Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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