Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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