Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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