Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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