private function addToComposite(\cmu\html\products\InterfaceComposite $composite) { foreach ($this->buildercomponents as $component) { $object = $component->returnLeaf(); $composite->addComponent($object); //add to Composite } }
function addToComposite(\cmu\html\products\InterfaceComposite $composite) { foreach ($this->buildercomponents as $component) { $object = $component->returnLeaf(); if (is_array($object)) { //array returning multiple objects foreach ($object as $obj) { $this->composite->addComponent($obj); //add to composite and below } } else { //returning single object $this->composite->addComponent($object); //add to composite } $composite->addComponent($this->composite); //add to Composite } }