diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-17 17:15:14 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-17 17:15:14 -0400 |
commit | ec0ecc5b0387924f061865f4ec12dbfc5b7018fe (patch) | |
tree | 146fe907e300fa88587b621aaf53a9ca05e8c2d8 /app/Job | |
parent | 3aa0f8574898876518dddf29ced43dd32efa2375 (diff) |
Added event for removed comments with some refactoring
Diffstat (limited to 'app/Job')
-rw-r--r-- | app/Job/CommentEventJob.php | 50 | ||||
-rw-r--r-- | app/Job/NotificationJob.php | 3 |
2 files changed, 51 insertions, 2 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); + } + } + } +} diff --git a/app/Job/NotificationJob.php b/app/Job/NotificationJob.php index 904a9273..cfd0699d 100644 --- a/app/Job/NotificationJob.php +++ b/app/Job/NotificationJob.php @@ -75,8 +75,7 @@ class NotificationJob extends BaseJob $values['task'] = $this->taskFinderModel->getDetails($values['file']['task_id']); break; case 'Kanboard\Event\CommentEvent': - $values['comment'] = $this->commentModel->getById($event['id']); - $values['task'] = $this->taskFinderModel->getDetails($values['comment']['task_id']); + $values = $event; break; } |