Example #1
0
 /**
  * {@inheritdoc}
  */
 public function setParent(NodeInterface $parent = null)
 {
     if ($parent === $this) {
         throw new \InvalidArgumentException('A node cannot have itself as a parent');
     }
     if ($parent === $this->parent) {
         return $this;
     }
     if ($this->parent !== null) {
         $this->parent->remove($this);
     }
     $this->parent = $parent;
     if ($this->parent !== null && !$this->parent->contains($this, false)) {
         $this->parent->add($this);
     }
     return $this;
 }