Jackalope\Item::remove PHP Method

remove() public method

{@inheritDoc}
public remove ( )
    public function remove()
    {
        $this->checkState();
        // To avoid the possibility to delete an already deleted node
        // sanity checks
        if ($this->getDepth() === 0) {
            throw new RepositoryException('Cannot remove root node');
        }
        if ($this instanceof PropertyInterface) {
            $this->objectManager->removeItem($this->parentPath, $this);
        } else {
            $this->objectManager->removeItem($this->path);
        }
        // TODO same-name siblings reindexing
        $this->setDeleted();
    }

Usage Example

Example #1
0
 /**
  * Remove this node
  *
  * {@inheritDoc}
  *
  * A jackalope node needs to notify the parent node about this if it is
  * cached, in addition to \PHPCR\ItemInterface::remove()
  *
  * @uses Node::unsetChildNode()
  *
  * @api
  */
 public function remove()
 {
     $this->checkState();
     $parent = $this->getParent();
     $parentNodeType = $parent->getPrimaryNodeType();
     //will throw a ConstraintViolationException if this node can't be removed
     $parentNodeType->canRemoveNode($this->getName(), true);
     if ($parent) {
         $parent->unsetChildNode($this->name, true);
     }
     // once we removed ourselves, $this->getParent() won't work anymore. do this last
     parent::remove();
 }
All Usage Examples Of Jackalope\Item::remove