diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-01-04 18:02:19 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-01-04 18:02:19 +0100 |
commit | de6cab31d0b451b163dd2f44adc2e87d1162e3e7 (patch) | |
tree | cbb337d23b4ccb30c5075c2096bd65d90bb1d40e /Http/HttpUtils.php | |
parent | cd57792e86d613ecd2d7b47acb048465f969aa1f (diff) | |
parent | e05ddf24cfcfb76cb7c3e1175ebca6ac3af3d1f6 (diff) | |
download | symfony-security-de6cab31d0b451b163dd2f44adc2e87d1162e3e7.zip symfony-security-de6cab31d0b451b163dd2f44adc2e87d1162e3e7.tar.gz symfony-security-de6cab31d0b451b163dd2f44adc2e87d1162e3e7.tar.bz2 |
Merge branch '2.1'
* 2.1: (24 commits)
updated license year
Update src/Symfony/Component/HttpFoundation/Response.php
[Form] Fixed inheritance of "error_bubbling" in RepeatedType
[Form] Fixed DateType when used with the intl extension disabled.
[HttpFoundation] fix return types and handling of zero in Response
[HttpFoundation] better fix for non-parseable Expires header date
Fixed missing plural message in portuguese validator
Fix Expires when the header is -1
[DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets.
[Console] fixed unitialized properties (closes #5935)
[Process] Prevented test from failing when pcntl extension is not enabled.
Revert "[DoctrineBridge] Improved performance of the EntityType when used with the "query_builder" option"
[Form] Fixed failing tests for DateTimeToStringTransformer.
[Locale] Fixed the StubLocaleTest for ICU versions lower than 4.8.
[Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
[Form] Fixed test regression introduced in #6440
[Tests] Fix namespaces
Fixed php doc of GenericEvent::__construct
HttpUtils must handle RequestMatcher too
use preferred_choices in favor of preferred_query
...
Conflicts:
src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php
Diffstat (limited to 'Http/HttpUtils.php')
-rw-r--r-- | Http/HttpUtils.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php index 76cfc6a..746b217 100644 --- a/Http/HttpUtils.php +++ b/Http/HttpUtils.php @@ -16,6 +16,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; +use Symfony\Component\HttpFoundation\RequestMatcherInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\ResourceNotFoundException; @@ -33,12 +34,15 @@ class HttpUtils /** * Constructor. * - * @param UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance - * @param UrlMatcherInterface $urlMatcher A UrlMatcherInterface instance + * @param UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance + * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher */ - public function __construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface $urlMatcher = null) + public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatcher = null) { $this->urlGenerator = $urlGenerator; + if ($urlMatcher !== null && !$urlMatcher instanceof UrlMatcherInterface && !$urlMatcher instanceof RequestMatcherInterface) { + throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); + } $this->urlMatcher = $urlMatcher; } @@ -96,7 +100,12 @@ class HttpUtils { if ('/' !== $path[0]) { try { - $parameters = $this->urlMatcher->match($request->getPathInfo()); + // matching a request is more powerful than matching a URL path + context, so try that first + if ($this->urlMatcher instanceof RequestMatcherInterface) { + $parameters = $this->urlMatcher->matchRequest($request); + } else { + $parameters = $this->urlMatcher->match($request->getPathInfo()); + } return $path === $parameters['_route']; } catch (MethodNotAllowedException $e) { |