Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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