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