-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
Allow make:entity
specify the table name
#1635
base: main
Are you sure you want to change the base?
Conversation
make:entity
specify the table name
Struggling with tools in local but i'm going to have a look and those errors |
@@ -40,15 +40,17 @@ public function __construct( | |||
) { | |||
} | |||
|
|||
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT): string | |||
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, ?string $tableName): string |
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.
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, ?string $tableName): string | |
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, ?string $tableName = null): string |
src/Maker/MakeEntity.php
Outdated
@@ -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-name', null, InputOption::VALUE_NONE, 'Overwrite default table name') |
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.
->addOption('table-name', null, InputOption::VALUE_NONE, 'Overwrite default table name') | |
->addOption('table-name', 't', InputOption::VALUE_NONE, 'Overwrite default table name') |
{ | ||
$repoClassDetails = $this->generator->createClassNameDetails( | ||
$entityClassDetails->getRelativeName(), | ||
'Repository\\', | ||
'Repository' | ||
); | ||
|
||
$tableName = $this->doctrineHelper->getPotentialTableName($entityClassDetails->getFullName()); | ||
if (null === $tableName) { |
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.
Wouldn't you consider handling the most common case of pluralizing the class name somehow? Maybe via another option or something else? You can use this Symfony inflector capability.
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.
This is a good point. But I think it's outside the scope of this PR, my purpose is to be able to explicitly choose the table name, not to change the default behavior. Both can also coexist, I think.
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.
I keep the idea to open a new PR in the next few days, or maybe you want to do it
@@ -40,15 +40,17 @@ public function __construct( | |||
) { | |||
} | |||
|
|||
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT): string | |||
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, string $tableName = null): string |
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.
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, string $tableName = null): string | |
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, ?string $tableName = null): string |
Missed the ?
here :)
src/Maker/MakeEntity.php
Outdated
@@ -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-name', 't', InputOption::VALUE_NONE, 'Overwrite default table name') |
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.
Overwrite seems more something to change existing things no ?
I'd say this will be also (mainly?) used during first Entitiy creation ?
Maybe something more like "Set custom table name" ?
Feel free to ignore if you disagree, just a comment passing by ;)
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.
To be honest I hadn't thought that far ahead. But I agree with you for this change, sounds better
Give a try on #1626