Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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