Code Duplication    Length = 24-29 lines in 5 locations

src/Eccube/ServiceProvider/EccubePluginServiceProvider.php 5 locations

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