Skip to content

Commit 97d6828

Browse files
committed
[Templating] introduce path and url methods in php templates to be in line with twig templates
1 parent 912fc4d commit 97d6828

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,38 @@ public function generate($name, $parameters = array(), $referenceType = UrlGener
4949
return $this->generator->generate($name, $parameters, $referenceType);
5050
}
5151

52+
/**
53+
* Generates a URL reference (as an absolute or relative path) to the route with the given parameters.
54+
*
55+
* @param string $name The name of the route
56+
* @param mixed $parameters An array of parameters
57+
* @param bool $relative Whether to generate a relative or absolute path
58+
*
59+
* @return string The generated URL reference
60+
*
61+
* @see UrlGeneratorInterface
62+
*/
63+
public function path($name, $parameters = array(), $relative = false)
64+
{
65+
return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
66+
}
67+
68+
/**
69+
* Generates a URL reference (as an absolute URL or network path) to the route with the given parameters.
70+
*
71+
* @param string $name The name of the route
72+
* @param mixed $parameters An array of parameters
73+
* @param bool $schemeRelative Whether to omit the scheme in the generated URL reference
74+
*
75+
* @return string The generated URL reference
76+
*
77+
* @see UrlGeneratorInterface
78+
*/
79+
public function url($name, $parameters = array(), $schemeRelative = false)
80+
{
81+
return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
82+
}
83+
5284
/**
5385
* {@inheritdoc}
5486
*/

0 commit comments

Comments
 (0)