Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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