From ca8c7907e238d5240696383d09ee88d2318c2760 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 24 Jan 2011 16:59:32 +0100 Subject: [PATCH] [Routing] added setContext() method to both matchers and generators --- .../Component/Routing/Generator/UrlGenerator.php | 10 ++++++++++ .../Component/Routing/Matcher/ApacheUrlMatcher.php | 10 ++++++++++ .../Component/Routing/Matcher/UrlMatcher.php | 10 ++++++++++ src/Symfony/Component/Routing/Router.php | 13 ++----------- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index b9f4ae1376ef..759c0c81c5ed 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -41,6 +41,16 @@ public function __construct(RouteCollection $routes, array $context = array(), a $this->cache = array(); } + /** + * Sets the request context. + * + * @param array $context The context + */ + public function setContext(array $context = array()) + { + $this->context = $context; + } + /** * Generates a URL from the given parameters. * diff --git a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php index 60e0f427bc86..bec07b104f51 100644 --- a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php @@ -36,6 +36,16 @@ public function __construct(array $context = array(), array $defaults = array()) $this->defaults = $defaults; } + /** + * Sets the request context. + * + * @param array $context The context + */ + public function setContext(array $context = array()) + { + $this->context = $context; + } + /** * Tries to match a URL based on Apache mod_rewrite matching. * diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index a9f45c482445..d1f42eb5fe32 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -39,6 +39,16 @@ public function __construct(RouteCollection $routes, array $context = array(), a $this->defaults = $defaults; } + /** + * Sets the request context. + * + * @param array $context The context + */ + public function setContext(array $context = array()) + { + $this->context = $context; + } + /** * Tries to match a URL with a set of routes. * diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 955f2ff9dab3..cc90ee8dc1ff 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -94,17 +94,8 @@ public function getRouteCollection() */ public function setContext(array $context = array()) { - $this->context = $context; - } - - /** - * Sets the defaults. - * - * @param array $defaults The defaults - */ - public function setDefaults(array $defaults = array()) - { - $this->defaults = $defaults; + $this->getMatcher()->setContext($context); + $this->getGenerator()->setContext($context); } /**