File tree 4 files changed +12
-11
lines changed
src/Symfony/Component/Routing
4 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,14 @@ public function __destruct()
40
40
*
41
41
* @return $this
42
42
*/
43
- final public function prefix ($ prefix )
43
+ final public function prefix ($ prefix, string $ namePrefix = '' )
44
44
{
45
+ if ('' !== $ namePrefix ) {
46
+ $ this ->route ->addNamePrefix ($ namePrefix );
47
+ }
48
+ if (!$ prefix ) {
49
+ return $ this ;
50
+ }
45
51
if (!\is_array ($ prefix )) {
46
52
$ this ->route ->addPrefix ($ prefix );
47
53
} else {
Original file line number Diff line number Diff line change @@ -124,14 +124,4 @@ final public function controller($controller)
124
124
125
125
return $ this ;
126
126
}
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
- }
137
127
}
Original file line number Diff line number Diff line change 15
15
->prefix ('/sub ' )
16
16
->requirements (array ('id ' => '\d+ ' ));
17
17
18
+ $ routes ->import ('php_dsl_sub.php ' )
19
+ ->prefix ('/zub ' , 'z_ ' );
20
+
18
21
$ routes ->add ('ouf ' , '/ouf ' )
19
22
->schemes (array ('https ' ))
20
23
->methods (array ('GET ' ))
Original file line number Diff line number Diff line change @@ -106,6 +106,8 @@ public function testRoutingConfigurator()
106
106
->setHost ('host ' )
107
107
->setRequirements (array ('id ' => '\d+ ' ))
108
108
);
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 ' ));
109
111
$ expectedCollection ->add ('ouf ' , (new Route ('/ouf ' ))
110
112
->setSchemes (array ('https ' ))
111
113
->setMethods (array ('GET ' ))
You can’t perform that action at this time.
0 commit comments