src/EventListener/SettingCreateListener.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use NexCRM\BaseBundle\Event\SettingsCreateEvent;
  4. use NexCRM\BaseBundle\ValueObject\SettingSection;
  5. use NexCRM\BaseBundle\ValueObject\SettingSectionItem;
  6. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  9. class SettingCreateListener
  10. {
  11.     /** @var AuthorizationCheckerInterface */
  12.     private $authorizationChecker;
  13.     public function __construct(
  14.         AuthorizationCheckerInterface $authorizationChecker
  15.     )
  16.     {
  17.         $this->authorizationChecker $authorizationChecker;
  18.     }
  19.     public function onBasebundleSettingCreate(SettingsCreateEvent $event)
  20.     {
  21.         if ($this->authorizationChecker->isGranted('ROLE_SETTINGS_ADMIN')) {
  22.             $appbundle = new SettingSection();
  23.             $appbundle->setAlias('app');
  24.             $appbundle->setName('Specifické web');
  25.             $appbundle->setPriority(4);
  26.             $appbundle->setIcon('plus');
  27.             $item = new SettingSectionItem();
  28.             $item->setAlias("map");
  29.             $item->setFormType(TextType::class);
  30.             $item->setOption([
  31.                 "label" => "Adresa pro mapu"
  32.             ]);
  33.             $appbundle->addSettingSectionItem($item);
  34.             $item = new SettingSectionItem();
  35.             $item->setAlias("storage_address");
  36.             $item->setFormType(TextareaType::class);
  37.             $item->setOption([
  38.                 "label" => "Adresa skladu"
  39.             ]);
  40.             $appbundle->addSettingSectionItem($item);
  41.             $item = new SettingSectionItem();
  42.             $item->setAlias("footer_address");
  43.             $item->setFormType(TextareaType::class);
  44.             $item->setOption([
  45.                 "label" => "Adresa v patičce"
  46.             ]);
  47.             $appbundle->addSettingSectionItem($item);
  48.             $item = new SettingSectionItem();
  49.             $item->setAlias("open_hours");
  50.             $item->setFormType(TextareaType::class);
  51.             $item->setOption([
  52.                 "label" => "Otevírací doba"
  53.             ]);
  54.             $appbundle->addSettingSectionItem($item);
  55.             $settings $event->getSetting();
  56.             $settings->addSettingSection($appbundle);
  57.         }
  58.     }
  59. }