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 (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
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-756 (lines=29) @@
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 (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
731
                return;
732
            }
733
734
735
            $route = $event->getRequest()->attributes->get('_route');
736
737
            if (is_null($route)) {
738
                return;
739
            }
740
741
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
742
743
            // 全体
744
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
745
746
            if (strpos($route, 'admin') === 0) {
747
                // 管理画面
748
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
749
            } else {
750
                // フロント画面
751
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
752
            }
753
754
            // ルーティング単位
755
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
756
        });
757
758
        // Response Event
759
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 759-786 (lines=28) @@
756
        });
757
758
        // Response Event
759
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
760
761
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
762
                return;
763
            }
764
765
            $route = $event->getRequest()->attributes->get('_route');
766
767
            if (is_null($route)) {
768
                return;
769
            }
770
771
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
772
773
            // ルーティング単位
774
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
775
776
            if (strpos($route, 'admin') === 0) {
777
                // 管理画面
778
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
779
            } else {
780
                // フロント画面
781
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
782
            }
783
784
            // 全体
785
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
786
        });
787
788
        // Exception Event
789
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 789-816 (lines=28) @@
786
        });
787
788
        // Exception Event
789
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
790
791
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
792
                return;
793
            }
794
795
            $route = $event->getRequest()->attributes->get('_route');
796
797
            if (is_null($route)) {
798
                return;
799
            }
800
801
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
802
803
            // ルーティング単位
804
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
805
806
            if (strpos($route, 'admin') === 0) {
807
                // 管理画面
808
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
809
            } else {
810
                // フロント画面
811
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
812
            }
813
814
            // 全体
815
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
816
        });
817
818
        // Terminate Event
819
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 819-842 (lines=24) @@
816
        });
817
818
        // Terminate Event
819
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
820
821
            $route = $event->getRequest()->attributes->get('_route');
822
823
            if (is_null($route)) {
824
                return;
825
            }
826
827
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
828
829
            // ルーティング単位
830
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
831
832
            if (strpos($route, 'admin') === 0) {
833
                // 管理画面
834
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
835
            } else {
836
                // フロント画面
837
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
838
            }
839
840
            // 全体
841
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
842
        });
843
    }
844
845
    public function loadPlugin()