Skip to content

Commit 64ef494

Browse files
committed
Add the option, the question and pass the value to the generator
1 parent c86da84 commit 64ef494

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Maker/MakeEntity.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
9797
->addOption('broadcast', 'b', InputOption::VALUE_NONE, 'Add the ability to broadcast entity updates using Symfony UX Turbo?')
9898
->addOption('regenerate', null, InputOption::VALUE_NONE, 'Instead of adding new fields, simply generate the methods (e.g. getter/setter) for existing fields')
9999
->addOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite any existing getter/setter methods')
100+
->addOption('table', null, InputOption::VALUE_OPTIONAL, 'Allow specify the table name')
100101
->setHelp($this->getHelpFileContents('MakeEntity.txt'))
101102
;
102103

@@ -186,14 +187,31 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
186187
'Entity\\'
187188
);
188189

190+
if (!$input->getOption('table')) {
191+
$potentialTableName = $this->doctrineHelper->getPotentialTableName($input->getArgument('name'));
192+
193+
$tableName = $io->ask(
194+
sprintf('Enter the database table name (e.g. `%s`)', $potentialTableName),
195+
$potentialTableName
196+
);
197+
$input->setOption('table', $tableName);
198+
}
199+
200+
189201
$classExists = class_exists($entityClassDetails->getFullName());
190202
if (!$classExists) {
203+
$tableName = $input->getOption('table');
204+
191205
$broadcast = $input->getOption('broadcast');
192206
$entityPath = $this->entityClassGenerator->generateEntityClass(
193207
entityClassDetails: $entityClassDetails,
194208
apiResource: $input->getOption('api-resource'),
195209
broadcast: $broadcast,
196210
useUuidIdentifier: $this->getIdType(),
211+
params:
212+
[
213+
'tableName' => $tableName,
214+
]
197215
);
198216

199217
if ($broadcast) {

0 commit comments

Comments
 (0)