Skip to content
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

[RFC] Provide db prefix in make:entity #327

Open
acrobat opened this issue Dec 11, 2018 · 0 comments
Open

[RFC] Provide db prefix in make:entity #327

acrobat opened this issue Dec 11, 2018 · 0 comments

Comments

@acrobat
Copy link
Contributor

acrobat commented Dec 11, 2018

Would a PR for a feature to provide a db table name prefix be accepted?

A use case is that a user would like to prefix his tables with a certain prefix. Therefor we could add the @ORM\Table annotation if a prefix is defined. Together with the prefix we could generate the db name based on the namingstrategy setup in the doctrine config.

Some pseudo code for a method in the doctrine helper:

public function getTableName($className)
{
    $em = $this->getRegistry()->getManagerForClass($className);
    if (null === $em) {
        $em = $this->getRegistry()->getManager();
    }
        
    $tableName = $em->getConfiguration()->getNamingStrategy()->classToTableName($className);

    return $tableName;
}

That way we can reliable determin the table name and add the given prefix. If no prefix is defined I would suggest to not add the @Table annotation

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

No branches or pull requests

1 participant