Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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