Improve notification classes and move interface to core

This commit is contained in:
Frederic Guillot
2016-05-28 17:36:55 -04:00
parent 88ee691bb9
commit d6c1c1ea33
8 changed files with 25 additions and 21 deletions

View File

@@ -3,7 +3,7 @@
namespace Kanboard\Controller; namespace Kanboard\Controller;
use Kanboard\Core\Security\Role; use Kanboard\Core\Security\Role;
use Kanboard\Notification\Mail as MailNotification; use Kanboard\Notification\MailNotification;
/** /**
* Class UserCreationController * Class UserCreationController

View File

@@ -1,11 +1,11 @@
<?php <?php
namespace Kanboard\Notification; namespace Kanboard\Core\Notification;
/** /**
* Notification Interface * Notification Interface
* *
* @package core * @package Kanboard\Core\Notification
* @author Frederic Guillot * @author Frederic Guillot
*/ */
interface NotificationInterface interface NotificationInterface

View File

@@ -3,14 +3,15 @@
namespace Kanboard\Notification; namespace Kanboard\Notification;
use Kanboard\Core\Base; use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/** /**
* Activity Stream Notification * Activity Stream Notification
* *
* @package notification * @package Kanboard\Notification
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class ActivityStream extends Base implements NotificationInterface class ActivityStreamNotification extends Base implements NotificationInterface
{ {
/** /**
* Send notification to a user * Send notification to a user

View File

@@ -3,6 +3,7 @@
namespace Kanboard\Notification; namespace Kanboard\Notification;
use Kanboard\Core\Base; use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
use Kanboard\Model\Task; use Kanboard\Model\Task;
use Kanboard\Model\TaskFile; use Kanboard\Model\TaskFile;
use Kanboard\Model\Comment; use Kanboard\Model\Comment;
@@ -11,10 +12,10 @@ use Kanboard\Model\Subtask;
/** /**
* Email Notification * Email Notification
* *
* @package notification * @package Kanboard\Notification
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Mail extends Base implements NotificationInterface class MailNotification extends Base implements NotificationInterface
{ {
/** /**
* Notification type * Notification type

View File

@@ -3,14 +3,15 @@
namespace Kanboard\Notification; namespace Kanboard\Notification;
use Kanboard\Core\Base; use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/** /**
* Web Notification * Web Notification
* *
* @package notification * @package Kanboard\Notification
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Web extends Base implements NotificationInterface class WebNotification extends Base implements NotificationInterface
{ {
/** /**
* Notification type * Notification type

View File

@@ -3,14 +3,15 @@
namespace Kanboard\Notification; namespace Kanboard\Notification;
use Kanboard\Core\Base; use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/** /**
* Webhook Notification * Webhook Notification
* *
* @package notification * @package Kanboard\Notification
* @author Frederic Guillot * @author Frederic Guillot
*/ */
class Webhook extends Base implements NotificationInterface class WebhookNotification extends Base implements NotificationInterface
{ {
/** /**
* Send notification to a user * Send notification to a user

View File

@@ -6,8 +6,8 @@ use Pimple\Container;
use Pimple\ServiceProviderInterface; use Pimple\ServiceProviderInterface;
use Kanboard\Model\UserNotificationType; use Kanboard\Model\UserNotificationType;
use Kanboard\Model\ProjectNotificationType; use Kanboard\Model\ProjectNotificationType;
use Kanboard\Notification\Mail as MailNotification; use Kanboard\Notification\MailNotification as MailNotification;
use Kanboard\Notification\Web as WebNotification; use Kanboard\Notification\WebNotification as WebNotification;
/** /**
* Notification Provider * Notification Provider
@@ -28,15 +28,15 @@ class NotificationProvider implements ServiceProviderInterface
{ {
$container['userNotificationType'] = function ($container) { $container['userNotificationType'] = function ($container) {
$type = new UserNotificationType($container); $type = new UserNotificationType($container);
$type->setType(MailNotification::TYPE, t('Email'), '\Kanboard\Notification\Mail'); $type->setType(MailNotification::TYPE, t('Email'), '\Kanboard\Notification\MailNotification');
$type->setType(WebNotification::TYPE, t('Web'), '\Kanboard\Notification\Web'); $type->setType(WebNotification::TYPE, t('Web'), '\Kanboard\Notification\WebNotification');
return $type; return $type;
}; };
$container['projectNotificationType'] = function ($container) { $container['projectNotificationType'] = function ($container) {
$type = new ProjectNotificationType($container); $type = new ProjectNotificationType($container);
$type->setType('webhook', 'Webhook', '\Kanboard\Notification\Webhook', true); $type->setType('webhook', 'Webhook', '\Kanboard\Notification\WebhookNotification', true);
$type->setType('activity_stream', 'ActivityStream', '\Kanboard\Notification\ActivityStream', true); $type->setType('activity_stream', 'ActivityStream', '\Kanboard\Notification\ActivityStreamNotification', true);
return $type; return $type;
}; };

View File

@@ -10,14 +10,14 @@ use Kanboard\Model\User;
use Kanboard\Model\TaskFile; use Kanboard\Model\TaskFile;
use Kanboard\Model\Project; use Kanboard\Model\Project;
use Kanboard\Model\Task; use Kanboard\Model\Task;
use Kanboard\Notification\Mail; use Kanboard\Notification\MailNotification;
use Kanboard\Subscriber\NotificationSubscriber; use Kanboard\Subscriber\NotificationSubscriber;
class MailTest extends Base class MailTest extends Base
{ {
public function testGetMailContent() public function testGetMailContent()
{ {
$en = new Mail($this->container); $en = new MailNotification($this->container);
$p = new Project($this->container); $p = new Project($this->container);
$tf = new TaskFinder($this->container); $tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container); $tc = new TaskCreation($this->container);
@@ -62,7 +62,7 @@ class MailTest extends Base
public function testSendWithEmailAddress() public function testSendWithEmailAddress()
{ {
$en = new Mail($this->container); $en = new MailNotification($this->container);
$p = new Project($this->container); $p = new Project($this->container);
$tf = new TaskFinder($this->container); $tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container); $tc = new TaskCreation($this->container);
@@ -93,7 +93,7 @@ class MailTest extends Base
public function testSendWithoutEmailAddress() public function testSendWithoutEmailAddress()
{ {
$en = new Mail($this->container); $en = new MailNotification($this->container);
$p = new Project($this->container); $p = new Project($this->container);
$tf = new TaskFinder($this->container); $tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container); $tc = new TaskCreation($this->container);