mirror of
https://github.com/flarum/framework.git
synced 2025-02-13 21:22:45 +08:00
![Toby Zerner](/assets/img/avatar_default.png)
Explained in d1e7453ffd
.
If we ever come up with a better way of doing this it should be easy to
change over, since modification of these properties by extensions is
abstracted by an Extend API.
76 lines
1.6 KiB
PHP
76 lines
1.6 KiB
PHP
<?php namespace Flarum\Api\Actions\Notifications;
|
|
|
|
use Flarum\Core\Commands\ReadNotificationCommand;
|
|
use Flarum\Api\Actions\SerializeResourceAction;
|
|
use Flarum\Api\JsonApiRequest;
|
|
use Illuminate\Contracts\Bus\Dispatcher;
|
|
use Tobscure\JsonApi\Document;
|
|
|
|
class UpdateAction extends SerializeResourceAction
|
|
{
|
|
/**
|
|
* @var \Illuminate\Contracts\Bus\Dispatcher
|
|
*/
|
|
protected $bus;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $include = [];
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $link = [];
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $limitMax = 50;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $limit = 20;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $sortFields = [];
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static $sort;
|
|
|
|
/**
|
|
* Instantiate the action.
|
|
*
|
|
* @param \Illuminate\Contracts\Bus\Dispatcher $bus
|
|
*/
|
|
public function __construct(Dispatcher $bus)
|
|
{
|
|
$this->bus = $bus;
|
|
}
|
|
|
|
/**
|
|
* Mark a notification as read, and return it ready to be serialized and
|
|
* assigned to the JsonApi response.
|
|
*
|
|
* @param \Flarum\Api\JsonApiRequest $request
|
|
* @param \Tobscure\JsonApi\Document $document
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
*/
|
|
protected function data(JsonApiRequest $request, Document $document)
|
|
{
|
|
return $this->bus->dispatch(
|
|
new ReadNotificationCommand($request->get('id'), $request->actor->getUser())
|
|
);
|
|
}
|
|
}
|