I know this question is old, but I will write the best answer that comes to my mind.
1) Abandon your dependency on the interface (for example, use the dependency injection pattern to inject the EntityManager into your class that creates queries and uses EntityManagerInterface instead)
Now either:
a) [, ] , EntityManagerInterface, entityManager true:
<?php
class CachedEntityManager implements EntityManagerInterface {
private $proxiedManager;
public function __construct(EntityManagerInterface $proxiedManager) {
$this->proxiedManager = $proxiedManager;
}
public function createQuery($dql = '') {
$query = $this->proxiedManager->createQuery($dql);
$query->useResultCache(true);
}
[... proxy all the calls forth to proxiedManager ...]
}
b) [ , ] EntityManager createQuery. , , , a):
<?php
class CachedEntityManager extends EntityManager {
public function createQuery($dql = '') {
$query = parent::createQuery($dql);
$query->useResultCache(true);
}
}