-
-
Notifications
You must be signed in to change notification settings - Fork 429
[make:entity] Allow specify the table name #1730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Changes from all commits
64ef494
f3b6f45
93f0728
821be30
eabfa3c
97d1562
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,6 +97,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf | |||||||||
| ->addOption('broadcast', 'b', InputOption::VALUE_NONE, 'Add the ability to broadcast entity updates using Symfony UX Turbo?') | ||||||||||
| ->addOption('regenerate', null, InputOption::VALUE_NONE, 'Instead of adding new fields, simply generate the methods (e.g. getter/setter) for existing fields') | ||||||||||
| ->addOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite any existing getter/setter methods') | ||||||||||
| ->addOption('table', null, InputOption::VALUE_OPTIONAL, 'Allow specify the table name') | ||||||||||
| ->setHelp($this->getHelpFileContents('MakeEntity.txt')) | ||||||||||
| ; | ||||||||||
|
|
||||||||||
|
|
@@ -186,14 +187,29 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen | |||||||||
| 'Entity\\' | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| if (!$input->getOption('table')) { | ||||||||||
| $potentialTableName = $this->doctrineHelper->getPotentialTableName($input->getArgument('name')); | ||||||||||
|
|
||||||||||
| $tableName = $io->ask( | ||||||||||
| \sprintf('Enter the database table name (e.g. `%s`)', $potentialTableName), | ||||||||||
| $potentialTableName | ||||||||||
| ); | ||||||||||
| $input->setOption('table', $tableName); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| $classExists = class_exists($entityClassDetails->getFullName()); | ||||||||||
| if (!$classExists) { | ||||||||||
| $tableName = $input->getOption('table'); | ||||||||||
|
|
||||||||||
| $broadcast = $input->getOption('broadcast'); | ||||||||||
| $entityPath = $this->entityClassGenerator->generateEntityClass( | ||||||||||
| entityClassDetails: $entityClassDetails, | ||||||||||
| apiResource: $input->getOption('api-resource'), | ||||||||||
| broadcast: $broadcast, | ||||||||||
| useUuidIdentifier: $this->getIdType(), | ||||||||||
| params: [ | ||||||||||
| 'tableName' => $tableName, | ||||||||||
| ] | ||||||||||
|
Comment on lines
+210
to
+212
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the intention, which is to stop adding parameters to the function and use an array instead. But in that case, we'd have to revise the entire method signature; this is just a stopgap solution. Since the class is internal, I'm convinced that the best thing to do is to add a new parameter to the method. That way, it's clearly documented. Otherwise, we'd have to use an array-shape in the phpdoc, which is less strict.
Suggested change
|
||||||||||
| ); | ||||||||||
|
|
||||||||||
| if ($broadcast) { | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.