|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the reva2/jsonapi. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Sergey Revenko <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Reva2\JsonApi\Factories; |
|
12
|
|
|
|
|
13
|
|
|
use Neomerx\JsonApi\Contracts\Codec\CodecMatcherInterface; |
|
14
|
|
|
use Neomerx\JsonApi\Contracts\Schema\ContainerInterface; |
|
15
|
|
|
use Neomerx\JsonApi\Encoder\EncoderOptions; |
|
16
|
|
|
use Neomerx\JsonApi\Factories\Factory as BaseFactory; |
|
17
|
|
|
use Reva2\JsonApi\Contracts\Factories\FactoryInterface; |
|
18
|
|
|
use Reva2\JsonApi\Contracts\Services\EnvironmentInterface; |
|
19
|
|
|
use Reva2\JsonApi\Encoder\Encoder; |
|
20
|
|
|
use Reva2\JsonApi\Http\Headers\HeadersChecker; |
|
21
|
|
|
use Reva2\JsonApi\Http\Query\QueryParametersParser; |
|
22
|
|
|
use Reva2\JsonApi\Http\Request; |
|
23
|
|
|
use Reva2\JsonApi\Services\Environment; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* JSON API factory |
|
27
|
|
|
* |
|
28
|
|
|
* @package Reva2\JsonApi\Factories |
|
29
|
|
|
* @author Sergey Revenko <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class Factory extends BaseFactory implements FactoryInterface |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @inheritdoc |
|
35
|
|
|
*/ |
|
36
|
2 |
|
public function createEncoder(ContainerInterface $container, EncoderOptions $encoderOptions = null) |
|
37
|
|
|
{ |
|
38
|
2 |
|
$encoder = new Encoder($this, $container, $encoderOptions); |
|
39
|
2 |
|
$encoder->setLogger($this->logger); |
|
40
|
|
|
|
|
41
|
2 |
|
return $encoder; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritdoc |
|
46
|
|
|
*/ |
|
47
|
4 |
|
public function createHeadersChecker(CodecMatcherInterface $codecMatcher) |
|
48
|
|
|
{ |
|
49
|
4 |
|
return new HeadersChecker($codecMatcher); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @inheritdoc |
|
54
|
|
|
*/ |
|
55
|
2 |
|
public function createEnvironment(array $config = null) |
|
56
|
|
|
{ |
|
57
|
2 |
|
return new Environment($config); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @inheritdoc |
|
62
|
|
|
*/ |
|
63
|
3 |
|
public function createRequest(EnvironmentInterface $environment) |
|
64
|
|
|
{ |
|
65
|
3 |
|
return new Request($environment); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @inheritdoc |
|
70
|
|
|
*/ |
|
71
|
2 |
|
public function createQueryParametersParser() |
|
72
|
|
|
{ |
|
73
|
2 |
|
return new QueryParametersParser(); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|