Open beberlei opened 1 month ago
4. Precondition: In ORM, if collection types are configured and Composer\PackageVersions for doctrine/collection is not high enough, throw.
simpler version: bump the min version of the doctrine/collection in the ORM to be the minor version introducing this DelegateCollection.
Users regularly want to introduce their own collections. We don't want to expose the Collection interface due to its complexity there is too much risk. MongoDB ODM has a code generated solution for this, for ORM I propose we do this with delegation.
DelegateCollection
with all methods implemented as final, delegating to $delegatee, and one custom methodgetInternalDelgatee
.new $assoc['collectionType](new PersistentCollection(...))
everywhere a PersistentCollection is created.$col = $col instanceof DelegateeCollection ? $col->getDelegatee() : $col
collectionType
key automatically.Example code:
Reference: