Code Duplication    Length = 26-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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