[TYPO3-mvc] Object relation - get children

Henjo Hoeksma | Stylence me at henjohoeksma.nl
Sat Feb 2 10:26:18 CET 2013


Hi Jan,

You put the relation on your project object.
This means you should delete the customer relation from your project model
and add a relation field projects to your customer model.

Now you can do $project->getCustomers(); after the change you can do what
you really want: get projects based on your aggregate root.

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.


On Sat, Feb 2, 2013 at 1:44 AM, Jan Kornblum <jan.kornblum at gmx.de> wrote:

> 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
>
>
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list