mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 14:20:47 +08:00
Use RequestUtil for accessing actor
This commit is contained in:
parent
9936681634
commit
f80a88d45b
|
@ -12,6 +12,7 @@ namespace Flarum\Flags\Api\Controller;
|
||||||
use Flarum\Api\Controller\AbstractCreateController;
|
use Flarum\Api\Controller\AbstractCreateController;
|
||||||
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
||||||
use Flarum\Flags\Command\CreateFlag;
|
use Flarum\Flags\Command\CreateFlag;
|
||||||
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
@ -51,7 +52,7 @@ class CreateFlagController extends AbstractCreateController
|
||||||
protected function data(ServerRequestInterface $request, Document $document)
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
{
|
{
|
||||||
return $this->bus->dispatch(
|
return $this->bus->dispatch(
|
||||||
new CreateFlag($request->getAttribute('actor'), Arr::get($request->getParsedBody(), 'data', []))
|
new CreateFlag(RequestUtil::getActor($request), Arr::get($request->getParsedBody(), 'data', []))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Flarum\Flags\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Api\Controller\AbstractDeleteController;
|
use Flarum\Api\Controller\AbstractDeleteController;
|
||||||
use Flarum\Flags\Command\DeleteFlags;
|
use Flarum\Flags\Command\DeleteFlags;
|
||||||
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
@ -36,7 +37,7 @@ class DeleteFlagsController extends AbstractDeleteController
|
||||||
protected function delete(ServerRequestInterface $request)
|
protected function delete(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->bus->dispatch(
|
$this->bus->dispatch(
|
||||||
new DeleteFlags(Arr::get($request->getQueryParams(), 'id'), $request->getAttribute('actor'), $request->getParsedBody())
|
new DeleteFlags(Arr::get($request->getQueryParams(), 'id'), RequestUtil::getActor($request), $request->getParsedBody())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Flarum\Flags\Api\Controller;
|
||||||
use Flarum\Api\Controller\AbstractListController;
|
use Flarum\Api\Controller\AbstractListController;
|
||||||
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
||||||
use Flarum\Flags\Flag;
|
use Flarum\Flags\Flag;
|
||||||
|
use Flarum\Http\RequestUtil;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ class ListFlagsController extends AbstractListController
|
||||||
*/
|
*/
|
||||||
protected function data(ServerRequestInterface $request, Document $document)
|
protected function data(ServerRequestInterface $request, Document $document)
|
||||||
{
|
{
|
||||||
$actor = $request->getAttribute('actor');
|
$actor = RequestUtil::getActor($request);
|
||||||
$include = $this->extractInclude($request);
|
$include = $this->extractInclude($request);
|
||||||
|
|
||||||
$actor->assertRegistered();
|
$actor->assertRegistered();
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Flarum\Flags;
|
||||||
|
|
||||||
use Flarum\Api\Controller;
|
use Flarum\Api\Controller;
|
||||||
use Flarum\Flags\Api\Controller\CreateFlagController;
|
use Flarum\Flags\Api\Controller\CreateFlagController;
|
||||||
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ class PrepareFlagsApiData
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($posts)) {
|
if (isset($posts)) {
|
||||||
$actor = $request->getAttribute('actor');
|
$actor = RequestUtil::getActor($request);
|
||||||
$postsWithPermission = [];
|
$postsWithPermission = [];
|
||||||
|
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user