| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\HttpFoundation\RequestMatcher; |
| 13 |
|
| 14 |
use Symfony\Component\ExpressionLanguage\Expression; |
| 15 |
use Symfony\Component\ExpressionLanguage\ExpressionLanguage; |
| 16 |
use Symfony\Component\HttpFoundation\Request; |
| 17 |
use Symfony\Component\HttpFoundation\RequestMatcherInterface; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
class ExpressionRequestMatcher implements RequestMatcherInterface |
| 25 |
{ |
| 26 |
public function __construct( |
| 27 |
private ExpressionLanguage $language, |
| 28 |
private Expression|string $expression, |
| 29 |
) { |
| 30 |
} |
| 31 |
|
| 32 |
public function matches(Request $request): bool |
| 33 |
{ |
| 34 |
return $this->language->evaluate($this->expression, [ |
| 35 |
'request' => $request, |
| 36 |
'method' => $request->getMethod(), |
| 37 |
'path' => rawurldecode($request->getPathInfo()), |
| 38 |
'host' => $request->getHost(), |
| 39 |
'ip' => $request->getClientIp(), |
| 40 |
'attributes' => $request->attributes->all(), |
| 41 |
]); |
| 42 |
} |
| 43 |
} |