Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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