[TYPO3-mvc] Object relation - get children

Jan Kornblum jan.kornblum at gmx.de
Sat Feb 2 01:44:56 CET 2013


Hi v4mvcgroup,

doing the first steps in extbase, i try to get the child objects for a 
certain parent object (i used current extension_builder for 6.01). 
"customer" is entity and aggregate root, "project" is entity. "project" 
has a n:1 relation to "customer" ("project"-records own a selectbox 
"customer" in BE).

Now i want to get all Projects for the current Customer using 
$customer->getProjects() inside CustomerControllers's showAction. But 
this leads to an error:

Fatal error: __clone method called on non-object in 
/XX/Classes/Domain/Model/Customer.php

I thought, extbase would determine all child objects itself. But maybe 
i'm wrong with this. What is additionally necessary to get it work or 
what's my mistake?


/*
*@var 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\XX\Customers\Domain\Model\Project>
*/
protected $projects;

/*
*@param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $projects
*/
public function 
setProjects(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $project) {
   $this->projects = $project;
}

/*
* @return 
Tx_Extbase_Persistence_ObjectStorage<\XX\Customers\Domain\Model\Project>
*/
public function getProjects() {
   return clone $this->projects;
}

Thanks for your help, Jan




More information about the TYPO3-project-typo3v4mvc mailing list