1: <?php
2:
3: namespace PHPixie\Framework\Processors\HTTP;
4:
5: use PHPixie\Route\Translator;
6: use Psr\Http\Message\ServerRequestInterface;
7:
8: 9: 10:
11: class ParseRoute implements \PHPixie\Processors\Processor
12: {
13: 14: 15:
16: protected $routeTranslator;
17:
18: 19: 20: 21:
22: public function __construct($routeTranslator)
23: {
24: $this->routeTranslator = $routeTranslator;
25: }
26:
27: 28: 29: 30: 31:
32: public function process($serverRequest)
33: {
34: $match = $this->routeTranslator->match($serverRequest);
35:
36: if($match !== null) {
37: $attributes = $match->attributes();
38: $attributes['routeResolverPath'] = $match->resolverPath();
39:
40: foreach($attributes as $key => $value) {
41: $serverRequest = $serverRequest->withAttribute($key, $value);
42: }
43: }
44:
45: return $serverRequest;
46: }
47: }