mirror of
https://github.com/flarum/framework.git
synced 2025-02-08 17:12:44 +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
ccfc176067
commit
1e640ba632
|
@ -3,10 +3,10 @@
|
||||||
use Flarum\Api\Events\WillSerializeData;
|
use Flarum\Api\Events\WillSerializeData;
|
||||||
use Flarum\Api\Request;
|
use Flarum\Api\Request;
|
||||||
use Flarum\Api\JsonApiRequest;
|
use Flarum\Api\JsonApiRequest;
|
||||||
use Flarum\Api\JsonApiResponse;
|
|
||||||
use Tobscure\JsonApi\Criteria;
|
use Tobscure\JsonApi\Criteria;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
use Tobscure\JsonApi\SerializerInterface;
|
use Tobscure\JsonApi\SerializerInterface;
|
||||||
|
use Zend\Diactoros\Response\JsonResponse;
|
||||||
|
|
||||||
abstract class SerializeAction extends JsonApiAction
|
abstract class SerializeAction extends JsonApiAction
|
||||||
{
|
{
|
||||||
|
@ -78,9 +78,7 @@ abstract class SerializeAction extends JsonApiAction
|
||||||
$serializer = new static::$serializer($request->actor, $request->include, $request->link);
|
$serializer = new static::$serializer($request->actor, $request->include, $request->link);
|
||||||
|
|
||||||
$document->setData($this->serialize($serializer, $data));
|
$document->setData($this->serialize($serializer, $data));
|
||||||
$response = new JsonApiResponse($document);
|
return new JsonResponse($document, 200, ['content-type' => 'application/vnd.api+json']);
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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