Jackalope\ObjectManager::purgeDisappearedNode PHP Method

purgeDisappearedNode() public method

This is used by Node::refresh() to let the object manager notify deleted nodes or detect cases when not to delete.
public purgeDisappearedNode ( string $absPath, boolean $keepChanges ) : boolean
$absPath string The absolute path of the item
$keepChanges boolean Whether to keep local changes or forget them
return boolean true if the node is to be forgotten by its parent (deleted or moved away), false if child should be kept
    public function purgeDisappearedNode($absPath, $keepChanges)
    {
        if (array_key_exists($absPath, $this->objectsByPath['Node'])) {
            $item = $this->objectsByPath['Node'][$absPath];
            if ($keepChanges && ($item->isNew() || $this->getMoveSrcPath($absPath))) {
                // we keep changes and this is a new node or it moved here
                return false;
            }
            // may not use $item->getIdentifier here - leads to endless loop if node purges itself
            $uuid = array_search($absPath, $this->objectsByUuid);
            if (false !== $uuid) {
                unset($this->objectsByUuid[$uuid]);
            }
            unset($this->objectsByPath['Node'][$absPath]);
            $item->setDeleted();
        }
        // if the node moved away from this node, we did not find it in
        // objectsByPath and the calling parent node can forget it
        return true;
    }