[TYPO3-mvc] Blog Example and Value Object question
Franz Koch
typo3.RemoveForMessage at elements-net.de
Wed Dec 30 11:30:57 CET 2009
Hi,
> How do I access the post repository from the blog repository? Somehow I don't understand why not the
> blog repository can get the findByTag() method.
I think the method shouldn't be inside the blogRepository but the blog
model as aggregate root if I understood Jochen correctly. If you like to
move it to a repository, then the postRepository might be the correct
one and you would need 4 methods in total for a complete featureset:
findByTag
findAllByTag
findByBlogAndTag
findAllByBlogAndTag
Those methods might also accept arrays as tag parameter, if multiple
tags/categories get selected/filtered. But for me those
findByFooAndBarAndFoobar methods look odd, especially if you have
various enableFields (maybe by having a additional country or language
filter, author filter and need to combine them). It's just like
reinventing the wheel for every additional sql criteria you need.
findAllByBlogAndAuthorAndTagAndTimerange($blog,$author,$tag,array('min'=>$date,'max'=>$date))
That's ridiculous and way to much overhead in my eyes as I thought the
extBase/Flow3 approach would simplify things. A "cleaner" way would be
to let the blogObject/aggregateRoot itterate over the blogPosts and
apply various filter options at a time - but that's somewhat slow and
not applicable on larger projects.
So maybe a more generic method like "findAllByBlogAndMultipleProperties"
might be the way to go, although writing tests for this might be a bit
more difficult than for "simpler" methods.
$postRepository->findAllByBlogAndMultipleProperties(
$blog,
array (
'author' => $author,
'tag' => $date,
'timerange' => array(
'min' => $dateMin,
'max' => $dateMax
)
));
What do you think? If you think this would be a good idea, we should
think of a proper method name and provide a generic
"findByMultipleProperties" in the abstractRepository of extbase as a)
usefull addition and b) as a reference for other methods of this type.
--
kind regards,
Franz Koch
---------------------------------------------------
PayPal-Account: 'paypal _at_ elements-net _dot_ de'
---------------------------------------------------
More information about the TYPO3-project-typo3v4mvc
mailing list