mirror of
https://github.com/flarum/core.git
synced 2025-10-11 23:14:29 +02:00
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Api\Controller;
|
|
|
|
use Flarum\Api\Serializer\PostSerializer;
|
|
use Flarum\Post\PostRepository;
|
|
use Illuminate\Support\Arr;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Tobscure\JsonApi\Document;
|
|
|
|
class ShowPostController extends AbstractShowController
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public $serializer = PostSerializer::class;
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public $include = [
|
|
'user',
|
|
'user.groups',
|
|
'editedUser',
|
|
'hiddenUser',
|
|
'discussion'
|
|
];
|
|
|
|
/**
|
|
* @var \Flarum\Post\PostRepository
|
|
*/
|
|
protected $posts;
|
|
|
|
/**
|
|
* @param \Flarum\Post\PostRepository $posts
|
|
*/
|
|
public function __construct(PostRepository $posts)
|
|
{
|
|
$this->posts = $posts;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function data(ServerRequestInterface $request, Document $document)
|
|
{
|
|
return $this->posts->findOrFail(Arr::get($request->getQueryParams(), 'id'), $request->getAttribute('actor'));
|
|
}
|
|
}
|