app/Plugin/MultiCutDx/EventSubscriber/KernelEventSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright(c) 2019 SYSTEM_KD
  4.  * Date: 2019/06/15
  5.  */
  6. namespace Plugin\MultiCutDx\EventSubscriber;
  7. use Plugin\MultiCutDx\Config\ConfigSetting;
  8. use Plugin\MultiCutDx\Controller\ShippingMultipleControllerEx;
  9. use Plugin\MultiCutDx\Service\PlgConfigService\ConfigService;
  10. use Psr\Container\ContainerInterface;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. class KernelEventSubscriber implements EventSubscriberInterface
  15. {
  16.     protected $configService;
  17.     public function __construct(ConfigService $configService)
  18.     {
  19.         $this->configService $configService;
  20.     }
  21.     public function onKernelController(ControllerEvent $event)
  22.     {
  23.         $request $event->getRequest();
  24.         $route $request->attributes->get('_route');
  25.         if ('shopping_shipping_multiple' == $route
  26.             || 'shopping_shipping_multiple_edit' == $route) {
  27.             // 複数配送停止の場合
  28.             if ($this->configService->isKeyBool(ConfigSetting::GROUP_MULTI)) {
  29.                 // Shoppingへ戻す
  30.                 $shippingMultipleControllerEx = new ShippingMultipleControllerEx();
  31.                 $event->setController([$shippingMultipleControllerEx'index']);
  32.             }
  33.         }
  34.     }
  35.     /**
  36.      * Returns an array of event names this subscriber wants to listen to.
  37.      *
  38.      * The array keys are event names and the value can be:
  39.      *
  40.      *  * The method name to call (priority defaults to 0)
  41.      *  * An array composed of the method name to call and the priority
  42.      *  * An array of arrays composed of the method names to call and respective
  43.      *    priorities, or 0 if unset
  44.      *
  45.      * For instance:
  46.      *
  47.      *  * ['eventName' => 'methodName']
  48.      *  * ['eventName' => ['methodName', $priority]]
  49.      *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  50.      *
  51.      * @return array The event names to listen to
  52.      */
  53.     public static function getSubscribedEvents()
  54.     {
  55.         return [
  56.             KernelEvents::CONTROLLER => ['onKernelController', -10],
  57.         ];
  58.     }
  59. }