mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 20:33:48 +08:00
Get rid of JsonApiResponse class
With the JSON-API library being updated, we can just make use of Diactoros' JSON response class.
This commit is contained in:
parent
7054472d66
commit
ccbebce93b
|
@ -3,10 +3,10 @@
|
|||
use Flarum\Api\Events\WillSerializeData;
|
||||
use Flarum\Api\Request;
|
||||
use Flarum\Api\JsonApiRequest;
|
||||
use Flarum\Api\JsonApiResponse;
|
||||
use Tobscure\JsonApi\Criteria;
|
||||
use Tobscure\JsonApi\Document;
|
||||
use Tobscure\JsonApi\SerializerInterface;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
|
||||
abstract class SerializeAction extends JsonApiAction
|
||||
{
|
||||
|
@ -78,9 +78,7 @@ abstract class SerializeAction extends JsonApiAction
|
|||
$serializer = new static::$serializer($request->actor, $request->include, $request->link);
|
||||
|
||||
$document->setData($this->serialize($serializer, $data));
|
||||
$response = new JsonApiResponse($document);
|
||||
|
||||
return $response;
|
||||
return new JsonResponse($document, 200, ['content-type' => 'application/vnd.api+json']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php namespace Flarum\Api;
|
||||
|
||||
use Tobscure\JsonApi\Document;
|
||||
use Zend\Diactoros\Response;
|
||||
|
||||
class JsonApiResponse extends Response
|
||||
{
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
parent::__construct('php://memory', 200, ['content-type' => 'application/vnd.api+json']);
|
||||
|
||||
$this->getBody()->write($document);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user