Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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