Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0053eee

Browse filesBrowse files
[Routing] Fix name-prefixing when using PHP DSL
1 parent b2fafc6 commit 0053eee
Copy full SHA for 0053eee

File tree

4 files changed

+12
-11
lines changed
Filter options

4 files changed

+12
-11
lines changed

‎src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ public function __destruct()
4040
*
4141
* @return $this
4242
*/
43-
final public function prefix($prefix)
43+
final public function prefix($prefix, string $namePrefix = '')
4444
{
45+
if ('' !== $namePrefix) {
46+
$this->route->addNamePrefix($namePrefix);
47+
}
48+
if (!$prefix) {
49+
return $this;
50+
}
4551
if (!\is_array($prefix)) {
4652
$this->route->addPrefix($prefix);
4753
} else {

‎src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,4 @@ final public function controller($controller)
124124

125125
return $this;
126126
}
127-
128-
/**
129-
* Adds a prefix to the name of all the routes within the collection.
130-
*/
131-
final public function addNamePrefix(string $prefix): self
132-
{
133-
$this->route->addNamePrefix($prefix);
134-
135-
return $this;
136-
}
137127
}

‎src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
->prefix('/sub')
1616
->requirements(array('id' => '\d+'));
1717

18+
$routes->import('php_dsl_sub.php')
19+
->prefix('/zub', 'z_');
20+
1821
$routes->add('ouf', '/ouf')
1922
->schemes(array('https'))
2023
->methods(array('GET'))

‎src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function testRoutingConfigurator()
106106
->setHost('host')
107107
->setRequirements(array('id' => '\d+'))
108108
);
109+
$expectedCollection->add('z_c_bar', new Route('/zub/pub/bar'));
110+
$expectedCollection->add('z_c_pub_buz', (new Route('/zub/pub/buz'))->setHost('host'));
109111
$expectedCollection->add('ouf', (new Route('/ouf'))
110112
->setSchemes(array('https'))
111113
->setMethods(array('GET'))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.