mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #5800] Allow using custom collections #9733
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?
Original Pull Request: https://github.com/doctrine/orm/pull/5800
State: closed
Merged: No
Current situation
When querying the DB, Doctrine retrieves the 1-n and n-n associations in its own collection, the PersistentCollection, and the query result set as an array. As this is a specific DoctrineCollection, tied to the implementation, it is currently impossible to specify a Domain Collection to be used instead of the PersistentCollection.
Proposed enhancement
Allow to specify a Collection for each entity type, to be used when retrieving 1-n and n-n relations, as well as the query result set .
The specified collection must be extended from PersistentCollection, in order to maintain the persistence capabilities of the associations. If the specified collection is not extended from PersistentCollection, an ORMInvalidArgumentException will be thrown.
If a collection is not specified, Doctrine will maintain the current behavior of using a PersistentCollection. I understand that this ties the domain collections to the ORM, but I feel that having this functionality is more important than that, also because it is not mandatory to use this functionality, it is completely optional for the developer to do so or not.
The query result set however will still be an array, as it is the current behavior of Doctrine and changing it would break BC. This, however, can be changed by adding an option to override the default behavior and return the query result set as the collection specified for the entities returned in the query result set.
This PR somewhat relates to: