Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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