[Templating] introduce path and url methods in php templates to be in line with twig templates

This commit is contained in:
Tobias Schultze 2015-10-18 20:03:06 +02:00
parent 912fc4de8f
commit 97d6828b51

View File

@ -49,6 +49,38 @@ class RouterHelper extends Helper
return $this->generator->generate($name, $parameters, $referenceType);
}
/**
* Generates a URL reference (as an absolute or relative path) to the route with the given parameters.
*
* @param string $name The name of the route
* @param mixed $parameters An array of parameters
* @param bool $relative Whether to generate a relative or absolute path
*
* @return string The generated URL reference
*
* @see UrlGeneratorInterface
*/
public function path($name, $parameters = array(), $relative = false)
{
return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
}
/**
* Generates a URL reference (as an absolute URL or network path) to the route with the given parameters.
*
* @param string $name The name of the route
* @param mixed $parameters An array of parameters
* @param bool $schemeRelative Whether to omit the scheme in the generated URL reference
*
* @return string The generated URL reference
*
* @see UrlGeneratorInterface
*/
public function url($name, $parameters = array(), $schemeRelative = false)
{
return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
}
/**
* {@inheritdoc}
*/