[TYPO3-50-general] FLOW3 Sample Blog Application Aggregate Roots Clarification
Nino Martincevic
don at zampano.com
Tue Aug 18 12:01:53 CEST 2009
Robert Lemke wrote:
> Correct, so the drawback of introducing a Post Repository is that posts
> won't be deleted automatically if you delete a Blog and it is your
> responsibility to keep the whole structure consistent.
Well, it depends on how you treat Posts.
If Posts may exist without out an associated or containing Blog (or do
exist for more than one Blog!) then you delete the Blog only.
But if a Blog takes all its Posts to Nirvana, well then they get deleted
too.
> public function remove(Blog $blog) {
> foreach ($blog->getPosts() as $post) {
> $this->postRepository->remove($post);
> }
> parent::remove($blog);
> }
>
Depending on the needs mentioned above you perhaps simply cannot do
that. An AR is the conceptual boundary in terms of data consistency.
It depends how your domain and ARs are styled, so no general guidance
possible here.
If you remove Posts when removing a Blog then with i.e. UnitOfWork you
don't have to call another Repository here.
But generally you should avoid calling one Repo from another, that's
often a sign for unclear boundaries contexts and could lead to
consistency leaks.
Hope that helps.
Nino
More information about the TYPO3-project-5_0-general
mailing list