Created
June 5, 2014 09:30
-
-
Save yupe/faf1da1301d3a50f129d to your computer and use it in GitHub Desktop.
Test event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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