Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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