8000 Updates based on new versions of depedencies. · nelson6e65/laravel-json-api@703e50e · GitHub
[go: up one dir, main page]

Skip to content

Commit 703e50e

Browse files
committed
Updates based on new versions of depedencies.
1 parent 23f7eba commit 703e50e

17 files changed

+315
-508
lines changed

README.md

Lines changed: 94 additions & 43 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"php": ">=5.5.0",
2626
"neomerx/json-api": "dev-develop",
2727
"illuminate/support": "^5.0",
28-
"cloudcreativity/json-api": "dev-master",
29-
"illuminate/routing": "^5.0"
28+
"cloudcreativity/json-api": "dev-develop",
29+
"illuminate/routing": "^5.1"
3030
},
3131
"require-dev": {
3232
"phpunit/phpunit": "^4.7"

config/json-api-advanced.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

config/json-api.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3+
use CloudCreativity\JsonApi\Config as C;
4+
use CloudCreativity\JsonApi\Contracts\Error\ErrorObjectInterface as Error;
35
use CloudCreativity\JsonApi\Contracts\Repositories\CodecMatcherRepositoryInterface as Codec;
4-
use CloudCreativity\JsonApi\Contracts\Repositories\EncodersRepositoryInterface as Enc;
5-
use CloudCreativity\JsonApi\Contracts\Repositories\DecodersRepositoryInterface as Dec;
6+
use CloudCreativity\JsonApi\Contracts\Repositories\SchemasRepositoryInterface as Schemas;
7+
use CloudCreativity\JsonApi\Decoders\DocumentDecoder;
68
use CloudCreativity\JsonApi\Exceptions\StandardRenderer as Renderer;
7-
use CloudCreativity\JsonApi\Contracts\Error\ErrorObjectInterface as Error;
8-
use CloudCreativity\JsonApi\Config as C;
99

1010
return [
1111

@@ -20,21 +20,27 @@
2020
* Codec Matchers
2121
*/
2222
C::CODEC_MATCHER => [
23-
// @todo
24-
],
25-
26-
/**
27-
* Encoders
28-
*/
29-
C::ENCODERS => [
30-
// @todo
23+
Codec::ENCODERS => [
24+
'application/vnd.api+json',
25+
'text/plain' => JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
26+
],
27+
Codec::DECODERS => [
28+
'application/vnd.api+json' => DocumentDecoder::class,
29+
],
3130
],
3231

3332
/**
34-
* Decoders
33+
* Schemas
3534
*/
36-
C::DECODERS => [
37-
// @todo
35+
C::SCHEMAS => [
36+
Schemas::DEFAULTS => [
37+
'Article' => 'ArticleSchema',
38+
'Comment' => 'CommentSchema',
39+
],
40+
// merged with defaults if JSON API middleware uses the 'extra-schemas' name.
41+
'extra-schemas' => [
42+
'Person' => 'PersonSchema',
43+
],
3844
],
3945

4046
/**

src/Config.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ class Config
1818
/** The key for codec matchers configuration */
1919
const CODEC_MATCHER = 'codec-matcher';
2020

21-
/** The key for encoders configuration */
22-
const ENCODERS = 'encoders';
23-
24-
/** The key for decoders configuration */
25-
const DECODERS = 'decoders';
21+
/** The key for the schemas configuration */
22+
const SCHEMAS = 'schemas';
2623

2724
/** The key for Exception Renderer Containe F438 r config */
2825
const EXCEPTIONS = 'exceptions';

src/Exceptions/HandlerTrait.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
use App;
66
use CloudCreativity\JsonApi\Contracts\Encoder\EncoderAwareInterface;
7+
use CloudCreativity\JsonApi\Contracts\Integration\EnvironmentInterface;
78
use Exception;
89
use Illuminate\Http\Response;
9-
use JsonApi;
10-
use Neomerx\JsonApi\Contracts\Codec\CodecMatcherInterface;
1110
use Neomerx\JsonApi\Contracts\Exceptions\RendererContainerInterface;
12-
use Neomerx\JsonApi\Contracts\Parameters\SupportedExtensionsInterface;
1311

1412
trait HandlerTrait
1513
{
@@ -19,7 +17,10 @@ trait HandlerTrait
1917
*/
2018
public function isJsonApi()
2119
{
22-
return JsonApi::isActive();
20+
/** @var EnvironmentInterface $environment */
21+
$environment = App::make(EnvironmentInterface::class);
22+
23+
return $environment->hasSchemas();
2324
}
2425

2526
/**
@@ -29,37 +30,32 @@ public function isJsonApi()
2930
*/
3031
public function renderJsonApi($request, Exception $e)
3132
{
32-
/** @var RendererContainerInterface $renderContainer */
33-
$renderContainer = App::make(RendererContainerInterface::class);
34-
/** @var CodecMatcherInterface $codecMatcher */
35-
$codecMatcher = JsonApi::getCodecMatcher();
33+
/** @var RendererContainerInterface $rendererContainer */
34+
$rendererContainer = App::make(RendererContainerInterface::class);
35+
/** @var EnvironmentInterface $environment */
36+
$environment = App::make(EnvironmentInterface::class);
3637

3738
// If there is no encoder, then we bug out. The client doesn't accept a content type we can render.
38-
if (!$codecMatcher->getEncoder()) {
39+
if (!$environment->hasEncoder()) {
3940
return new Response(null, 406);
4041
}
4142

42-
$renderer = $renderContainer->getRenderer(get_class($e));
43+
$renderer = $rendererContainer->getRenderer(get_class($e));
4344

45+
// set encoder if needed
4446
if ($renderer instanceof EncoderAwareInterface) {
45-
$renderer->setEncoder($codecMatcher->getEncoder());
47+
$renderer->setEncoder($environment->getEncoder());
4648
}
4749

48-
/** @var SupportedExtensionsInterface|null $ext */
49-
$supportedExtensions = JsonApi::getSupportedExtensions();
50+
// set supported extensions if there are any
51+
$supportedExtensions = $environment->getSupportedExtensions();
5052

5153
if ($supportedExtensions) {
5254
$renderer->withSupportedExtensions($supportedExtensions);
5355
}
5456

55-
$contentType = $codecMatcher->getEncoderHeaderMatchedType();
56-
57-
if (!$contentType) {
58-
$contentType = $codecMatcher->getEncoderRegisteredMatchedType();
59-
}
60-
6157
return $renderer
62-
->withMediaType($contentType)
58+
->withMediaType($environment->getEncoderMediaType())
6359
->render($e);
6460
}
6561
}

src/Facade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace CloudCreativity\JsonApi;
44

5+
use CloudCreativity\JsonApi\Contracts\Integration\EnvironmentInterface;
56
use Illuminate\Support\Facades\Facade as BaseFacade;
6-
use CloudCreativity\JsonApi\Services\EnvironmentService;
77

88
class Facade extends BaseFacade
99
{
@@ -13,6 +13,6 @@ class Facade extends BaseFacade
1313
*/
1414
protected static function getFacadeAccessor()
1515
{
16-
return EnvironmentService::class;
16+
return EnvironmentInterface::class;
1717
}
1818
}

src/Http/Controllers/DocumentDecoderTrait.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
namespace CloudCreativity\JsonApi\Http\Controllers;
44

55
use App;
6+
use CloudCreativity\JsonApi\Contracts\Integration\EnvironmentInterface;
67
use CloudCreativity\JsonApi\Contracts\Object\Document\DocumentInterface;
78
use CloudCreativity\JsonApi\Contracts\Validator\ValidatorAwareInterface;
89
use CloudCreativity\JsonApi\Contracts\Validator\ValidatorInterface;
910
use CloudCreativity\JsonApi\Object\Document\Document;
1011
use CloudCreativity\JsonApi\Validator\Document\DocumentValidator;
1112
use Illuminate\Http\Request;
12-
use JsonApi;
13-
use Neomerx\JsonApi\Contracts\Codec\CodecMatcherInterface;
14-
use Neomerx\JsonApi\Contracts\Decoder\DecoderInterface;
1513
use RuntimeException;
1614

1715
/**
@@ -27,13 +25,9 @@ trait DocumentDecoderTrait
2725
*/
2826
public function getContentBody(ValidatorInterface $validator = null)
2927
{
30-
/** @var CodecMatcherInterface $codecMatcher */
31-
$codecMatcher = JsonApi::getCodecMatcher();
32-
$decoder = $codecMatcher->getDecoder();
33-
34-
if (!$decoder instanceof DecoderInterface) {
35-
throw new RuntimeException('A decoder should be set by now. Are you in a JSON API route?');
36-
}
28+
/** @var EnvironmentInterface $environment */
29+
$environment = App::make(EnvironmentInterface::class);
30+
$decoder = $environment->getDecoder();
3731

3832
if ($validator && !$decoder instanceof ValidatorAwareInterface) {
3933
throw new RuntimeException('To use a validator on content body, your decoder must implement the ValidatorAwareInterface.');

src/Http/Controllers/QueryCheckerTrait.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace CloudCreativity\JsonApi\Http\Controllers;
44

55
use App;
6-
use JsonApi;
6+
use CloudCreativity\JsonApi\Contracts\Integration\EnvironmentInterface;
77
use Neomerx\JsonApi\Contracts\Integration\ExceptionThrowerInterface;
8+
use Neomerx\JsonApi\Contracts\Parameters\ParametersFactoryInterface;
89
use Neomerx\JsonApi\Contracts\Parameters\ParametersInterface;
910
use Neomerx\JsonApi\Contracts\Parameters\QueryCheckerInterface;
10-
use Neomerx\JsonApi\Contracts\Parameters\ParametersFactoryInterface;
1111

1212
/**
1313
* Class QueryCheckerTrait
@@ -103,7 +103,10 @@ public function getQueryChecker()
103103
*/
104104
public function getParameters()
105105
{
106-
return JsonApi::getParameters();
106+
/** @var EnvironmentInterface $environment */
107+
$environment= App::make(EnvironmentInterface::class);
108+
109+
return $environment->getParameters();
107110
}
108111

109112
/**

0 commit comments

Comments
 (0)
0