Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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