summaryrefslogtreecommitdiffstats
path: root/Http
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2012-06-26 11:17:51 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2012-06-26 11:18:35 +0200
commita86fab245763a1bb7e81a55d5acb621cf3f31345 (patch)
tree10ba98fd30c1c30077652b49568fd95a4d16b684 /Http
parent1ddd70f2c3d9baeb28f1f13024a100fd25e6fdde (diff)
downloadsymfony-security-a86fab245763a1bb7e81a55d5acb621cf3f31345.zip
symfony-security-a86fab245763a1bb7e81a55d5acb621cf3f31345.tar.gz
symfony-security-a86fab245763a1bb7e81a55d5acb621cf3f31345.tar.bz2
[Security] changed the HttpUtils constructor to tak both a UrlGenerator and a UrlMatcher instead of a Router (to make it useable by Silex)
Diffstat (limited to 'Http')
-rw-r--r--Http/HttpUtils.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php
index f62f84d..de40e1e 100644
--- a/Http/HttpUtils.php
+++ b/Http/HttpUtils.php
@@ -15,7 +15,8 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\Routing\RouterInterface;
+use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
@@ -26,16 +27,19 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
*/
class HttpUtils
{
- private $router;
+ private $urlGenerator;
+ private $urlMatcher;
/**
* Constructor.
*
- * @param RouterInterface $router An RouterInterface instance
+ * @param UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance
+ * @param UrlMatcherInterface $urlMatcher A UrlMatcherInterface instance
*/
- public function __construct(RouterInterface $router = null)
+ public function __construct(UrlGeneratorInterface $urlGenerator = null, UrlMatcherInterface $urlMatcher = null)
{
- $this->router = $router;
+ $this->urlGenerator = $urlGenerator;
+ $this->urlMatcher = $urlMatcher;
}
/**
@@ -105,7 +109,7 @@ class HttpUtils
{
if ('/' !== $path[0]) {
try {
- $parameters = $this->router->match($request->getPathInfo());
+ $parameters = $this->urlMatcher->match($request->getPathInfo());
return $path === $parameters['_route'];
} catch (MethodNotAllowedException $e) {
@@ -120,10 +124,10 @@ class HttpUtils
private function generateUrl($route, $absolute = false)
{
- if (null === $this->router) {
- throw new \LogicException('You must provide a RouterInterface instance to be able to use routes.');
+ if (null === $this->urlGenerator) {
+ throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
}
- return $this->router->generate($route, array(), $absolute);
+ return $this->urlGenerator->generate($route, array(), $absolute);
}
}