[FLOW3-general] Recursive domain object
Rens Admiraal
renst3 at e-rank.nl
Wed Dec 16 16:31:30 CET 2009
No, I didn't. I copied this structure from another class (the menu
itself). That class holds multiple menuitems without errors...
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
More information about the FLOW3-general
mailing list