cookieChecker = $cookieChecker; $this->cookieCategories = $cookieCategories; $this->cookieConsentSimplified = $cookieConsentSimplified; } public function buildForm(FormBuilderInterface $builder, array $options) { foreach ($this->cookieCategories as $category) { $builder->remove($category); $data = 'true'; if ($this->cookieChecker->isCookieConsentSavedByUser() && !$this->cookieChecker->isCategoryAllowedByUser( $category )) { $data = 'false'; } $builder->add( $category, ChoiceType::class, [ 'expanded' => true, 'multiple' => false, 'data' => $data, 'choices' => [ ['ch_cookie_consent.yes' => 'true'], ['ch_cookie_consent.no' => 'false'], ], ] ); } } public static function getExtendedTypes(): iterable { return [BaseCookieConsentType::class]; } }