Gc\Document\Model::delete PHP Method

delete() public method

Delete document
public delete ( ) : boolean
return boolean
    public function delete()
    {
        $this->events()->trigger(__CLASS__, 'before.delete', $this);
        $documentId = $this->getId();
        if (!empty($documentId)) {
            try {
                $propertiesTable = new TableGateway('property_value', $this->getAdapter());
                $propertiesTable->delete(array('document_id' => $this->getId()));
                parent::delete(array('id' => $documentId));
            } catch (\Exception $e) {
                throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
            }
            $this->events()->trigger(__CLASS__, 'after.delete', $this);
            unset($this);
            return true;
        }
        $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
        return false;
    }

Usage Example

Example #1
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->document->delete();
     $this->documentType->delete();
     $this->user->delete();
     $this->view->delete();
     $this->layout->delete();
     unset($this->object);
     unset($this->layout);
     unset($this->view);
     unset($this->user);
     unset($this->documentType);
     unset($this->document);
 }
All Usage Examples Of Gc\Document\Model::delete