Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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