Improve webhooks to call external url on task creation/modification

This commit is contained in:
Frédéric Guillot
2014-07-21 20:32:12 -02:30
parent 4ae655ced3
commit 9e1dcf21dc
18 changed files with 320 additions and 14 deletions

View File

@@ -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

View File

@@ -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;
}
}