Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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