[FLOW3-general] Recursive domain object
Robert Lemke
robert at typo3.org
Wed Jan 6 12:21:39 CET 2010
Hi Rens,
what does a var_dump($this->items); output if you place it right before the $this->items->attach() ?
Cheers,
robert
Am 16.12.2009 um 16:31 schrieb Rens Admiraal:
> I now tried to create the object in the constructor, but it did not solve the problem.
>
>
> With kind regards,
> Rens Admiraal
> TYPO3 Certified Integrator
>
> Op 16 dec 2009, om 16:23 heeft Tommy Seus het volgende geschreven:
>
>> Have you created the object in the constructor?
>>
>> __construct() {
>> $this->items = new \SplObjectStorage;
>> }
>>
>>
>> Am 16.12.2009 16:17, schrieb Rens Admiraal:
>>> I have a menuitem object in my domain model, and I want it to be
>>> recursive so menuitems can hold subitems.
>>> I've tried this to add the following variable / method:
>>>
>>> /**
>>> * @var \SplObjectStorage<\F3\Package\Domain\Model\MenuItem>
>>> * @lazy
>>> */
>>> protected $items;
>>>
>>> /**
>>> * @param \F3\Package\Domain\Model\MenuItem $item
>>> * @return void
>>> */
>>> public function addMenuItem(\F3\Package\Domain\Model\MenuItem $item) {
>>> $item->setParent($this); // setter for parent property of
>>> type \F3\Package\Domain\Model\MenuItem
>>> $this->items->attach($item);
>>> }
>>>
>>>
>>> But when I call the method addMenuItem on an object I get 'Call to a
>>> member function attach() on a non-object in.... on line ...', in which
>>> the linenumber points to the addMenuItem method...
>>>
>>> What's the right way to create a recursive object?
>>>
>>>
>>> With kind regards,
>>> Rens Admiraal
>>> TYPO3 Certified Integrator
>>>
>>> _______________________________________________
>>> FLOW3-general mailing list
>>> FLOW3-general at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>
>> _______________________________________________
>> FLOW3-general mailing list
>> FLOW3-general at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
--
Robert Lemke
Fluent Code Artisan
http://typo3.org
http://flow3.typo3.org
More information about the FLOW3-general
mailing list