[DDC-2170] Decorator base classes for query related objects Created: 26/Nov/12  Updated: 22/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Major
Reporter: Lars Strojny Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


Doctrine\ORM\Query should not be directly extendable but it would be nice to decorate query objects and add additional methods. Use cases are e.g. doctrine-fun (see https://github.com/lstrojny/doctrine-fun/blob/master/src/Doctrine/Fun/Query.php) or even cases where users want to add domain specific methods. As Doctrine\ORM\Query is final it is not so easy to decorate correctly. I would propose:

  • Add a new interfaces: Doctrine\ORM\QueryInterface that provides a contract for all methods Doctrine\ORM\Query provides
  • Add a decorator base class Doctrine\ORM\QueryDecorator as an extension point
  • Some for NativeQuery and QueryBuilder

Comment by Lars Strojny [ 26/Nov/12 ]


Comment by Aurimas Niekis [ 21/Jan/15 ]

Any changes on this?

Comment by Marco Pivetta [ 22/Jan/15 ]

The EntityManagerInterface now allows producing custom query objects: just requires a custom createQuery or createQueryBuilder API.

Comment by Aurimas Niekis [ 22/Jan/15 ]

Yes, but you can't extend `Doctrine\ORM\Query` object, and many places expects `Doctrine\ORM\Query` not your custom query object

Comment by Marco Pivetta [ 22/Jan/15 ]

Oh, I see what you mean.

Yes, those still require patching, so I suggest getting your hands dirty and trying with a pull request

Generated at Wed Nov 25 18:55:13 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.