Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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