Ejemplo n.º 1
0
 public function attachToCompound(Compound $root, $prepend = false)
 {
     $this->root = $root;
     if (!$root->getComponents()->contains($this)) {
         $root->getComponents()->add($this);
     }
     /** @var PartInterface $this */
     $parentId = $this->getDestinationParentId();
     if ($parentId === Compound::ROOT_ID) {
         if ($this->parent() !== $root) {
             $root->children()->add($this, $prepend);
             return;
         }
     } else {
         $parts = $root->getComponents();
         /** @var ContainerPartInterface $parent */
         $parent = $parts->findByProperty('id', $parentId, true);
         if (!$parent) {
             $id = $this->getId();
             throw new RuntimeException("Trying to attach compound part '{$id}' to not existing '{$parentId}'.");
         }
         if (!$parent instanceof ContainerPartInterface) {
             $id = $this->getId();
             throw new RuntimeException("Trying to attach compound part '{$id}' to invalid container '{$parentId}'.");
         }
         if ($this->parent() !== $parent->getContainer()) {
             $parent->getContainer()->children()->add($this, $prepend);
             return;
         }
     }
     return;
 }
Ejemplo n.º 2
0
 public function attachToCompound(Compound $root, $prepend = false)
 {
     // prepend component that will render results
     $root->children()->add(new DataView(function () {
         if ($this->inputOption->hasValue()) {
             $this->renderCsv();
         }
     }), true);
     parent::attachToCompound($root, $prepend);
 }