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\Schema\Container; |
24
|
|
|
use Reva2\JsonApi\Services\Environment; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* JSON API factory |
28
|
|
|
* |
29
|
|
|
* @package Reva2\JsonApi\Factories |
30
|
|
|
* @author Sergey Revenko <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class Factory extends BaseFactory implements FactoryInterface |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @inheritdoc |
36
|
2 |
|
*/ |
37
|
|
|
public function createEncoder(ContainerInterface $container, EncoderOptions $encoderOptions = null) |
38
|
2 |
|
{ |
39
|
2 |
|
$encoder = new Encoder($this, $container, $encoderOptions); |
40
|
|
|
$encoder->setLogger($this->logger); |
41
|
2 |
|
|
42
|
|
|
return $encoder; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritdoc |
47
|
4 |
|
*/ |
48
|
|
|
public function createHeadersChecker(CodecMatcherInterface $codecMatcher) |
49
|
4 |
|
{ |
50
|
|
|
return new HeadersChecker($codecMatcher); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritdoc |
55
|
2 |
|
*/ |
56
|
|
|
public function createEnvironment(array $config = null) |
57
|
2 |
|
{ |
58
|
|
|
return new Environment($config); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @inheritdoc |
63
|
3 |
|
*/ |
64
|
|
|
public function createRequest(EnvironmentInterface $environment) |
65
|
3 |
|
{ |
66
|
|
|
return new Request($environment); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @inheritdoc |
71
|
2 |
|
*/ |
72
|
|
|
public function createQueryParametersParser() |
73
|
2 |
|
{ |
74
|
|
|
return new QueryParametersParser(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @inheritdoc |
79
|
|
|
*/ |
80
|
|
|
public function createContainer(array $providers = []) |
81
|
|
|
{ |
82
|
|
|
$container = new Container($this, $providers); |
83
|
|
|
$container->setLogger($this->logger); |
84
|
|
|
|
85
|
|
|
return $container; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|