Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

@@ 708-736 (lines=29) @@
705
        });
706
707
        // Request Event
708
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function (\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) {
709
710
            if (!$event->isMasterRequest()) {
711
                return;
712
            }
713
714
            $route = $event->getRequest()->attributes->get('_route');
715
716
            if (is_null($route)) {
717
                return;
718
            }
719
720
            $app['monolog']->debug('KernelEvents::REQUEST '.$route);
721
722
            // 全体
723
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.request', $event);
724
725
            if (strpos($route, 'admin') === 0) {
726
                // 管理画面
727
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.request', $event);
728
            } else {
729
                // フロント画面
730
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.request', $event);
731
            }
732
733
            // ルーティング単位
734
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.request", $event);
735
736
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
737
738
        // Controller Event
739
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
@@ 739-766 (lines=28) @@
736
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
737
738
        // Controller Event
739
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
740
741
            if (!$event->isMasterRequest()) {
742
                return;
743
            }
744
745
            $route = $event->getRequest()->attributes->get('_route');
746
747
            if (is_null($route)) {
748
                return;
749
            }
750
751
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
752
753
            // 全体
754
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
755
756
            if (strpos($route, 'admin') === 0) {
757
                // 管理画面
758
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
759
            } else {
760
                // フロント画面
761
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
762
            }
763
764
            // ルーティング単位
765
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
766
        });
767
768
        // Response Event
769
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 769-795 (lines=27) @@
766
        });
767
768
        // Response Event
769
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
770
            if (!$event->isMasterRequest()) {
771
                return;
772
            }
773
774
            $route = $event->getRequest()->attributes->get('_route');
775
776
            if (is_null($route)) {
777
                return;
778
            }
779
780
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
781
782
            // ルーティング単位
783
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
784
785
            if (strpos($route, 'admin') === 0) {
786
                // 管理画面
787
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
788
            } else {
789
                // フロント画面
790
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
791
            }
792
793
            // 全体
794
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
795
        });
796
797
        // Exception Event
798
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 798-825 (lines=28) @@
795
        });
796
797
        // Exception Event
798
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
799
800
            if (!$event->isMasterRequest()) {
801
                return;
802
            }
803
804
            $route = $event->getRequest()->attributes->get('_route');
805
806
            if (is_null($route)) {
807
                return;
808
            }
809
810
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
811
812
            // ルーティング単位
813
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
814
815
            if (strpos($route, 'admin') === 0) {
816
                // 管理画面
817
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
818
            } else {
819
                // フロント画面
820
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
821
            }
822
823
            // 全体
824
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
825
        });
826
827
        // Terminate Event
828
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 828-851 (lines=24) @@
825
        });
826
827
        // Terminate Event
828
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
829
830
            $route = $event->getRequest()->attributes->get('_route');
831
832
            if (is_null($route)) {
833
                return;
834
            }
835
836
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
837
838
            // ルーティング単位
839
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
840
841
            if (strpos($route, 'admin') === 0) {
842
                // 管理画面
843
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
844
            } else {
845
                // フロント画面
846
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
847
            }
848
849
            // 全体
850
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
851
        });
852
    }
853
854
    public function loadPlugin()