src/SetterTrait.php
public function setChild($parent, $child)
    {
        if (is_string($parent)) {
            $name   = $parent;
            $parent = $this->getItem($parent);
            if (is_null($parent)) {
                throw new Exception("Unknown parent:$name at setChild");
            }
        }
        if (is_string($child)) {
            $name  = $child;
            $child = $this->getItem($child);
            if (is_null($child)) {
                throw new Exception("Unknown child:$name at setChild");
            }
        }
        if (isset($this->children[$parent->name][$child->name])) {
            return false;
        }

        return $this->addChild($parent, $child);
    }
public function setChild($parent, $child)
    {
        if (is_string($parent)) {
            $name   = $parent;
            $parent = $this->getItem($parent);
            if (is_null($parent)) {
                throw new Exception("Unknown parent:$name at setChild");
            }
        }
        if (is_string($child)) {
            $name  = $child;
            $child = $this->getItem($child);
            if (is_null($child)) {
                throw new Exception("Unknown child:$name at setChild");
            }
        }
        if (isset($this->children[$parent->name][$child->name])) {
            return false;
        }

        return $this->addChild($parent, $child);
    }
public function setChild ( $ parent , $ child ) { if ( is_string ( $ parent ) ) { $ name = $ parent ; $ parent = $ this -> getItem ( $ parent ) ; if ( is_null ( $ parent ) ) { throw new Exception ( "Unknown parent:$name at setChild" ) ; } } if ( is_string ( $ child ) ) { $ name = $ child ; $ child = $ this -> getItem ( $ child ) ; if ( is_null ( $ child ) ) { throw new Exception ( "Unknown child:$name at setChild" ) ; } } if ( isset ( $ this -> children [ $ parent -> name ] [ $ child -> name ] ) ) { return false ; } return $ this -> addChild ( $ parent , $ child ) ; }
Set child.
@param string|Item $parent
@param string|Item $child
@return bool
Set child .