mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 17:33:15 +02:00
Allow custom collections #5671
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 @guilhermeblanco on GitHub (Sep 2, 2017).
@sergiolatostadora commented on GitHub (Jan 7, 2019):
It would be nice to have this feature
@Ocramius commented on GitHub (Aug 24, 2019):
Note that https://github.com/doctrine/collections/pull/177 alleviates the need for this massively. @guilhermeblanco given the complexity of this feature (and the implications of added inheritance support), would you be willing to drop this from
3.x?@wajdijurry commented on GitHub (May 3, 2020):
+1
@oojacoboo commented on GitHub (Nov 24, 2020):
@Ocramius I'm not sure how the need for custom collections is alleviated by generics psalm support. Can you please elaborate on that one.
Custom collections are a good idea for when your ORM is returning a collection and you want to include custom logic into that value holder. This can be very useful in many business logic use cases. For instance, you might have something like the following:
In the example above, we've simply added an
orderBymethod into our customCollectionclass that takes a property argument and orders the results based on that. By using a fluid interface, we can chain additional methods. Further, if we leverage a php port of C#'s LINQ, like https://github.com/Athari/YaLinqo, we're able to perform a lot of really awesome data parsing directly within our collections.@oojacoboo commented on GitHub (Jan 10, 2025):
I can't believe no one else wants custom methods on their Doctrine ORM collections - really baffles me.
@greg0ire commented on GitHub (Jan 10, 2025):
There are 9 upvotes to your previous message, why are you saying no one else wants this?
@ruudk commented on GitHub (Jan 10, 2025):
@oojacoboo Why not contribute the changes?