summaryrefslogtreecommitdiff
path: root/app/Job/CommentEventJob.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-17 17:15:14 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-17 17:15:14 -0400
commitec0ecc5b0387924f061865f4ec12dbfc5b7018fe (patch)
tree146fe907e300fa88587b621aaf53a9ca05e8c2d8 /app/Job/CommentEventJob.php
parent3aa0f8574898876518dddf29ced43dd32efa2375 (diff)
Added event for removed comments with some refactoring
Diffstat (limited to 'app/Job/CommentEventJob.php')
-rw-r--r--app/Job/CommentEventJob.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/Job/CommentEventJob.php b/app/Job/CommentEventJob.php
new file mode 100644
index 00000000..c89350ed
--- /dev/null
+++ b/app/Job/CommentEventJob.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Kanboard\Job;
+
+use Kanboard\EventBuilder\CommentEventBuilder;
+use Kanboard\Model\CommentModel;
+
+/**
+ * Class CommentEventJob
+ *
+ * @package Kanboard\Job
+ * @author Frederic Guillot
+ */
+class CommentEventJob extends BaseJob
+{
+ /**
+ * Set job params
+ *
+ * @param int $commentId
+ * @param string $eventName
+ * @return $this
+ */
+ public function withParams($commentId, $eventName)
+ {
+ $this->jobParams = array($commentId, $eventName);
+ return $this;
+ }
+
+ /**
+ * Execute job
+ *
+ * @param int $commentId
+ * @param string $eventName
+ * @return $this
+ */
+ public function execute($commentId, $eventName)
+ {
+ $event = CommentEventBuilder::getInstance($this->container)
+ ->withCommentId($commentId)
+ ->build();
+
+ if ($event !== null) {
+ $this->dispatcher->dispatch($eventName, $event);
+
+ if ($eventName === CommentModel::EVENT_CREATE) {
+ $this->userMentionModel->fireEvents($event['comment']['comment'], CommentModel::EVENT_USER_MENTION, $event);
+ }
+ }
+ }
+}