Skip to content

[make:entity] Allow specify the table name#1730

Open
omgslinux wants to merge 6 commits intosymfony:1.xfrom
omgslinux:interactive-table-name
Open

[make:entity] Allow specify the table name#1730
omgslinux wants to merge 6 commits intosymfony:1.xfrom
omgslinux:interactive-table-name

Conversation

@omgslinux
Copy link
Copy Markdown

Related to #1626, here's a PR to fit that need. I've checked it's backwards compatible, so if you want to keep the current behaviour, you just have to confirm the default guessing. If you want to have a different table name from the default guessing, just enter when prompted. And I've tested that if you enter a keyword, it's properly quoted.

@GromNaN GromNaN changed the title Allow make:entity specify the table name [make:entity] Allow specify the table name Feb 12, 2026
Copy link
Copy Markdown
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from my preference regarding the signature of the generateEntityClass method, I think it's useful. It adds a question to the make:entity command, but the default answer makes it easy to skip.

Comment on lines +210 to +212
params: [
'tableName' => $tableName,
]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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
params: [
'tableName' => $tableName,
]
$tableName,

}

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, array $params = []): string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, array $params = []): string
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource, bool $withPasswordUpgrade = false, bool $generateRepositoryClass = true, bool $broadcast = false, EntityIdTypeEnum $useUuidIdentifier = EntityIdTypeEnum::INT, string $tableName = ''): string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants