[FLOW3-general] Recursive domain object

Rens Admiraal renst3 at e-rank.nl
Wed Dec 16 16:17:37 CET 2009


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



More information about the FLOW3-general mailing list