diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-19 22:38:30 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-19 22:38:30 -0400 |
commit | 390082aa41cb81610089163b1cc3a256f3b3c513 (patch) | |
tree | 1ada3964702ee536fe1486f34230f8e30a95d82e /app/Job/NotificationJob.php | |
parent | d9d37882228771bca0c7f53f5ffcef90ba7ac1c5 (diff) |
Refactoring of internal task events
Diffstat (limited to 'app/Job/NotificationJob.php')
-rw-r--r-- | app/Job/NotificationJob.php | 50 |
1 files changed, 9 insertions, 41 deletions
diff --git a/app/Job/NotificationJob.php b/app/Job/NotificationJob.php index 5a52eb31..8fb260e8 100644 --- a/app/Job/NotificationJob.php +++ b/app/Job/NotificationJob.php @@ -17,59 +17,27 @@ class NotificationJob extends BaseJob * * @param GenericEvent $event * @param string $eventName - * @param string $eventObjectName * @return $this */ - public function withParams(GenericEvent $event, $eventName, $eventObjectName) + public function withParams(GenericEvent $event, $eventName) { - $this->jobParams = array($event->getAll(), $eventName, $eventObjectName); + $this->jobParams = array($event->getAll(), $eventName); return $this; } /** * Execute job * - * @param array $event + * @param array $eventData * @param string $eventName - * @param string $eventObjectName */ - public function execute(array $event, $eventName, $eventObjectName) + public function execute(array $eventData, $eventName) { - $eventData = $this->getEventData($event, $eventObjectName); - - if (! empty($eventData)) { - if (! empty($event['mention'])) { - $this->userNotificationModel->sendUserNotification($event['mention'], $eventName, $eventData); - } else { - $this->userNotificationModel->sendNotifications($eventName, $eventData); - $this->projectNotificationModel->sendNotifications($eventData['task']['project_id'], $eventName, $eventData); - } - } - } - - /** - * Get event data - * - * @param array $event - * @param string $eventObjectName - * @return array - */ - public function getEventData(array $event, $eventObjectName) - { - $values = array(); - - if (! empty($event['changes'])) { - $values['changes'] = $event['changes']; + if (! empty($eventData['mention'])) { + $this->userNotificationModel->sendUserNotification($eventData['mention'], $eventName, $eventData); + } else { + $this->userNotificationModel->sendNotifications($eventName, $eventData); + $this->projectNotificationModel->sendNotifications($eventData['task']['project_id'], $eventName, $eventData); } - - switch ($eventObjectName) { - case 'Kanboard\Event\TaskEvent': - $values['task'] = $this->taskFinderModel->getDetails($event['task_id']); - break; - default: - $values = $event; - } - - return $values; } } |