Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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