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\Request; |
22
|
|
|
use Reva2\JsonApi\Services\Environment; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* JSON API factory |
26
|
|
|
* |
27
|
|
|
* @package Reva2\JsonApi\Factories |
28
|
|
|
* @author Sergey Revenko <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class Factory extends BaseFactory implements FactoryInterface |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @inheritdoc |
34
|
|
|
*/ |
35
|
2 |
|
public function createEncoder(ContainerInterface $container, EncoderOptions $encoderOptions = null) |
36
|
|
|
{ |
37
|
2 |
|
$encoder = new Encoder($this, $container, $encoderOptions); |
38
|
2 |
|
$encoder->setLogger($this->logger); |
39
|
|
|
|
40
|
2 |
|
return $encoder; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritdoc |
45
|
|
|
*/ |
46
|
1 |
|
public function createHeadersChecker(CodecMatcherInterface $codecMatcher) |
47
|
|
|
{ |
48
|
1 |
|
return new HeadersChecker($codecMatcher); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @inheritdoc |
53
|
|
|
*/ |
54
|
2 |
|
public function createEnvironment(array $config = null) |
55
|
|
|
{ |
56
|
2 |
|
return new Environment($config); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdoc |
61
|
|
|
*/ |
62
|
|
|
public function createRequest(EnvironmentInterface $environment) |
63
|
|
|
{ |
64
|
|
|
return new Request($environment); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|