When I read docs about repositories, it is often to work with entities & collection but in a \"read-only\" manner.
There are never examples where repositories have m
If you take a look at the repository pattern http://martinfowler.com/eaaCatalog/repository.html ,
it is stated that repositories uses a "collection-like interface".
Later, it is also written " Objects can be added to and removed from the Repository, as they can from a simple collection of objects".
I'm not saying this is a bible, but there is conceptually nothing wrong to see a repository like a collection that you can query. But as it is a collection, you can add, remove, ... In fact, the ObjectRepository should implement Doctrine\Common\Collection :)
On the other hand, the most important is not to mess reads and writes, as CQS says. That's maybe why they didn't allow directly that, to avoid abuses and read/write mix.
EDIT: I should have talked about flush
. This should not be made in the repository itself, as it might break transactional consistency.
You'd better move the flush
call to something that wraps the whole business transaction logic (a command bus handling a command f.e?)