src/Juki/Bundle/AppBundle/EventListener/GroupSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Juki\Bundle\AppBundle\EventListener;
  4. use Hitso\Bundle\CommonBundle\Form\Type\TinyMCEType;
  5. use Hitso\Bundle\FormBundle\Event\FormEvent;
  6. use Hitso\Bundle\FormBundle\Form\Type\ImageType;
  7. use Juki\Bundle\AppBundle\Entity\Dictionary\Shop;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  10. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  11. /**
  12.  * Class GroupSubscriber
  13.  *
  14.  * @package Juki\Bundle\AppBundle\EventListener
  15.  */
  16. final class GroupSubscriber implements EventSubscriberInterface
  17. {
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             'group_type.form_init' => 'onFormInit',
  22.         ];
  23.     }
  24.     public function onFormInit(FormEvent $event)
  25.     {
  26.         $builder $event->getBuilder();
  27.         $builder->add('shopType',
  28.             ChoiceType::class, [
  29.                 'label'      => 'Rodzaj strony',
  30.                 'choices'    => [
  31.                     'ISM' => Shop::ISM_SYMBOL,
  32.                     'HSM' => Shop::HSM_SYMBOL,
  33.                 ],
  34.                 'empty_data' => Shop::ISM_SYMBOL,
  35.                 'required'   => true,
  36.                 'position'   => ['after' => 'slug'],
  37.             ]
  38.         );
  39.         $builder->add(
  40.             'landingPage',
  41.             CheckboxType::class,
  42.             [
  43.                 'label'    => 'Landing page',
  44.                 'required' => false,
  45.                 'position' => ['before' => 'published'],
  46.             ]
  47.         );
  48.         $builder->add(
  49.             'description',
  50.             TinyMCEType::class,
  51.             [
  52.                 'label'      => 'Opis',
  53.                 'required'   => false,
  54.                 'empty_data' => '',
  55.                 'config'     => [
  56.                     'toolbar' => [
  57.                         'styleselect | bullist numlist | bold italic | link unlink | pastetext removeformat | code',
  58.                     ],
  59.                 ],
  60.                 'position'   => ['after' => 'shopType'],
  61.             ]
  62.         );
  63.         $builder->add(
  64.             'photo',
  65.             ImageType::class,
  66.             [
  67.                 'label'       => 'Zdjęcie',
  68.                 'config_name' => 'product_image',
  69.                 'required'    => false,
  70.                 'position'    => ['after' => 'description'],
  71.             ]
  72.         );
  73.     }
  74. }