File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,9 @@ public static function asRoutePath(string $value): string
102
102
103
103
public static function asRouteName (string $ value ): string
104
104
{
105
- return self ::asTwigVariable ($ value );
105
+ $ routeName = self ::asTwigVariable ($ value );
106
+
107
+ return str_starts_with ($ routeName , 'app_ ' ) ? $ routeName : 'app_ ' .$ routeName ;
106
108
}
107
109
108
110
public static function asSnakeCase (string $ value ): string
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ private function getMakerInstance(string $makerClass): MakerInterface
106
106
}
107
107
108
108
// a cheap way to guess the service id
109
- $ serviceId = $ serviceId ?? sprintf ('maker.maker.%s ' , Str::asRouteName ((new \ReflectionClass ($ makerClass ))->getShortName ()));
109
+ $ serviceId = $ serviceId ?? sprintf ('maker.maker.%s ' , Str::asSnakeCase ((new \ReflectionClass ($ makerClass ))->getShortName ()));
110
110
111
111
return $ this ->kernel ->getContainer ()->get ($ serviceId );
112
112
}
Original file line number Diff line number Diff line change @@ -200,4 +200,19 @@ public function asHumanWordsTests()
200
200
yield [' FooBar ' , 'Foo Bar ' ];
201
201
yield [' Foo Bar ' , 'Foo Bar ' ];
202
202
}
203
+
204
+ /**
205
+ * @dataProvider provideAsRouteName
206
+ */
207
+ public function testAsRouteName (string $ value , string $ expectedRouteName )
208
+ {
209
+ $ this ->assertSame ($ expectedRouteName , Str::asRouteName ($ value ));
210
+ }
211
+
212
+ public function provideAsRouteName ()
213
+ {
214
+ yield ['Example ' , 'app_example ' ];
215
+ yield ['AppExample ' , 'app_example ' ];
216
+ yield ['Apple ' , 'app_apple ' ];
217
+ }
203
218
}
You can’t perform that action at this time.
0 commit comments