Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

@@ 666-694 (lines=29) @@
663
        });
664
665
        // Request Event
666
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function (\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) {
667
668
            if (!$event->isMasterRequest()) {
669
                return;
670
            }
671
672
            $route = $event->getRequest()->attributes->get('_route');
673
674
            if (is_null($route)) {
675
                return;
676
            }
677
678
            $app['monolog']->debug('KernelEvents::REQUEST '.$route);
679
680
            // 全体
681
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.request', $event);
682
683
            if (strpos($route, 'admin') === 0) {
684
                // 管理画面
685
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.request', $event);
686
            } else {
687
                // フロント画面
688
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.request', $event);
689
            }
690
691
            // ルーティング単位
692
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.request", $event);
693
694
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
695
696
        // Controller Event
697
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
@@ 697-724 (lines=28) @@
694
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
695
696
        // Controller Event
697
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
698
699
            if (!$event->isMasterRequest()) {
700
                return;
701
            }
702
703
            $route = $event->getRequest()->attributes->get('_route');
704
705
            if (is_null($route)) {
706
                return;
707
            }
708
709
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
710
711
            // 全体
712
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
713
714
            if (strpos($route, 'admin') === 0) {
715
                // 管理画面
716
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
717
            } else {
718
                // フロント画面
719
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
720
            }
721
722
            // ルーティング単位
723
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
724
        });
725
726
        // Response Event
727
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 727-753 (lines=27) @@
724
        });
725
726
        // Response Event
727
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
728
            if (!$event->isMasterRequest()) {
729
                return;
730
            }
731
732
            $route = $event->getRequest()->attributes->get('_route');
733
734
            if (is_null($route)) {
735
                return;
736
            }
737
738
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
739
740
            // ルーティング単位
741
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
742
743
            if (strpos($route, 'admin') === 0) {
744
                // 管理画面
745
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
746
            } else {
747
                // フロント画面
748
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
749
            }
750
751
            // 全体
752
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
753
        });
754
755
        // Exception Event
756
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 756-783 (lines=28) @@
753
        });
754
755
        // Exception Event
756
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
757
758
            if (!$event->isMasterRequest()) {
759
                return;
760
            }
761
762
            $route = $event->getRequest()->attributes->get('_route');
763
764
            if (is_null($route)) {
765
                return;
766
            }
767
768
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
769
770
            // ルーティング単位
771
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
772
773
            if (strpos($route, 'admin') === 0) {
774
                // 管理画面
775
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
776
            } else {
777
                // フロント画面
778
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
779
            }
780
781
            // 全体
782
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
783
        });
784
785
        // Terminate Event
786
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 786-809 (lines=24) @@
783
        });
784
785
        // Terminate Event
786
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
787
788
            $route = $event->getRequest()->attributes->get('_route');
789
790
            if (is_null($route)) {
791
                return;
792
            }
793
794
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
795
796
            // ルーティング単位
797
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
798
799
            if (strpos($route, 'admin') === 0) {
800
                // 管理画面
801
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
802
            } else {
803
                // フロント画面
804
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
805
            }
806
807
            // 全体
808
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
809
        });
810
    }
811
812
    public function loadPlugin()