Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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