Mercurial > hg > isophonics-drupal-site
annotate vendor/symfony/http-foundation/ExpressionRequestMatcher.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 /* |
Chris@0 | 4 * This file is part of the Symfony package. |
Chris@0 | 5 * |
Chris@0 | 6 * (c) Fabien Potencier <fabien@symfony.com> |
Chris@0 | 7 * |
Chris@0 | 8 * For the full copyright and license information, please view the LICENSE |
Chris@0 | 9 * file that was distributed with this source code. |
Chris@0 | 10 */ |
Chris@0 | 11 |
Chris@0 | 12 namespace Symfony\Component\HttpFoundation; |
Chris@0 | 13 |
Chris@0 | 14 use Symfony\Component\ExpressionLanguage\ExpressionLanguage; |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * ExpressionRequestMatcher uses an expression to match a Request. |
Chris@0 | 18 * |
Chris@0 | 19 * @author Fabien Potencier <fabien@symfony.com> |
Chris@0 | 20 */ |
Chris@0 | 21 class ExpressionRequestMatcher extends RequestMatcher |
Chris@0 | 22 { |
Chris@0 | 23 private $language; |
Chris@0 | 24 private $expression; |
Chris@0 | 25 |
Chris@0 | 26 public function setExpression(ExpressionLanguage $language, $expression) |
Chris@0 | 27 { |
Chris@0 | 28 $this->language = $language; |
Chris@0 | 29 $this->expression = $expression; |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 public function matches(Request $request) |
Chris@0 | 33 { |
Chris@0 | 34 if (!$this->language) { |
Chris@0 | 35 throw new \LogicException('Unable to match the request as the expression language is not available.'); |
Chris@0 | 36 } |
Chris@0 | 37 |
Chris@17 | 38 return $this->language->evaluate($this->expression, [ |
Chris@0 | 39 'request' => $request, |
Chris@0 | 40 'method' => $request->getMethod(), |
Chris@0 | 41 'path' => rawurldecode($request->getPathInfo()), |
Chris@0 | 42 'host' => $request->getHost(), |
Chris@0 | 43 'ip' => $request->getClientIp(), |
Chris@0 | 44 'attributes' => $request->attributes->all(), |
Chris@17 | 45 ]) && parent::matches($request); |
Chris@0 | 46 } |
Chris@0 | 47 } |