1
0
mirror of https://github.com/flarum/core.git synced 2025-10-22 20:26:15 +02:00

Extract Flarum\Notification namespace

This commit is contained in:
Franz Liedke
2017-06-24 14:22:19 +02:00
parent 4a13cd8088
commit b38ade986d
18 changed files with 42 additions and 45 deletions

View File

@@ -0,0 +1,55 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Notification\Blueprint;
/**
* A notification BlueprintInterface, when instantiated, represents a notification about
* something. The blueprint is used by the NotificationSyncer to commit the
* notification to the database.
*/
interface BlueprintInterface
{
/**
* Get the user that sent the notification.
*
* @return \Flarum\User\User|null
*/
public function getSender();
/**
* Get the model that is the subject of this activity.
*
* @return \Flarum\Database\AbstractModel|null
*/
public function getSubject();
/**
* Get the data to be stored in the notification.
*
* @return array|null
*/
public function getData();
/**
* Get the serialized type of this activity.
*
* @return string
*/
public static function getType();
/**
* Get the name of the model class for the subject of this activity.
*
* @return string
*/
public static function getSubjectModel();
}

View File

@@ -0,0 +1,70 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Notification\Blueprint;
use Flarum\Post\DiscussionRenamedPost;
class DiscussionRenamedBlueprint implements BlueprintInterface
{
/**
* @var \Flarum\Post\DiscussionRenamedPost
*/
protected $post;
/**
* @param DiscussionRenamedPost $post
*/
public function __construct(DiscussionRenamedPost $post)
{
$this->post = $post;
}
/**
* {@inheritdoc}
*/
public function getSender()
{
return $this->post->user;
}
/**
* {@inheritdoc}
*/
public function getSubject()
{
return $this->post->discussion;
}
/**
* {@inheritdoc}
*/
public function getData()
{
return ['postNumber' => (int) $this->post->number];
}
/**
* {@inheritdoc}
*/
public static function getType()
{
return 'discussionRenamed';
}
/**
* {@inheritdoc}
*/
public static function getSubjectModel()
{
return 'Flarum\Discussion\Discussion';
}
}