1 | <?php |
||
2 | |||
3 | declare(strict_types = 1); |
||
4 | |||
5 | namespace inroutephp\inroute\Compiler\Dsl; |
||
6 | |||
7 | use inroutephp\inroute\Annotations\Pipe; |
||
8 | use inroutephp\inroute\Compiler\CompilerPassInterface; |
||
9 | use inroutephp\inroute\Runtime\RouteInterface; |
||
10 | |||
11 | final class PipeCompilerPass implements CompilerPassInterface |
||
12 | { |
||
13 | public function processRoute(RouteInterface $route): RouteInterface |
||
14 | { |
||
15 | /** @var Pipe $pipe */ |
||
16 | foreach ($route->getAnnotations(Pipe::CLASS) as $pipe) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
17 | foreach ((array)$pipe->middlewares as $middleware) { |
||
18 | $route = $route->withMiddleware($middleware); |
||
19 | } |
||
20 | |||
21 | foreach ((array)$pipe->attributes as $key => $value) { |
||
22 | $route = $route->withAttribute($key, $value); |
||
23 | } |
||
24 | } |
||
25 | |||
26 | return $route; |
||
27 | } |
||
28 | } |
||
29 |