Some refactoring for PHP 5.3

This commit is contained in:
Frédéric Guillot
2014-11-22 18:49:34 -05:00
parent 77e10d2582
commit c49d46718a
9 changed files with 39 additions and 67 deletions

View File

@@ -95,7 +95,7 @@ class Comment extends Base
}
/**
* Save a comment in the database
* Create a new comment
*
* @access public
* @param array $values Form values
@@ -104,20 +104,13 @@ class Comment extends Base
public function create(array $values)
{
$values['date'] = time();
$comment_id = $this->persist(self::TABLE, $values);
return $this->db->transaction(function($db) use ($values) {
if ($comment_id) {
$this->event->trigger(self::EVENT_CREATE, array('id' => $comment_id) + $values);
}
if (! $db->table(Comment::TABLE)->save($values)) {
return false;
}
$comment_id = (int) $db->getConnection()->getLastId();
$values['id'] = $comment_id;
$this->event->trigger(self::EVENT_CREATE, $values);
return $comment_id;
});
return $comment_id;
}
/**