[Routing] Fix name-prefixing when using PHP DSL
This commit is contained in:
parent
b2fafc6a0f
commit
0053eeefcf
@ -40,8 +40,14 @@ class ImportConfigurator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
final public function prefix($prefix)
|
||||
final public function prefix($prefix, string $namePrefix = '')
|
||||
{
|
||||
if ('' !== $namePrefix) {
|
||||
$this->route->addNamePrefix($namePrefix);
|
||||
}
|
||||
if (!$prefix) {
|
||||
return $this;
|
||||
}
|
||||
if (!\is_array($prefix)) {
|
||||
$this->route->addPrefix($prefix);
|
||||
} else {
|
||||
|
@ -124,14 +124,4 @@ trait RouteTrait
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a prefix to the name of all the routes within the collection.
|
||||
*/
|
||||
final public function addNamePrefix(string $prefix): self
|
||||
{
|
||||
$this->route->addNamePrefix($prefix);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ return function (RoutingConfigurator $routes) {
|
||||
->prefix('/sub')
|
||||
->requirements(array('id' => '\d+'));
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->prefix('/zub', 'z_');
|
||||
|
||||
$routes->add('ouf', '/ouf')
|
||||
->schemes(array('https'))
|
||||
->methods(array('GET'))
|
||||
|
@ -106,6 +106,8 @@ class PhpFileLoaderTest extends TestCase
|
||||
->setHost('host')
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
);
|
||||
$expectedCollection->add('z_c_bar', new Route('/zub/pub/bar'));
|
||||
$expectedCollection->add('z_c_pub_buz', (new Route('/zub/pub/buz'))->setHost('host'));
|
||||
$expectedCollection->add('ouf', (new Route('/ouf'))
|
||||
->setSchemes(array('https'))
|
||||
->setMethods(array('GET'))
|
||||
|
Reference in New Issue
Block a user