Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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