I stumbled upon an interesting question about Doctrine's findAll() method.
The OP asked how could he call findAll()
with a limit
criteria, which is not natively supported by Doctrine2. The accepted answer wisely suggested him to look at the source code of this method and we learned from this that findAll()
does nothing more than calling findBy()
with particular arguments.
So calling findAll()
with a limit
of 13 can be done by calling directly:
findBy(array(), array('id' => 'DESC'), 13);
But when reading the code, this last instruction is not as straightforward as a call that would look like this:
findAllWithLimit(13);
My question is: where this method would belong if I wanted to make it application-wide?
public function findAllWithLimit($limit)
{
return $em->findBy(array(), array('id' => 'DESC', $limit);
}