mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 22:43:41 +08:00
Update for API Client changes
This commit is contained in:
parent
706a07429d
commit
494633537e
|
@ -80,9 +80,9 @@ class Tag
|
|||
'page' => ['offset' => ($page - 1) * 20, 'limit' => 20]
|
||||
];
|
||||
|
||||
$apiDocument = $this->getApiDocument($actor, $params);
|
||||
$apiDocument = $this->getApiDocument($request, $params);
|
||||
|
||||
$tagsDocument = $this->getTagsDocument($actor, $slug);
|
||||
$tagsDocument = $this->getTagsDocument($request, $slug);
|
||||
|
||||
$apiDocument->included[] = $tagsDocument->data;
|
||||
foreach ((array) $tagsDocument->included as $tag) {
|
||||
|
@ -118,21 +118,16 @@ class Tag
|
|||
|
||||
/**
|
||||
* Get the result of an API request to list discussions.
|
||||
*
|
||||
* @param User $actor
|
||||
* @param array $params
|
||||
* @return object
|
||||
*/
|
||||
private function getApiDocument(User $actor, array $params)
|
||||
private function getApiDocument(Request $request, array $params)
|
||||
{
|
||||
return json_decode($this->api->send(ListDiscussionsController::class, $actor, $params)->getBody());
|
||||
return json_decode($this->api->withParentRequest($request)->withQueryParams($params)->get('/discussions')->getBody());
|
||||
}
|
||||
|
||||
private function getTagsDocument(User $actor, string $slug)
|
||||
private function getTagsDocument(Request $request, string $slug)
|
||||
{
|
||||
return json_decode($this->api->send(ShowTagController::class, $actor, [
|
||||
'slug' => $slug,
|
||||
return json_decode($this->api->withParentRequest($request)->withQueryParams([
|
||||
'include' => 'children,children.parent,parent,parent.children.parent,state'
|
||||
])->getBody());
|
||||
])->get("/tags/$slug")->getBody());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace Flarum\Tags\Content;
|
|||
|
||||
use Flarum\Api\Client;
|
||||
use Flarum\Frontend\Document;
|
||||
use Flarum\Http\RequestUtil;
|
||||
use Flarum\Http\UrlGenerator;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Tags\Api\Controller\ListTagsController;
|
||||
|
@ -80,7 +79,7 @@ class Tags
|
|||
|
||||
public function __invoke(Document $document, Request $request)
|
||||
{
|
||||
$apiDocument = $this->getTagsDocument(RequestUtil::getActor($request));
|
||||
$apiDocument = $this->getTagsDocument($request);
|
||||
$tags = collect(Arr::get($apiDocument, 'data', []));
|
||||
|
||||
$childTags = $tags->where('attributes.isChild', true);
|
||||
|
@ -103,10 +102,10 @@ class Tags
|
|||
return $document;
|
||||
}
|
||||
|
||||
private function getTagsDocument(User $actor)
|
||||
private function getTagsDocument(Request $request)
|
||||
{
|
||||
return json_decode($this->api->send(ListTagsController::class, $actor, [
|
||||
return json_decode($this->api->withParentRequest($request)->withQueryParams([
|
||||
'include' => 'children,lastPostedDiscussion'
|
||||
])->getBody(), true);
|
||||
])->get('/tags')->getBody(), true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user