소스 검색

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

Fabien Potencier 14 년 전
부모
커밋
04ac1fdba2

+ 2 - 2
src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

@@ -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);
     }

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

@@ -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);
     }

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php

@@ -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);
     }

+ 1 - 1
src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php

@@ -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));

+ 4 - 4
src/Symfony/Component/Routing/Generator/UrlGenerator.php

@@ -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));

+ 2 - 2
src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php

@@ -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);
 }

+ 2 - 2
src/Symfony/Component/Routing/Router.php

@@ -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);
     }