1414use Doctrine \Bundle \DoctrineBundle \DoctrineBundle ;
1515use Doctrine \Common \Persistence \ManagerRegistry ;
1616use Doctrine \DBAL \Types \Type ;
17+ use Doctrine \ORM \Mapping \Column ;
1718use Psr \Container \ContainerInterface ;
1819use Symfony \Bundle \MakerBundle \ConsoleStyle ;
1920use Symfony \Bundle \MakerBundle \DependencyBuilder ;
@@ -262,10 +263,17 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
262263
263264 public function configureDependencies (DependencyBuilder $ dependencies )
264265 {
266+ // guarantee DoctrineBundle
265267 $ dependencies ->addClassDependency (
266268 DoctrineBundle::class,
267269 'orm '
268270 );
271+
272+ // guarantee ORM
273+ $ dependencies ->addClassDependency (
274+ Column::class,
275+ 'orm '
276+ );
269277 }
270278
271279 private function askForNextField (ConsoleStyle $ io , array $ fields , string $ entityClass )
@@ -290,15 +298,15 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
290298
291299 $ defaultType = 'string ' ;
292300 // try to guess the type by the field name prefix/suffix
293- // convert to camel case for simplicity
294- $ camelCasedField = Str::snakeCase ($ fieldName );
295- if ('_at ' == substr ($ camelCasedField , -3 )) {
301+ // convert to snake case for simplicity
302+ $ snakeCasedField = Str::asSnakeCase ($ fieldName );
303+ if ('_at ' == substr ($ snakeCasedField , -3 )) {
296304 $ defaultType = 'datetime ' ;
297- } elseif ('_id ' == substr ($ camelCasedField , -3 )) {
305+ } elseif ('_id ' == substr ($ snakeCasedField , -3 )) {
298306 $ defaultType = 'integer ' ;
299- } elseif ('is_ ' == substr ($ camelCasedField , 0 , 3 )) {
307+ } elseif ('is_ ' == substr ($ snakeCasedField , 0 , 3 )) {
300308 $ defaultType = 'boolean ' ;
301- } elseif ('has_ ' == substr ($ camelCasedField , 0 , 4 )) {
309+ } elseif ('has_ ' == substr ($ snakeCasedField , 0 , 4 )) {
302310 $ defaultType = 'boolean ' ;
303311 }
304312
@@ -514,20 +522,21 @@ function ($name) use ($targetClass) {
514522
515523 $ askOrphanRemoval = function (string $ owningClass , string $ inverseClass ) use ($ io ) {
516524 $ io ->text ([
525+ 'Do you want to activate <comment>orphanRemoval</comment> on your relationship? ' ,
517526 sprintf (
518- 'A <comment>%s</comment> becomes "orphaned" if it is removed from its related <comment>%s</comment>. ' ,
527+ 'A <comment>%s</comment> is "orphaned" when it is removed from its related <comment>%s</comment>. ' ,
519528 Str::getShortClassName ($ owningClass ),
520529 Str::getShortClassName ($ inverseClass )
521530 ),
522531 sprintf (
523- 'For example: <comment>$%s->remove%s($%s)</comment> ' ,
532+ 'e.g. <comment>$%s->remove%s($%s)</comment> ' ,
524533 Str::asLowerCamelCase (Str::getShortClassName ($ inverseClass )),
525534 Str::asCamelCase (Str::getShortClassName ($ owningClass )),
526535 Str::asLowerCamelCase (Str::getShortClassName ($ owningClass ))
527536 ),
528537 '' ,
529538 sprintf (
530- 'NOTE: If a <comment>%s</comment> should be allowed to *change* from one <comment>%s</comment> to another, answer "no". ' ,
539+ 'NOTE: If a <comment>%s</comment> may *change* from one <comment>%s</comment> to another, answer "no". ' ,
531540 Str::getShortClassName ($ owningClass ),
532541 Str::getShortClassName ($ inverseClass )
533542 ),
0 commit comments