Exception
2 years ago
File
2 years ago
Session
2 years ago
Tests
2 years ago
AcceptHeader.php
2 years ago
AcceptHeaderItem.php
2 years ago
ApacheRequest.php
2 years ago
BinaryFileResponse.php
2 years ago
Cookie.php
2 years ago
ExpressionRequestMatcher.php
2 years ago
FileBag.php
2 years ago
HeaderBag.php
2 years ago
IpUtils.php
2 years ago
JsonResponse.php
2 years ago
LICENSE
2 years ago
ParameterBag.php
2 years ago
RedirectResponse.php
2 years ago
Request.php
2 years ago
RequestMatcher.php
2 years ago
RequestMatcherInterface.php
2 years ago
RequestStack.php
2 years ago
Response.php
2 years ago
ResponseHeaderBag.php
2 years ago
ServerBag.php
2 years ago
StreamedResponse.php
2 years ago
ExpressionRequestMatcher.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | * |
| 11 | * Modified by impress-org on 23-January-2024 using Strauss. |
| 12 | * @see https://github.com/BrianHenryIE/strauss |
| 13 | */ |
| 14 | |
| 15 | namespace Give\Vendors\Symfony\Component\HttpFoundation; |
| 16 | |
| 17 | use Symfony\Component\ExpressionLanguage\ExpressionLanguage; |
| 18 | |
| 19 | /** |
| 20 | * ExpressionRequestMatcher uses an expression to match a Request. |
| 21 | * |
| 22 | * @author Fabien Potencier <fabien@symfony.com> |
| 23 | */ |
| 24 | class ExpressionRequestMatcher extends RequestMatcher |
| 25 | { |
| 26 | private $language; |
| 27 | private $expression; |
| 28 | |
| 29 | public function setExpression(ExpressionLanguage $language, $expression) |
| 30 | { |
| 31 | $this->language = $language; |
| 32 | $this->expression = $expression; |
| 33 | } |
| 34 | |
| 35 | public function matches(Request $request) |
| 36 | { |
| 37 | if (!$this->language) { |
| 38 | throw new \LogicException('Unable to match the request as the expression language is not available.'); |
| 39 | } |
| 40 | |
| 41 | return $this->language->evaluate($this->expression, [ |
| 42 | 'request' => $request, |
| 43 | 'method' => $request->getMethod(), |
| 44 | 'path' => rawurldecode($request->getPathInfo()), |
| 45 | 'host' => $request->getHost(), |
| 46 | 'ip' => $request->getClientIp(), |
| 47 | 'attributes' => $request->attributes->all(), |
| 48 | ]) && parent::matches($request); |
| 49 | } |
| 50 | } |
| 51 |