On 3 February 2014 13:52, Sebastian Krebs <[email protected]> wrote:

>
>
>
> 2014-01-31 Christophe COEVOET <[email protected]>:
>
>  Le 31/01/2014 16:00, Sebastian Krebs a écrit :
>>
>> The repository is about querying, not about persisting or flushing.
>> Exposing them would mix the responsibilities of the class.
>>
>
> Actually thats what my question is (somehow) about: When reading
> "Repository", just from the meaning of the word, I'd assume, that I not
> only can fetch something out of, but also can _push_ things into a
> repository. Maybe you have something to read (a link or so), why the
> responsibility is only about reading, but not writing?
>

Actually, a repository is indeed used for querying... It is a
collection-like data structure as of PoEAA, and I'd say that you have
indeed a point about using it for writes. I just am not sure if that's a
good idea, since it complicates things quite a bit.
I found myself having cleaner code when repositories don't include
persistence operations, but only read ones.


>
>
>>
>> And exposing getEntityManager publicly has the same drawback. If your
>> class needs to use the manager, inject it as a dependency instead of using
>> the repository as a service locator for the manager
>>
>
> Thats what I'm doing right now, but it sometimes feel slightly cumbersome
> to always inject both.
>

It's actually quite ok to inject both IMO. It makes the flow of persistence
quite explicit as well.


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to