8000 [Bugfix] Add minor amendments for backwards compatibility · startupengine/laravel-json-api@96965ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 96965ad

Browse files
committed
[Bugfix] Add minor amendments for backwards compatibility
Test response helper needs to not type-hint response because the JSON response class does not extend the Illuminate response. The error repository from the inbound request API needs to be bound in the container for backwards compatibility with classes that were resolving it via constructor injection.
1 parent c347833 commit 96965ad

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/ServiceProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use CloudCreativity\JsonApi\Contracts\Object\DocumentInterface;
2525
use CloudCreativity\JsonApi\Contracts\Object\RelationshipInterface;
2626
use CloudCreativity\JsonApi\Contracts\Object\ResourceObjectInterface;
27+
use CloudCreativity\JsonApi\Contracts\Repositories\ErrorRepositoryInterface;
2728
use CloudCreativity\JsonApi\Contracts\Store\StoreInterface;
2829
use CloudCreativity\JsonApi\Exceptions\RuntimeException;
2930
use CloudCreativity\LaravelJsonApi\Api\Repository;
@@ -199,7 +200,7 @@ protected function bindRequestInterpreter()
199200
}
200201

201202
/**
202-
* Bind the inbound request services so they can be type-hinted in controllers.
203+
* Bind the inbound request services so they can be type-hinted in controllers and authorizers.
203204
*
204205
* @return void
205206
*/
@@ -209,6 +210,10 @@ protected function bindInboundRequest()
209210
return json_api()->getStore();
210211
});
211212

213+
$this->app->bind(ErrorRepositoryInterface::class, function (Application $app) {
214+
return json_api()->getErrors();
215+
});
216+
212217
$this->app->bind(DocumentInterface::class, function () {
213218
if (!$document = json_api_request()->getDocument()) {
214219
throw new RuntimeException('No request document on inbound JSON API request.');

src/Testing/TestResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestResponse extends BaseTestResponse
3030
* @param Response $response
3131
* @param string|null $expectedResourceType
3232
*/
33-
public function __construct(Response $response, $expectedResourceType = null)
33+
public function __construct($response, $expectedResourceType = null)
3434
{
3535
parent::__construct($response);
3636
$this->expectedResourceType = $expectedResourceType;

0 commit comments

Comments
 (0)
0