Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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