Extract Flarum\Notification namespace

This commit is contained in:
Franz Liedke 2017-06-24 14:22:19 +02:00
parent 4a13cd8088
commit b38ade986d
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
18 changed files with 42 additions and 45 deletions

View File

@ -13,7 +13,7 @@ namespace Flarum\Api\Controller;
use Flarum\Discussion\Discussion;
use Flarum\User\Exception\PermissionDeniedException;
use Flarum\Core\Repository\NotificationRepository;
use Flarum\Notification\NotificationRepository;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
@ -39,12 +39,12 @@ class ListNotificationsController extends AbstractListController
public $limit = 10;
/**
* @var \Flarum\Core\Repository\NotificationRepository
* @var \Flarum\Notification\NotificationRepository
*/
protected $notifications;
/**
* @param \Flarum\Core\Repository\NotificationRepository $notifications
* @param \Flarum\Notification\NotificationRepository $notifications
*/
public function __construct(NotificationRepository $notifications)
{
@ -80,7 +80,7 @@ class ListNotificationsController extends AbstractListController
}
/**
* @param \Flarum\Core\Notification[] $notifications
* @param \Flarum\Notification\Notification[] $notifications
*/
private function loadSubjectDiscussions(array $notifications)
{

View File

@ -11,7 +11,7 @@
namespace Flarum\Api\Serializer;
use Flarum\Core\Notification;
use Flarum\Notification\Notification;
use InvalidArgumentException;
class NotificationSerializer extends AbstractSerializer
@ -32,7 +32,7 @@ class NotificationSerializer extends AbstractSerializer
/**
* {@inheritdoc}
*
* @param \Flarum\Core\Notification $notification
* @param \Flarum\Notification\Notification $notification
* @throws InvalidArgumentException
*/
protected function getDefaultAttributes($notification)

View File

@ -13,7 +13,7 @@ namespace Flarum\Core\Command;
use DateTime;
use Flarum\User\AssertPermissionTrait;
use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Notification\NotificationSyncer;
use Flarum\Post\CommentPost;
use Flarum\Discussion\DiscussionRepository;
use Flarum\Foundation\DispatchEventsTrait;
@ -32,7 +32,7 @@ class PostReplyHandler
protected $discussions;
/**
* @var NotificationSyncer
* @var \Flarum\Notification\NotificationSyncer
*/
protected $notifications;
@ -44,7 +44,7 @@ class PostReplyHandler
/**
* @param Dispatcher $events
* @param DiscussionRepository $discussions
* @param NotificationSyncer $notifications
* @param \Flarum\Notification\NotificationSyncer $notifications
* @param PostValidator $validator
*/
public function __construct(

View File

@ -12,7 +12,7 @@
namespace Flarum\Core\Command;
use Flarum\User\AssertPermissionTrait;
use Flarum\Core\Repository\NotificationRepository;
use Flarum\Notification\NotificationRepository;
class ReadAllNotificationsHandler
{

View File

@ -12,7 +12,7 @@
namespace Flarum\Core\Command;
use Flarum\User\AssertPermissionTrait;
use Flarum\Core\Notification;
use Flarum\Notification\Notification;
class ReadNotificationHandler
{
@ -20,7 +20,7 @@ class ReadNotificationHandler
/**
* @param ReadNotification $command
* @return \Flarum\Core\Notification
* @return \Flarum\Notification\Notification
* @throws \Flarum\User\Exception\PermissionDeniedException
*/
public function handle(ReadNotification $command)

View File

@ -40,7 +40,7 @@ class CoreServiceProvider extends AbstractServiceProvider
$this->registerAvatarsFilesystem();
$this->app->register('Flarum\Core\Notification\NotificationServiceProvider');
$this->app->register('Flarum\Notification\Notification\NotificationServiceProvider');
$this->app->register('Flarum\Search\SearchServiceProvider');
$this->app->register('Flarum\Formatter\FormatterServiceProvider');
}

View File

@ -11,8 +11,8 @@
namespace Flarum\Discussion;
use Flarum\Core\Notification\DiscussionRenamedBlueprint;
use Flarum\Core\Notification\NotificationSyncer;
use Flarum\Notification\Blueprint\DiscussionRenamedBlueprint;
use Flarum\Notification\NotificationSyncer;
use Flarum\Post\DiscussionRenamedPost;
use Flarum\Discussion\Event\Renamed;
use Illuminate\Contracts\Events\Dispatcher;

View File

@ -11,7 +11,7 @@
namespace Flarum\Event;
use Flarum\Core\Notification\BlueprintInterface;
use Flarum\Notification\Blueprint\BlueprintInterface;
use InvalidArgumentException;
use ReflectionClass;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification\Blueprint;
/**
* A notification BlueprintInterface, when instantiated, represents a notification about

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification\Blueprint;
use Flarum\Post\DiscussionRenamedPost;

View File

@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Event;
namespace Flarum\Notification\Event;
use Flarum\Core\Notification\BlueprintInterface;
use Flarum\Notification\Blueprint\BlueprintInterface;
class NotificationWillBeSent
class Sending
{
/**
* The blueprint for the notification.
@ -30,7 +30,7 @@ class NotificationWillBeSent
public $users;
/**
* @param BlueprintInterface $blueprint
* @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
* @param \Flarum\User\User[] $users
*/
public function __construct(BlueprintInterface $blueprint, array &$users)

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification;
interface MailableInterface
{

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core;
namespace Flarum\Notification;
use Flarum\Database\AbstractModel;

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification;
use Flarum\User\User;
use Illuminate\Contracts\Mail\Mailer;

View File

@ -9,9 +9,8 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Repository;
namespace Flarum\Notification;
use Flarum\Core\Notification;
use Flarum\User\User;
class NotificationRepository

View File

@ -9,9 +9,8 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification;
use Flarum\Core\Notification;
use Flarum\Event\ConfigureNotificationTypes;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\User\User;
@ -33,7 +32,7 @@ class NotificationServiceProvider extends AbstractServiceProvider
public function registerNotificationTypes()
{
$blueprints = [
'Flarum\Core\Notification\DiscussionRenamedBlueprint' => ['alert']
'Flarum\Notification\Notification\DiscussionRenamedBlueprint' => ['alert']
];
$this->app->make('events')->fire(
@ -52,7 +51,7 @@ class NotificationServiceProvider extends AbstractServiceProvider
in_array('alert', $enabled)
);
if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Core\Notification\MailableInterface')) {
if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\Notification\Notification\MailableInterface')) {
User::addPreference(
User::getNotificationPreferenceKey($type, 'email'),
'boolval',

View File

@ -9,12 +9,11 @@
* file that was distributed with this source code.
*/
namespace Flarum\Core\Notification;
namespace Flarum\Notification;
use Carbon\Carbon;
use Flarum\Core\Notification;
use Flarum\Core\Repository\NotificationRepository;
use Flarum\Event\NotificationWillBeSent;
use Flarum\Notification\Event\Sending;
use Flarum\Notification\Blueprint\BlueprintInterface;
use Flarum\User\User;
/**
@ -66,11 +65,11 @@ class NotificationSyncer
* visible to anyone else. If it is being made visible for the first time,
* attempt to send the user an email.
*
* @param BlueprintInterface $blueprint
* @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
* @param User[] $users
* @return void
*/
public function sync(BlueprintInterface $blueprint, array $users)
public function sync(Blueprint\BlueprintInterface $blueprint, array $users)
{
$attributes = $this->getAttributes($blueprint);
@ -125,7 +124,7 @@ class NotificationSyncer
/**
* Delete a notification for all users.
*
* @param BlueprintInterface $blueprint
* @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
* @return void
*/
public function delete(BlueprintInterface $blueprint)
@ -165,14 +164,14 @@ class NotificationSyncer
* Create a notification record and send an email (depending on user
* preference) from a blueprint to a list of recipients.
*
* @param BlueprintInterface $blueprint
* @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
* @param User[] $recipients
*/
protected function sendNotifications(BlueprintInterface $blueprint, array $recipients)
protected function sendNotifications(Blueprint\BlueprintInterface $blueprint, array $recipients)
{
$now = Carbon::now('utc')->toDateTimeString();
event(new NotificationWillBeSent($blueprint, $recipients));
event(new Sending($blueprint, $recipients));
$attributes = $this->getAttributes($blueprint);
@ -220,10 +219,10 @@ class NotificationSyncer
* Construct an array of attributes to be stored in a notification record in
* the database, given a notification blueprint.
*
* @param BlueprintInterface $blueprint
* @param \Flarum\Notification\Blueprint\BlueprintInterface $blueprint
* @return array
*/
protected function getAttributes(BlueprintInterface $blueprint)
protected function getAttributes(Blueprint\BlueprintInterface $blueprint)
{
return [
'type' => $blueprint::getType(),

View File

@ -13,7 +13,7 @@ namespace Flarum\User;
use DomainException;
use Flarum\Group\Group;
use Flarum\Core\Notification;
use Flarum\Notification\Notification;
use Flarum\Group\Permission;
use Flarum\Foundation\EventGeneratorTrait;
use Flarum\Database\ScopeVisibilityTrait;
@ -632,7 +632,7 @@ class User extends AbstractModel
*/
public function notifications()
{
return $this->hasMany('Flarum\Core\Notification');
return $this->hasMany('Flarum\Notification\Notification');
}
/**