mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-659: Programmatic PHP ClassMetadata Builder #814
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jun 28, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user @beberlei:
Currently using the two existing PHP Metadata Drivers you have a hard time writing the metadata against a plain ClassMetadata instance, because its already so optimiized in the datastruct. It would we cool if we had a class (Doctrine\ORM\Tools\ClassMetadataBuilder) which accepts a ClassMetadata instance in the constructor and has convenience methods to build up this instance.
This way you could use the PHPStatic Driver for example:
@doctrinebot commented on GitHub (Aug 8, 2010):
Comment created by @beberlei:
API Suggestion:
@doctrinebot commented on GitHub (Aug 23, 2010):
Comment created by avalanche123:
I'm on it, in case you were wondering:)
@doctrinebot commented on GitHub (Aug 24, 2010):
Comment created by @beberlei:
Can we discuss on the API?
@Roman what is your opinion on using set/add or omitting it in this case? I want the interface to be as fluent as possible :-)
@doctrinebot commented on GitHub (Aug 26, 2010):
Comment created by romanb:
I think omitting add/set prefixes is fine if it improves the readability of the fluent interface.
@doctrinebot commented on GitHub (Aug 30, 2010):
Comment created by avalanche123:
So I'm kinda stuck with associations.
API like addOneToOne($fieldName, $targetEntity) makes little sense, since relation mapping requires much more information than that.
So one way to account for it would be to change the function signature to read addOneToOne($fieldName, $targetEntity, $associationMapping), where the mapping array would contain the rest of the required information like joinColumns, mappedBy, cascade, fetch, etc.
Then the $associationMapping array could be generated using the AssociationBuilder and subclasses.
This makes builder somewhat bloated...
Thoughts?
@doctrinebot commented on GitHub (Aug 31, 2010):
Comment created by @beberlei:
The idea is that methods on ClassMetadataBuilder return the FieldBuilder and AssociationBuilder when necessary.
That way the interface isnt fully fluent, but it is fluent for the definition of one field, which is a pretty good separation layer anyways:
Passing options is rather bad in my opinion, because it would be cumbersome to map that into a correct method call.
However I just realize that is complicated to call the final method on ClassMetadataInfo.
Can we collaborate in IRC on that tonight?
@doctrinebot commented on GitHub (Oct 22, 2010):
Comment created by shurakai:
Hm, what about a "setIdGenerator" method?
@doctrinebot commented on GitHub (Sep 4, 2011):
Comment created by @beberlei:
Implemented
@doctrinebot commented on GitHub (Sep 4, 2011):
Issue was closed with resolution "Fixed"