Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

@@ 769-797 (lines=29) @@
766
        });
767
768
        // Request Event
769
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function (\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) {
770
771
            if (!$event->isMasterRequest()) {
772
                return;
773
            }
774
775
            $route = $event->getRequest()->attributes->get('_route');
776
777
            if (is_null($route)) {
778
                return;
779
            }
780
781
            $app['monolog']->debug('KernelEvents::REQUEST '.$route);
782
783
            // 全体
784
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.request', $event);
785
786
            if (strpos($route, 'admin') === 0) {
787
                // 管理画面
788
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.request', $event);
789
            } else {
790
                // フロント画面
791
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.request', $event);
792
            }
793
794
            // ルーティング単位
795
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.request", $event);
796
797
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
798
799
        // Controller Event
800
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
@@ 800-827 (lines=28) @@
797
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
798
799
        // Controller Event
800
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
801
802
            if (!$event->isMasterRequest()) {
803
                return;
804
            }
805
806
            $route = $event->getRequest()->attributes->get('_route');
807
808
            if (is_null($route)) {
809
                return;
810
            }
811
812
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
813
814
            // 全体
815
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
816
817
            if (strpos($route, 'admin') === 0) {
818
                // 管理画面
819
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
820
            } else {
821
                // フロント画面
822
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
823
            }
824
825
            // ルーティング単位
826
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
827
        });
828
829
        // Response Event
830
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 830-856 (lines=27) @@
827
        });
828
829
        // Response Event
830
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
831
            if (!$event->isMasterRequest()) {
832
                return;
833
            }
834
835
            $route = $event->getRequest()->attributes->get('_route');
836
837
            if (is_null($route)) {
838
                return;
839
            }
840
841
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
842
843
            // ルーティング単位
844
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
845
846
            if (strpos($route, 'admin') === 0) {
847
                // 管理画面
848
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
849
            } else {
850
                // フロント画面
851
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
852
            }
853
854
            // 全体
855
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
856
        });
857
858
        // Exception Event
859
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 859-886 (lines=28) @@
856
        });
857
858
        // Exception Event
859
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
860
861
            if (!$event->isMasterRequest()) {
862
                return;
863
            }
864
865
            $route = $event->getRequest()->attributes->get('_route');
866
867
            if (is_null($route)) {
868
                return;
869
            }
870
871
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
872
873
            // ルーティング単位
874
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
875
876
            if (strpos($route, 'admin') === 0) {
877
                // 管理画面
878
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
879
            } else {
880
                // フロント画面
881
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
882
            }
883
884
            // 全体
885
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
886
        });
887
888
        // Terminate Event
889
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 889-912 (lines=24) @@
886
        });
887
888
        // Terminate Event
889
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
890
891
            $route = $event->getRequest()->attributes->get('_route');
892
893
            if (is_null($route)) {
894
                return;
895
            }
896
897
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
898
899
            // ルーティング単位
900
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
901
902
            if (strpos($route, 'admin') === 0) {
903
                // 管理画面
904
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
905
            } else {
906
                // フロント画面
907
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
908
            }
909
910
            // 全体
911
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
912
        });
913
    }
914
915
    public function loadPlugin()