mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
Use RequestUtil to access actor
This commit is contained in:
parent
a1ba21ec69
commit
5235dda1e4
|
@ -10,6 +10,7 @@
|
|||
namespace Flarum\Tags\Api\Controller;
|
||||
|
||||
use Flarum\Api\Controller\AbstractCreateController;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\Api\Serializer\TagSerializer;
|
||||
use Flarum\Tags\Command\CreateTag;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
|
@ -48,7 +49,7 @@ class CreateTagController extends AbstractCreateController
|
|||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
return $this->bus->dispatch(
|
||||
new CreateTag($request->getAttribute('actor'), Arr::get($request->getParsedBody(), 'data', []))
|
||||
new CreateTag(RequestUtil::getActor($request), Arr::get($request->getParsedBody(), 'data', []))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace Flarum\Tags\Api\Controller;
|
||||
|
||||
use Flarum\Api\Controller\AbstractDeleteController;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\Command\DeleteTag;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
|
@ -36,7 +37,7 @@ class DeleteTagController extends AbstractDeleteController
|
|||
protected function delete(ServerRequestInterface $request)
|
||||
{
|
||||
$this->bus->dispatch(
|
||||
new DeleteTag(Arr::get($request->getQueryParams(), 'id'), $request->getAttribute('actor'))
|
||||
new DeleteTag(Arr::get($request->getQueryParams(), 'id'), RequestUtil::getActor($request))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace Flarum\Tags\Api\Controller;
|
||||
|
||||
use Flarum\Api\Controller\AbstractListController;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\Api\Serializer\TagSerializer;
|
||||
use Flarum\Tags\Tag;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -54,7 +55,7 @@ class ListTagsController extends AbstractListController
|
|||
*/
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
$actor = RequestUtil::getActor($request);
|
||||
$include = $this->extractInclude($request);
|
||||
|
||||
$tags = $this->tags->whereVisibleTo($actor)->withStateFor($actor)->get();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace Flarum\Tags\Api\Controller;
|
||||
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\Tag;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laminas\Diactoros\Response\EmptyResponse;
|
||||
|
@ -23,7 +24,7 @@ class OrderTagsController implements RequestHandlerInterface
|
|||
*/
|
||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
$request->getAttribute('actor')->assertAdmin();
|
||||
RequestUtil::getActor($request)->assertAdmin();
|
||||
|
||||
$order = Arr::get($request->getParsedBody(), 'order');
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace Flarum\Tags\Api\Controller;
|
||||
|
||||
use Flarum\Api\Controller\AbstractShowController;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\Api\Serializer\TagSerializer;
|
||||
use Flarum\Tags\Command\EditTag;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
|
@ -43,7 +44,7 @@ class UpdateTagController extends AbstractShowController
|
|||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$id = Arr::get($request->getQueryParams(), 'id');
|
||||
$actor = $request->getAttribute('actor');
|
||||
$actor = RequestUtil::getActor($request);
|
||||
$data = Arr::get($request->getParsedBody(), 'data', []);
|
||||
|
||||
return $this->bus->dispatch(
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Flarum\Tags\Content;
|
|||
use Flarum\Api\Client;
|
||||
use Flarum\Api\Controller\ListDiscussionsController;
|
||||
use Flarum\Frontend\Document;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Tags\TagRepository;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
@ -58,7 +59,7 @@ class Tag
|
|||
public function __invoke(Document $document, Request $request)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
$actor = $request->getAttribute('actor');
|
||||
$actor = RequestUtil::getActor($request);
|
||||
|
||||
$slug = Arr::pull($queryParams, 'slug');
|
||||
$sort = Arr::pull($queryParams, 'sort');
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace Flarum\Tags;
|
||||
|
||||
use Flarum\Api\Controller\ShowForumController;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
class LoadForumTagsRelationship
|
||||
|
@ -21,7 +22,7 @@ class LoadForumTagsRelationship
|
|||
*/
|
||||
public function __invoke(ShowForumController $controller, &$data, ServerRequestInterface $request)
|
||||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
$actor = RequestUtil::getActor($request);
|
||||
|
||||
// Expose the complete tag list to clients by adding it as a
|
||||
// relationship to the /api endpoint. Since the Forum model
|
||||
|
|
Loading…
Reference in New Issue
Block a user