Skip to content

Commit

Permalink
[Routing] added setContext() method to both matchers and generators
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 24, 2011
1 parent 49793c2 commit ca8c790
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Component/Routing/Generator/UrlGenerator.php
Expand Up @@ -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.
*
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php
Expand Up @@ -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.
*
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Expand Up @@ -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.
*
Expand Down
13 changes: 2 additions & 11 deletions src/Symfony/Component/Routing/Router.php
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit ca8c790

Please sign in to comment.