Skip to content

Instantly share code, notes, and snippets.

@yupe
Created June 5, 2014 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yupe/faf1da1301d3a50f129d to your computer and use it in GitHub Desktop.
Save yupe/faf1da1301d3a50f129d to your computer and use it in GitHub Desktop.
Test event
public function publish()
{
$transaction = Yii::app()->db->beginTransaction();
try
{
$this->status = self::STATUS_PUBLISHED;
$this->publish_date = date('d-m-Y h:i');
if($this->save()) {
Yii::app()->eventManager->fire(PostEvents::POST_PUBLISH, new PostPublishEvent($this, Yii::app()->getUser()));
}
$transaction->commit();
return true;
}
catch(Exception $e)
{
$transaction->rollback();
Yii::log($e->__toString(), CLogger::LEVEL_ERROR);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment