[TYPO3-mvc] Using ObjectStorage properly
S.Korth
s.korth at dms-arts.com
Thu May 6 13:11:41 CEST 2010
Søren Malling schrieb:
> Hi,
>
> First, thanks to Felix for his great help on my last issue! I found
> I've made wrong declaration on alot of my properties :)
>
> Onto next (hopefully eyeopening) issue :-)
>
> I'm building a XML output with members of a club and club information.
>
> I've come to the part where I need to get the members of the currenct
> club object. All members are fe_users with a "club" field (related to
> another model I've made)
>
> I took a look on the blog_example extension and how they get posts for a blog.
>
> In there Blog Model they got
>
> /**
> * The posts of this blog
> *
> * @var Tx_Extbase_Persistence_ObjectStorage<Tx_BlogExample_Domain_Model_Post>
> * @lazy
> * @cascade remove
> */
> protected $posts
>
> and then they simple give it a objectstorage in the __construct function
>
> $this->posts = new Tx_Extbase_Persistence_ObjectStorage();
>
> In the blog controller all blogs are assigned to the Fluid template with
>
> $this->blogRepository =
> t3lib_div::makeInstance('Tx_BlogExample_Domain_Repository_BlogRepository');
> and
> $this->view->assign('blogs', $this->blogRepository->findAll());
>
> and doing a foreach loop in fluid
> <f:for each="{blogs}" as="blog">
> <dt>
> <f:link.action action="index" controller="Post" arguments="{blog : blog}">
> {blog.title} (<f:count subject="{blog.posts}" />)
> </f:link.action>
> ...
> </f:for>
>
> I created a property in my club model
>
> /**
> * Members of club
> * @var
> Tx_Extbase_Persistence_ObjectStorage<Tx_Ysmenmembers_Domain_Model_Member>
> */
> protected $members;
>
> public function __construct() {
> $this->members = new Tx_Extbase_Persistence_ObjectStorage();
> }
>
> /**
> * Get members of club
> * @return
> Tx_Extbase_Persistence_ObjectStorage<Tx_Ysmenmembers_Domain_Model_Member>
> */
> public function getMembers() {
> return $this->members;
> }
>
> As I've seen in the blog_example.
>
> This is where I'm stucked. How does this objectstorage know what data
> to return? And should this be handled in a different way, using a
> memberRepository instead?
>
> Regards,
>
> Søren
>
Hey Søren,
i am also new to extbase, but i think a memberRepository is the way to
go. Controller -> get data from memberRepository -> xml output
Sascha
More information about the TYPO3-project-typo3v4mvc
mailing list