コード例 #1
0
 private function addToComposite(\cmu\html\products\InterfaceComposite $composite)
 {
     foreach ($this->buildercomponents as $component) {
         $object = $component->returnLeaf();
         $composite->addComponent($object);
         //add to Composite
     }
 }
コード例 #2
0
 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
     }
 }