Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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