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
102102
103103 public static function asRouteName (string $ value ): string
104104 {
105- return self ::asTwigVariable ($ value );
105+ $ routeName = self ::asTwigVariable ($ value );
106+
107+ return str_starts_with ($ routeName , 'app_ ' ) ? $ routeName : 'app_ ' .$ routeName ;
106108 }
107109
108110 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
106106 }
107107
108108 // 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 ()));
110110
111111 return $ this ->kernel ->getContainer ()->get ($ serviceId );
112112 }
Original file line number Diff line number Diff line change @@ -200,4 +200,19 @@ public function asHumanWordsTests()
200200 yield [' FooBar ' , 'Foo Bar ' ];
201201 yield [' Foo Bar ' , 'Foo Bar ' ];
202202 }
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+ }
203218}
You can’t perform that action at this time.
0 commit comments