diff options
Diffstat (limited to 'app/Event/WebhookListener.php')
| -rw-r--r-- | app/Event/WebhookListener.php | 49 |
1 files changed, 49 insertions, 0 deletions
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; + } +} |
