Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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