public function delete()
{
$this->events()->trigger(__CLASS__, 'before.delete', $this);
$id = $this->getId();
if (!empty($id)) {
try {
parent::delete(array('id' => $id));
} catch (\Exception $e) {
throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
}
if (file_exists($this->getFilePath())) {
unlink($this->getFilePath());
}
$this->events()->trigger(__CLASS__, 'after.delete', $this);
unset($this);
return true;
}
$this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
return false;
}
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @return void */ protected function tearDown() { unset($this->object); $this->documentType->delete(); unset($this->documentType); $this->view->delete(); unset($this->view); $this->layout->delete(); unset($this->layout); $this->user->delete(); unset($this->user); }