Sorry, that I push this topic once more, but I had a short discussion with
a colleague and I really lack of arguments ... For example see
http://martinfowler.com/eaaCatalog/repository.html
This covers my understanding, that a repository isn't just something I can
fetch things out of, but also can throw things in.
Regarding the over-engineering/complexity: Actually the repository
class/interface only needs to expose the persist() and flush() (?) methods,
or do I miss something?
Beside it would give the possibility to decouple components from an
additional dependency (the ObjectManager)
Now:
<Foo> -----find()-->[Repository] ----> [OM]
\---persists()--------------------/
As seen in the link above
<Foo> ----find() / persist() ---> [Repository] ----> [OM]
2014-02-03 13:59 GMT+01:00 Marco Pivetta <[email protected]>:
>
>
> 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.
>
--
github.com/KingCrunch
--
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/d/optout.