Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/Application.php 5 locations

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