[Routing] changed UrlGeneratorInterface::generate() signature to allow passing objects instead of arrays

This commit is contained in:
Fabien Potencier 2011-07-26 07:57:40 +02:00
parent 1543ad159d
commit 04ac1fdba2
7 changed files with 15 additions and 15 deletions

View File

@ -40,12 +40,12 @@ class RoutingExtension extends \Twig_Extension
);
}
public function getPath($name, array $parameters = array())
public function getPath($name, $parameters = array())
{
return $this->generator->generate($name, $parameters, false);
}
public function getUrl($name, array $parameters = array())
public function getUrl($name, $parameters = array())
{
return $this->generator->generate($name, $parameters, true);
}

View File

@ -34,12 +34,12 @@ class Controller extends ContainerAware
* Generates a URL from the given parameters.
*
* @param string $name The name of the route
* @param array $parameters An array of parameters
* @param mixed $parameters An array of parameters
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
*/
public function generateUrl($route, array $parameters = array(), $absolute = false)
public function generateUrl($route, $parameters = array(), $absolute = false)
{
return $this->container->get('router')->generate($route, $parameters, $absolute);
}

View File

@ -37,12 +37,12 @@ class RouterHelper extends Helper
* Generates a URL from the given parameters.
*
* @param string $name The name of the route
* @param array $parameters An array of parameters
* @param mixed $parameters An array of parameters
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
*/
public function generate($name, array $parameters = array(), $absolute = false)
public function generate($name, $parameters = array(), $absolute = false)
{
return $this->generator->generate($name, $parameters, $absolute);
}

View File

@ -78,7 +78,7 @@ EOF
return <<<EOF
public function generate(\$name, array \$parameters = array(), \$absolute = false)
public function generate(\$name, \$parameters = array(), \$absolute = false)
{
if (!isset(self::\$declaredRouteNames[\$name])) {
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', \$name));

View File

@ -33,8 +33,8 @@ class UrlGenerator implements UrlGeneratorInterface
'%2F' => '/',
);
private $routes;
private $cache;
protected $routes;
protected $cache;
/**
* Constructor.
@ -77,7 +77,7 @@ class UrlGenerator implements UrlGeneratorInterface
* Generates a URL from the given parameters.
*
* @param string $name The name of the route
* @param array $parameters An array of parameters
* @param mixed $parameters An array of parameters
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
@ -86,7 +86,7 @@ class UrlGenerator implements UrlGeneratorInterface
*
* @api
*/
public function generate($name, array $parameters = array(), $absolute = false)
public function generate($name, $parameters = array(), $absolute = false)
{
if (null === $route = $this->routes->get($name)) {
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));

View File

@ -26,12 +26,12 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
* Generates a URL from the given parameters.
*
* @param string $name The name of the route
* @param array $parameters An array of parameters
* @param mixed $parameters An array of parameters
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
*
* @api
*/
function generate($name, array $parameters = array(), $absolute = false);
function generate($name, $parameters = array(), $absolute = false);
}

View File

@ -171,12 +171,12 @@ class Router implements RouterInterface
* Generates a URL from the given parameters.
*
* @param string $name The name of the route
* @param array $parameters An array of parameters
* @param mixed $parameters An array of parameters
* @param Boolean $absolute Whether to generate an absolute URL
*
* @return string The generated URL
*/
public function generate($name, array $parameters = array(), $absolute = false)
public function generate($name, $parameters = array(), $absolute = false)
{
return $this->getGenerator()->generate($name, $parameters, $absolute);
}