src/Node/Node.php
public function removeChild(string $childId, bool $setParent = true): NodeInterface
    {
        if ($this->hasChild($childId)) {
            $child = $this->getChild($childId);

            if ($setParent) {
                $child->removeParent($this->getId(), false);
            }

            unset($this->_children[$childId]);

            $this->notifySubscribers(
                self::EVENT_REMOVE_CHILD,
                ['parent' => $this, 'child' => $child]
            );

            /** @var NodeInterface $parent */
            foreach ($this->getAllParents() as $parent) {
                $child->removeSubscriber($parent->getId());
            }
        }

        return $this;
    }
public function removeChild(string $childId, bool $setParent = true): NodeInterface
    {
        if ($this->hasChild($childId)) {
            $child = $this->getChild($childId);

            if ($setParent) {
                $child->removeParent($this->getId(), false);
            }

            unset($this->_children[$childId]);

            $this->notifySubscribers(
                self::EVENT_REMOVE_CHILD,
                ['parent' => $this, 'child' => $child]
            );

            /** @var NodeInterface $parent */
            foreach ($this->getAllParents() as $parent) {
                $child->removeSubscriber($parent->getId());
            }
        }

        return $this;
    }
public function removeChild ( string $ childId , bool $ setParent = true ) : NodeInterface { if ( $ this -> hasChild ( $ childId ) ) { $ child = $ this -> getChild ( $ childId ) ; if ( $ setParent ) { $ child -> removeParent ( $ this -> getId ( ) , false ) ; } unset ( $ this -> _children [ $ childId ] ) ; $ this -> notifySubscribers ( self :: EVENT_REMOVE_CHILD , [ 'parent' => $ this , 'child' => $ child ] ) ; /** @var NodeInterface $parent */ foreach ( $ this -> getAllParents ( ) as $ parent ) { $ child -> removeSubscriber ( $ parent -> getId ( ) ) ; } } return $ this ; }
Removes a child.

@param string $childId   - Child ID.
@param bool   $setParent - Set parent?

@return NodeInterface
Removes a child .