[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


 Description   

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


 Comments   
Comment by Lars Strojny [ 26/Nov/12 ]

Related:

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 Mar 04 12:55:17 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.