diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-05-18 21:04:06 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-05-18 21:04:06 -0400 |
commit | 6d5ffaa848dcbc09538f79cb0cdea08f5306f4a4 (patch) | |
tree | 2b782b7bc4b7f25cfa9021f7250450c7534f86cb /app/Subscriber | |
parent | db95e96f92a15660dc043eb033a0f7737b59a030 (diff) |
Send all Kanboard events to the webhook (breaking change)
Diffstat (limited to 'app/Subscriber')
-rw-r--r-- | app/Subscriber/WebhookSubscriber.php | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/app/Subscriber/WebhookSubscriber.php b/app/Subscriber/WebhookSubscriber.php index 6b5abf1b..e28675bd 100644 --- a/app/Subscriber/WebhookSubscriber.php +++ b/app/Subscriber/WebhookSubscriber.php @@ -2,8 +2,13 @@ namespace Subscriber; +use Event\CommentEvent; +use Event\GenericEvent; use Event\TaskEvent; +use Model\Comment; use Model\Task; +use Model\File; +use Model\Subtask; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class WebhookSubscriber extends Base implements EventSubscriberInterface @@ -11,32 +16,30 @@ class WebhookSubscriber extends Base implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - Task::EVENT_CREATE => array('onTaskCreation', 0), - Task::EVENT_UPDATE => array('onTaskModification', 0), - Task::EVENT_CLOSE => array('onTaskModification', 0), - Task::EVENT_OPEN => array('onTaskModification', 0), - Task::EVENT_MOVE_COLUMN => array('onTaskModification', 0), - Task::EVENT_MOVE_POSITION => array('onTaskModification', 0), - Task::EVENT_ASSIGNEE_CHANGE => array('onTaskModification', 0), + Task::EVENT_CREATE => array('execute', 0), + Task::EVENT_UPDATE => array('execute', 0), + Task::EVENT_CLOSE => array('execute', 0), + Task::EVENT_OPEN => array('execute', 0), + Task::EVENT_MOVE_COLUMN => array('execute', 0), + Task::EVENT_MOVE_POSITION => array('execute', 0), + Task::EVENT_ASSIGNEE_CHANGE => array('execute', 0), + Task::EVENT_MOVE_PROJECT => array('execute', 0), + Task::EVENT_MOVE_SWIMLANE => array('execute', 0), + Comment::EVENT_CREATE => array('execute', 0), + Comment::EVENT_UPDATE => array('execute', 0), + File::EVENT_CREATE => array('execute', 0), + Subtask::EVENT_CREATE => array('execute', 0), + Subtask::EVENT_UPDATE => array('execute', 0), ); } - public function onTaskCreation(TaskEvent $event) + public function execute(GenericEvent $event, $event_name) { - $this->executeRequest('webhook_url_task_creation', $event); - } - - public function onTaskModification(TaskEvent $event) - { - $this->executeRequest('webhook_url_task_modification', $event); - } - - public function executeRequest($parameter, TaskEvent $event) - { - $url = $this->config->get($parameter); + $payload = array( + 'event_name' => $event_name, + 'event_data' => $event->getAll(), + ); - if (! empty($url)) { - $this->webhook->notify($url, $event->getAll()); - } + $this->webhook->notify($payload); } } |