@@ -302,55 +302,24 @@ public function runRequired(string $position = 'before')
302
302
}
303
303
}
304
304
305
- foreach ($ filtersClass [$ position ] as $ className ) {
306
- $ class = new $ className ();
307
-
308
- if (! $ class instanceof FilterInterface) {
309
- throw FilterException::forIncorrectInterface (get_class ($ class ));
310
- }
311
-
312
- if ($ position === 'before ' ) {
313
- $ result = $ class ->before (
314
- $ this ->request ,
315
- $ this ->argumentsClass [$ className ] ?? null
316
- );
317
-
318
- if ($ result instanceof RequestInterface) {
319
- $ this ->request = $ result ;
320
-
321
- continue ;
322
- }
323
-
324
- // If the response object was sent back,
325
- // then send it and quit.
326
- if ($ result instanceof ResponseInterface) {
327
- // short circuit - bypass any other filters
328
- return $ result ;
329
- }
330
- // Ignore an empty result
331
- if (empty ($ result )) {
332
- continue ;
333
- }
305
+ if ($ position === 'before ' ) {
306
+ $ result = $ this ->runBefore ($ filtersClass );
334
307
308
+ // If the response object was sent back,
309
+ // then send it and quit.
310
+ if ($ result instanceof ResponseInterface) {
311
+ // short circuit - bypass any other filters
335
312
return $ result ;
336
313
}
337
314
338
- if ($ position === 'after ' ) {
339
- $ result = $ class ->after (
340
- $ this ->request ,
341
- $ this ->response ,
342
- $ this ->argumentsClass [$ className ] ?? null
343
- );
344
-
345
- if ($ result instanceof ResponseInterface) {
346
- $ this ->response = $ result ;
315
+ return $ result ;
316
+ }
347
317
348
- continue ;
349
- }
350
- }
318
+ if ($ position === 'after ' ) {
319
+ $ result = $ this ->runAfter ($ filtersClass );
351
320
}
352
321
353
- return $ position === ' before ' ? $ this -> request : $ this -> response ;
322
+ return $ result ;
354
323
}
355
324
356
325
/**
0 commit comments