src/Node/Node.php
public function addParent(NodeInterface $parent, bool $setParentsChild = true): NodeInterface
    {
        if (!$this->supportsParent($parent)) {
            throw ParentTypeNotSupportedException::create($this, $parent);
        }

        $this->_parents[$parent->getId()] = $parent;

        if ($setParentsChild) {
            $parent->addChild($this, false);
        }

        $this->notifySubscribers(
            self::EVENT_ADD_PARENT,
            ['oldParents' => $this->_parents, 'newParent' => $parent, 'child' => $this]
        );

        return $this;
    }
public function addParent(NodeInterface $parent, bool $setParentsChild = true): NodeInterface
    {
        if (!$this->supportsParent($parent)) {
            throw ParentTypeNotSupportedException::create($this, $parent);
        }

        $this->_parents[$parent->getId()] = $parent;

        if ($setParentsChild) {
            $parent->addChild($this, false);
        }

        $this->notifySubscribers(
            self::EVENT_ADD_PARENT,
            ['oldParents' => $this->_parents, 'newParent' => $parent, 'child' => $this]
        );

        return $this;
    }
public function addParent ( NodeInterface $ parent , bool $ setParentsChild = true ) : NodeInterface { if ( ! $ this -> supportsParent ( $ parent ) ) { throw ParentTypeNotSupportedException :: create ( $ this , $ parent ) ; } $ this -> _parents [ $ parent -> getId ( ) ] = $ parent ; if ( $ setParentsChild ) { $ parent -> addChild ( $ this , false ) ; } $ this -> notifySubscribers ( self :: EVENT_ADD_PARENT , [ 'oldParents' => $ this -> _parents , 'newParent' => $ parent , 'child' => $ this ] ) ; return $ this ; }
Sets the value of field parent.

@param NodeInterface $parent          - Parent.
@param bool          $setParentsChild - Set parent's child.

@throws ParentTypeNotSupportedException

@return NodeInterface
Sets the value of field parent .