Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/ServiceProvider/EccubePluginServiceProvider.php 5 locations

@@ 136-164 (lines=29) @@
133
        });
134
135
        // Request Event
136
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function (\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) {
137
138
            if (!$event->isMasterRequest()) {
139
                return;
140
            }
141
142
            $route = $event->getRequest()->attributes->get('_route');
143
144
            if (is_null($route)) {
145
                return;
146
            }
147
148
            $app['monolog']->debug('KernelEvents::REQUEST '.$route);
149
150
            // 全体
151
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.request', $event);
152
153
            if (strpos($route, 'admin') === 0) {
154
                // 管理画面
155
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.request', $event);
156
            } else {
157
                // フロント画面
158
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.request', $event);
159
            }
160
161
            // ルーティング単位
162
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.request", $event);
163
164
        }, 30); // Routing(32)が解決し, 認証判定(8)が実行される前のタイミング.
165
166
        // Controller Event
167
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
@@ 167-193 (lines=27) @@
164
        }, 30); // Routing(32)が解決し, 認証判定(8)が実行される前のタイミング.
165
166
        // Controller Event
167
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) {
168
169
            if (!$event->isMasterRequest()) {
170
                return;
171
            }
172
173
            $route = $event->getRequest()->attributes->get('_route');
174
175
            if (is_null($route)) {
176
                return;
177
            }
178
179
            $app['monolog']->debug('KernelEvents::CONTROLLER '.$route);
180
181
            // 全体
182
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.controller', $event);
183
184
            if (strpos($route, 'admin') === 0) {
185
                // 管理画面
186
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.controller', $event);
187
            } else {
188
                // フロント画面
189
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.controller', $event);
190
            }
191
            // ルーティング単位
192
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.controller", $event);
193
        });
194
195
        // Response Event
196
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
@@ 196-222 (lines=27) @@
193
        });
194
195
        // Response Event
196
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
197
            if (!$event->isMasterRequest()) {
198
                return;
199
            }
200
201
            $route = $event->getRequest()->attributes->get('_route');
202
203
            if (is_null($route)) {
204
                return;
205
            }
206
207
            $app['monolog']->debug('KernelEvents::RESPONSE '.$route);
208
209
            // ルーティング単位
210
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.response", $event);
211
212
            if (strpos($route, 'admin') === 0) {
213
                // 管理画面
214
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.response', $event);
215
            } else {
216
                // フロント画面
217
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.response', $event);
218
            }
219
220
            // 全体
221
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.response', $event);
222
        });
223
224
        // Exception Event
225
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
@@ 225-252 (lines=28) @@
222
        });
223
224
        // Exception Event
225
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) {
226
227
            if (!$event->isMasterRequest()) {
228
                return;
229
            }
230
231
            $route = $event->getRequest()->attributes->get('_route');
232
233
            if (is_null($route)) {
234
                return;
235
            }
236
237
            $app['monolog']->debug('KernelEvents::EXCEPTION '.$route);
238
239
            // ルーティング単位
240
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.exception", $event);
241
242
            if (strpos($route, 'admin') === 0) {
243
                // 管理画面
244
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.exception', $event);
245
            } else {
246
                // フロント画面
247
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.exception', $event);
248
            }
249
250
            // 全体
251
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.exception', $event);
252
        });
253
254
        // Terminate Event
255
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
@@ 255-278 (lines=24) @@
252
        });
253
254
        // Terminate Event
255
        $app->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) {
256
257
            $route = $event->getRequest()->attributes->get('_route');
258
259
            if (is_null($route)) {
260
                return;
261
            }
262
263
            $app['monolog']->debug('KernelEvents::TERMINATE '.$route);
264
265
            // ルーティング単位
266
            $app['eccube.event.dispatcher']->dispatch("eccube.event.route.{$route}.terminate", $event);
267
268
            if (strpos($route, 'admin') === 0) {
269
                // 管理画面
270
                $app['eccube.event.dispatcher']->dispatch('eccube.event.admin.terminate', $event);
271
            } else {
272
                // フロント画面
273
                $app['eccube.event.dispatcher']->dispatch('eccube.event.front.terminate', $event);
274
            }
275
276
            // 全体
277
            $app['eccube.event.dispatcher']->dispatch('eccube.event.app.terminate', $event);
278
        });
279
    }
280
281
    public function loadPlugin(Application $app)