Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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