Improve webhooks to call external url on task creation/modification
This commit is contained in:
@@ -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
|
||||
49
app/Event/WebhookListener.php
Normal file
49
app/Event/WebhookListener.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user