Adldap\Models\Model::delete PHP Method

delete() public method

Deletes the current entry.
public delete ( ) : boolean
return boolean
    public function delete()
    {
        $dn = $this->getDn();
        if ($this->exists === false) {
            // Make sure the record exists before we can delete it.
            // Otherwise, we'll throw an exception.
            throw (new ModelDoesNotExistException())->setModel(get_class($this));
        }
        if (empty($dn)) {
            // If the record exists but the DN attribute does
            // not exist, we can't process a delete.
            throw new AdldapException('Unable to delete. The current model does not have a distinguished name.');
        }
        if ($this->query->getConnection()->delete($dn)) {
            // We'll set the exists property to false on delete
            // so the dev can run create operations.
            $this->exists = false;
            return true;
        }
        return false;
    }