[Routing] added setContext() method to both matchers and generators

This commit is contained in:
Fabien Potencier 2011-01-24 16:59:32 +01:00
parent 49793c22d4
commit ca8c7907e2
4 changed files with 32 additions and 11 deletions

View File

@ -41,6 +41,16 @@ class UrlGenerator implements UrlGeneratorInterface
$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.
*

View File

@ -36,6 +36,16 @@ class ApacheUrlMatcher extends UrlMatcher
$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.
*

View File

@ -39,6 +39,16 @@ class UrlMatcher implements UrlMatcherInterface
$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.
*

View File

@ -94,17 +94,8 @@ class Router implements RouterInterface
*/
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);
}
/**