Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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