File tree Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Expand file tree Collapse file tree 4 files changed +12
-11
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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 ' ))
Original file line number Diff line number Diff 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 ' ))
You can’t perform that action at this time.
0 commit comments