summaryrefslogtreecommitdiff
path: root/app/Model/Comment.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-22 18:49:34 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-22 18:49:34 -0500
commitc49d46718a07afeea017aa90a60320587211dc49 (patch)
tree68499594b8d2f6a26411249aaff12b87b4ee3628 /app/Model/Comment.php
parent77e10d25829f3523a168bf61424fac99a539f8be (diff)
Some refactoring for PHP 5.3
Diffstat (limited to 'app/Model/Comment.php')
-rw-r--r--app/Model/Comment.php19
1 files changed, 6 insertions, 13 deletions
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index 8ef89094..3b7dfbc1 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -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;
}
/**