1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 15:34:26 +02:00
Files
php-flarum/src/Api/JsonApiResponse.php
Matt Kilgore d7a5a6ad14 Change Zend namespace to Laminas (#1963)
Also ensure backwards compatibility for extensions that use the Zend framework but don't explicitly require it.
2020-01-06 22:29:34 +01:00

30 lines
879 B
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Api;
use Laminas\Diactoros\Response\JsonResponse;
use Tobscure\JsonApi\Document;
class JsonApiResponse extends JsonResponse
{
/**
* {@inheritdoc}
*/
public function __construct(Document $document, $status = 200, array $headers = [], $encodingOptions = 15)
{
$headers['content-type'] = 'application/vnd.api+json';
// The call to jsonSerialize prevents rare issues with json_encode() failing with a
// syntax error even though Document implements the JsonSerializable interface.
// See https://github.com/flarum/core/issues/685
parent::__construct($document->jsonSerialize(), $status, $headers, $encodingOptions);
}
}