app/Plugin/FwEasyHoliday42/Event.php line 30

Open in your IDE?
  1. <?php
  2. namespace Plugin\FwEasyHoliday42;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  8. class Event implements EventSubscriberInterface
  9. {
  10.     private $urlGenerator;
  11.     public function __construct(UrlGeneratorInterface $urlGenerator)
  12.     {
  13.         $this->urlGenerator $urlGenerator;
  14.     }
  15.     /**
  16.      * @return array
  17.      */
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             KernelEvents::RESPONSE => 'onKernelResponse',
  22.         ];
  23.     }
  24.     public function onKernelResponse(ResponseEvent $event)
  25.     {
  26.         $request $event->getRequest();
  27.         if ($request->attributes->get('_route') === 'admin_setting_shop_calendar') {
  28.             $url $this->urlGenerator->generate('fw_easy_holiday_admin_edit');
  29.             $event->setResponse(new RedirectResponse($url));
  30.         }
  31.     }
  32. }