diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-07-21 20:32:12 -0230 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-07-21 20:32:12 -0230 |
commit | 9e1dcf21dc5d65bcc4195f1ae4caedbe57835415 (patch) | |
tree | 7fa9a2a08e24de7d16c0196b61e7c1bf8540f486 /app/Event | |
parent | 4ae655ced334bb48342274caaf15f2b3d8b444f6 (diff) |
Improve webhooks to call external url on task creation/modification
Diffstat (limited to 'app/Event')
-rw-r--r-- | app/Event/ProjectModificationDate.php (renamed from app/Event/TaskModification.php) | 8 | ||||
-rw-r--r-- | app/Event/WebhookListener.php | 49 |
2 files changed, 54 insertions, 3 deletions
diff --git a/app/Event/TaskModification.php b/app/Event/ProjectModificationDate.php index b1d412c7..8fbaee73 100644 --- a/app/Event/TaskModification.php +++ b/app/Event/ProjectModificationDate.php @@ -6,12 +6,14 @@ use Core\Listener; use Model\Project; /** - * Task modification listener + * Project modification date listener * - * @package events + * Update the last modified field for a project + * + * @package event * @author Frederic Guillot */ -class TaskModification implements Listener +class ProjectModificationDate implements Listener { /** * Project model diff --git a/app/Event/WebhookListener.php b/app/Event/WebhookListener.php new file mode 100644 index 00000000..f9776653 --- /dev/null +++ b/app/Event/WebhookListener.php @@ -0,0 +1,49 @@ +<?php + +namespace Event; + +use Core\Listener; +use Model\Webhook; + +/** + * Webhook task events + * + * @package event + * @author Frederic Guillot + */ +class WebhookListener implements Listener +{ + /** + * Webhook model + * + * @accesss private + * @var \Model\Webhook + */ + private $webhook; + + /** + * Constructor + * + * @access public + * @param string $url URL to call + * @param \Model\Webhook $webhook Webhook model instance + */ + public function __construct($url, Webhook $webhook) + { + $this->url = $url; + $this->webhook = $webhook; + } + + /** + * Execute the action + * + * @access public + * @param array $data Event data dictionary + * @return bool True if the action was executed or false when not executed + */ + public function execute(array $data) + { + $this->webhook->notify($this->url, $data); + return true; + } +} |