src/Juki/Bundle/AppBundle/EventListener/CtaBlockSectionSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Juki\Bundle\AppBundle\EventListener;
  4. use Doctrine\Common\Util\Debug;
  5. use Hitso\Bundle\FormBundle\Event\FormEvent;
  6. use Hitso\Bundle\SectionBundle\Entity\Section\ProductListSection;
  7. use Hitso\Bundle\SectionBundle\Form\Section\ProductsListSectionType;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Validator\Constraints\NotBlank;
  11. use Symfony\Component\Validator\Constraints\NotNull;
  12. /**
  13.  * Class CtaBlockSectionSubscriber
  14.  *
  15.  * @package Juki\Bundle\AppBundle\EventListener
  16.  */
  17. final class CtaBlockSectionSubscriber implements EventSubscriberInterface
  18. {
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             'section.form_init' => 'onFormInit',
  23.         ];
  24.     }
  25.     public function onFormInit(FormEvent $event)
  26.     {
  27.         $builder $event->getBuilder();
  28.         if ($builder->getName() === "cta_block_section") {
  29.             $builder->add(
  30.                 'mode',
  31.                 ChoiceType::class,
  32.                 [
  33.                     'label'    => 'Rodzaj widoku',
  34.                     'choices'  => [
  35.                         'jasny'  => 'light',
  36.                         'ciemny' => 'dark',
  37.                     ],
  38.                     'position' => ['after' => 'identifier'],
  39.                 ]
  40.             );
  41.         }
  42.     }
  43. }