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;
use Kanboard\Core\Security\Role;
use Kanboard\Notification\Mail as MailNotification;
use Kanboard\Notification\MailNotification;
/**
* Class UserCreationController

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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