Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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