Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

@@ 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 (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
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-741 (lines=29) @@
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 (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
716
                return;
717
            }
718
719
720
            $route = $event->getRequest()->attributes->get('_route');
721
722
            if (is_null($route)) {
723
                return;
724
            }
725
726
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
727
728
            // 全体
729
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
730
731
            if (strpos($route, 'admin') === 0) {
732
                // 管理画面
733
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
734
            } else {
735
                // フロント画面
736
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
737
            }
738
739
            // ルーティング単位
740
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
741
        });
742
743
        // Response Event
744
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 744-771 (lines=28) @@
741
        });
742
743
        // Response Event
744
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
745
746
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
747
                return;
748
            }
749
750
            $route = $event->getRequest()->attributes->get('_route');
751
752
            if (is_null($route)) {
753
                return;
754
            }
755
756
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
757
758
            // ルーティング単位
759
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
760
761
            if (strpos($route, 'admin') === 0) {
762
                // 管理画面
763
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
764
            } else {
765
                // フロント画面
766
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
767
            }
768
769
            // 全体
770
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
771
        });
772
773
        // Exception Event
774
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 774-801 (lines=28) @@
771
        });
772
773
        // Exception Event
774
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
775
776
            if (\Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
777
                return;
778
            }
779
780
            $route = $event->getRequest()->attributes->get('_route');
781
782
            if (is_null($route)) {
783
                return;
784
            }
785
786
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
787
788
            // ルーティング単位
789
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
790
791
            if (strpos($route, 'admin') === 0) {
792
                // 管理画面
793
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
794
            } else {
795
                // フロント画面
796
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
797
            }
798
799
            // 全体
800
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
801
        });
802
803
        // Terminate Event
804
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 804-827 (lines=24) @@
801
        });
802
803
        // Terminate Event
804
        $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
805
806
            $route = $event->getRequest()->attributes->get('_route');
807
808
            if (is_null($route)) {
809
                return;
810
            }
811
812
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
813
814
            // ルーティング単位
815
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
816
817
            if (strpos($route, 'admin') === 0) {
818
                // 管理画面
819
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
820
            } else {
821
                // フロント画面
822
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
823
            }
824
825
            // 全体
826
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
827
        });
828
    }
829
830
    public function loadPlugin()