Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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