Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

@@ 737-765 (lines=29) @@
734
        });
735
736
        // Request Event
737
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function(\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) {
738
739
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
740
                return;
741
            }
742
743
            $route = $event->getRequest()->attributes->get('_route');
744
745
            if (is_null($route)) {
746
                return;
747
            }
748
749
            $app['monolog']->debug('KernelEvents::REQUEST '.$route);
750
751
            // 全体
752
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.request', $event);
753
754
            if (strpos($route, 'admin') === 0) {
755
                // 管理画面
756
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.request', $event);
757
            } else {
758
                // フロント画面
759
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.request', $event);
760
            }
761
762
            // ルーティング単位
763
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.request", $event);
764
765
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
766
767
        // Controller Event
768
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function(\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
@@ 768-796 (lines=29) @@
765
        }, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング.
766
767
        // Controller Event
768
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function(\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
769
770
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
771
                return;
772
            }
773
774
775
            $route = $event->getRequest()->attributes->get('_route');
776
777
            if (is_null($route)) {
778
                return;
779
            }
780
781
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
782
783
            // 全体
784
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
785
786
            if (strpos($route, 'admin') === 0) {
787
                // 管理画面
788
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
789
            } else {
790
                // フロント画面
791
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
792
            }
793
794
            // ルーティング単位
795
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
796
        });
797
798
        // Response Event
799
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 799-826 (lines=28) @@
796
        });
797
798
        // Response Event
799
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
800
801
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
802
                return;
803
            }
804
805
            $route = $event->getRequest()->attributes->get('_route');
806
807
            if (is_null($route)) {
808
                return;
809
            }
810
811
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
812
813
            // ルーティング単位
814
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
815
816
            if (strpos($route, 'admin') === 0) {
817
                // 管理画面
818
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
819
            } else {
820
                // フロント画面
821
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
822
            }
823
824
            // 全体
825
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
826
        });
827
828
        // Exception Event
829
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 829-856 (lines=28) @@
826
        });
827
828
        // Exception Event
829
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
830
831
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
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::EXCEPTION '.$route);
842
843
            // ルーティング単位
844
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
845
846
            if (strpos($route, 'admin') === 0) {
847
                // 管理画面
848
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
849
            } else {
850
                // フロント画面
851
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
852
            }
853
854
            // 全体
855
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
856
        });
857
858
        // Terminate Event
859
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 859-882 (lines=24) @@
856
        });
857
858
        // Terminate Event
859
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
860
861
            $route = $event->getRequest()->attributes->get('_route');
862
863
            if (is_null($route)) {
864
                return;
865
            }
866
867
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
868
869
            // ルーティング単位
870
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
871
872
            if (strpos($route, 'admin') === 0) {
873
                // 管理画面
874
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
875
            } else {
876
                // フロント画面
877
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
878
            }
879
880
            // 全体
881
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
882
        });
883
    }
884
885
    public function loadPlugin()