DDC-1046: Configurable/overridable code generation templates for entities and repositories classes automatic generation #1306

Closed
opened 2026-01-22 13:09:11 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 25, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user mikhus:

Initial proposal discussed in doctrine-user groups: http://groups.google.com/group/doctrine-user/browse_thread/thread/10ed814339429c3e?hl=en

Required features are:

  1. Possibility to override default Doctrine's code generation templates, which are hard-coded for the moment within EntityGenerator & EntityRepositoryGenerator classes
  2. Possibility to extend Repository classes from a custom base class. For the moment it is also hard-coded inside EntityRepositoryGenerator class to be extended from Doctrine\ORM\EntityRepository

Attached pull request with possible implementation is here: https://github.com/doctrine/doctrine2/pull/30

Originally created by @doctrinebot on GitHub (Feb 25, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user mikhus: Initial proposal discussed in doctrine-user groups: http://groups.google.com/group/doctrine-user/browse_thread/thread/10ed814339429c3e?hl=en Required features are: 1. Possibility to override default Doctrine's code generation templates, which are hard-coded for the moment within EntityGenerator & EntityRepositoryGenerator classes 2. Possibility to extend Repository classes from a custom base class. For the moment it is also hard-coded inside EntityRepositoryGenerator class to be extended from Doctrine\ORM\EntityRepository Attached pull request with possible implementation is here: https://github.com/doctrine/doctrine2/pull/30
admin added the New Feature label 2026-01-22 13:09:11 +01:00
admin closed this issue 2026-01-22 13:09:13 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 25, 2011):

Comment created by @beberlei:

There are several things I don't like with this change that need to be addressed before I merge this:

  • Additional options in the configuration, please drop them, you may specify them as optional arguments to the constructors of GenerateEntitiesCommand and GenerateRepositoriesCommand classes.
  • The init() in the constructor, please move it to load lazily in the setters/getters of the AbstractWriter.
  • The change for $fullParentClassName is not backwards compatible, please make that parameter optional and default to "Doctrine\ORM\EntityRepository".
@doctrinebot commented on GitHub (Feb 25, 2011): Comment created by @beberlei: There are several things I don't like with this change that need to be addressed before I merge this: - Additional options in the configuration, please drop them, you may specify them as optional arguments to the constructors of GenerateEntitiesCommand and GenerateRepositoriesCommand classes. - The init() in the constructor, please move it to load lazily in the setters/getters of the AbstractWriter. - The change for $fullParentClassName is not backwards compatible, please make that parameter optional and default to "Doctrine\ORM\EntityRepository".
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2011):

Comment created by mikhus:

Hi, Benjamin!

Done and available for review: https://github.com/doctrine/doctrine2/pull/30/files

  1. Done. Options dropped, added optional arguments --code-writer="My\Writer\ClassImpl" to orm:generate-entities & orm:generate-repositories commands
  2. Done.
  3. Done. Added constant DEFAULT_EXTEND_CLASS to EntityRepositoryGenerator class, which is used within $fullParendClassName and $parentClassName as defualt value

I've also removed assignment of writer instance via constructor and added setCodeWriter method dedicated for this purpose. From other hand implemented getCodeWriter method will construct a default writer if none was previously set, so both EntityRepositoryGenerator and EntityGenerator are also backward compatible from now.

@doctrinebot commented on GitHub (Feb 26, 2011): Comment created by mikhus: Hi, Benjamin! Done and available for review: https://github.com/doctrine/doctrine2/pull/30/files 1. Done. Options dropped, added optional arguments --code-writer="My\Writer\ClassImpl" to orm:generate-entities & orm:generate-repositories commands 2. Done. 3. Done. Added constant DEFAULT_EXTEND_CLASS to EntityRepositoryGenerator class, which is used within $fullParendClassName and $parentClassName as defualt value I've also removed assignment of writer instance via constructor and added setCodeWriter method dedicated for this purpose. From other hand implemented getCodeWriter method will construct a default writer if none was previously set, so both EntityRepositoryGenerator and EntityGenerator are also backward compatible from now.
Author
Owner

@doctrinebot commented on GitHub (Mar 1, 2011):

Comment created by mikhus:

Could I help in any other way? Is there any problem to merge?

Best regards,
Mike

@doctrinebot commented on GitHub (Mar 1, 2011): Comment created by mikhus: Could I help in any other way? Is there any problem to merge? Best regards, Mike
Author
Owner

@doctrinebot commented on GitHub (Mar 1, 2011):

Comment created by @beberlei:

I just have limited time at the moment, i will merge this in the near future.

@doctrinebot commented on GitHub (Mar 1, 2011): Comment created by @beberlei: I just have limited time at the moment, i will merge this in the near future.
Author
Owner

@doctrinebot commented on GitHub (Mar 11, 2012):

Comment created by @asm89:

The entity generation stuff will hopefully be replaced by a new generation project in the future:
https://github.com/beberlei/DoctrineCodeGenerator

Since this is quite an old issue I'll close it.

@doctrinebot commented on GitHub (Mar 11, 2012): Comment created by @asm89: The entity generation stuff will hopefully be replaced by a new generation project in the future: https://github.com/beberlei/DoctrineCodeGenerator Since this is quite an old issue I'll close it.
Author
Owner

@doctrinebot commented on GitHub (Mar 11, 2012):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Mar 11, 2012): Issue was closed with resolution "Won't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1306