Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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