1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bankiru\Api\Doctrine; |
4
|
|
|
|
5
|
|
|
use Bankiru\Api\Doctrine\Cache\CacheConfiguration; |
6
|
|
|
use Bankiru\Api\Doctrine\Cache\CacheConfigurationInterface; |
7
|
|
|
use Bankiru\Api\Doctrine\Type\TypeRegistryInterface; |
8
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; |
9
|
|
|
use Psr\Cache\CacheItemPoolInterface; |
10
|
|
|
use Psr\Log\LoggerInterface; |
11
|
|
|
use Psr\Log\NullLogger; |
12
|
|
|
|
13
|
|
|
class Configuration |
14
|
|
|
{ |
15
|
|
|
/** @var EntityMetadataFactory */ |
16
|
|
|
private $metadataFactory; |
17
|
|
|
/** @var MappingDriver */ |
18
|
|
|
private $driver; |
19
|
|
|
/** @var ClientRegistryInterface */ |
20
|
|
|
private $clientRegistry; |
21
|
|
|
/** @var ApiFactoryRegistryInterface */ |
22
|
|
|
private $factoryRegistry; |
23
|
|
|
/** @var string */ |
24
|
|
|
private $proxyDir; |
25
|
|
|
/** @var string */ |
26
|
|
|
private $proxyNamespace; |
27
|
|
|
/** @var bool */ |
28
|
|
|
private $autogenerateProxies = true; |
29
|
|
|
/** @var TypeRegistryInterface */ |
30
|
|
|
private $typeRegistry; |
31
|
|
|
/** @var array */ |
32
|
|
|
private $cacheConfiguration = []; |
33
|
|
|
/** @var CacheItemPoolInterface */ |
34
|
|
|
private $apiCache; |
35
|
|
|
/** @var LoggerInterface */ |
36
|
|
|
private $apiCacheLogger; |
37
|
|
|
/** @var CacheConfigurationInterface[] */ |
38
|
|
|
private $cacheConfigurationCache = []; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Configuration constructor. |
42
|
|
|
*/ |
43
|
25 |
|
public function __construct() |
44
|
|
|
{ |
45
|
25 |
|
$this->apiCacheLogger = new NullLogger(); |
46
|
25 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return ClientRegistryInterface |
50
|
|
|
*/ |
51
|
24 |
|
public function getClientRegistry() |
52
|
|
|
{ |
53
|
24 |
|
return $this->clientRegistry; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param ClientRegistryInterface $clientRegistry |
58
|
|
|
*/ |
59
|
25 |
|
public function setClientRegistry($clientRegistry) |
60
|
|
|
{ |
61
|
25 |
|
$this->clientRegistry = $clientRegistry; |
62
|
25 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return ApiFactoryRegistryInterface |
66
|
|
|
*/ |
67
|
23 |
|
public function getFactoryRegistry() |
68
|
|
|
{ |
69
|
23 |
|
return $this->factoryRegistry; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param ApiFactoryRegistryInterface $factoryRegistry |
74
|
|
|
*/ |
75
|
25 |
|
public function setFactoryRegistry(ApiFactoryRegistryInterface $factoryRegistry) |
76
|
|
|
{ |
77
|
25 |
|
$this->factoryRegistry = $factoryRegistry; |
78
|
25 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return LoggerInterface |
82
|
|
|
*/ |
83
|
1 |
|
public function getApiCacheLogger() |
84
|
|
|
{ |
85
|
1 |
|
return $this->apiCacheLogger; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param LoggerInterface $apiCacheLogger |
90
|
|
|
*/ |
91
|
1 |
|
public function setApiCacheLogger($apiCacheLogger) |
92
|
|
|
{ |
93
|
1 |
|
$this->apiCacheLogger = $apiCacheLogger; |
94
|
1 |
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return CacheItemPoolInterface |
98
|
|
|
*/ |
99
|
1 |
|
public function getApiCache() |
100
|
|
|
{ |
101
|
1 |
|
return $this->apiCache; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param CacheItemPoolInterface|null $apiCache |
106
|
|
|
*/ |
107
|
1 |
|
public function setApiCache(CacheItemPoolInterface $apiCache = null) |
108
|
|
|
{ |
109
|
1 |
|
$this->apiCache = $apiCache; |
110
|
1 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Returns class cache configuration |
114
|
|
|
* |
115
|
|
|
* @param $class |
116
|
|
|
* |
117
|
|
|
* @return CacheConfigurationInterface |
118
|
|
|
*/ |
119
|
24 |
|
public function getCacheConfiguration($class) |
120
|
|
|
{ |
121
|
24 |
|
if (!array_key_exists($class, $this->cacheConfiguration)) { |
122
|
23 |
|
return CacheConfiguration::disabled(); |
123
|
|
|
} |
124
|
|
|
|
125
|
1 |
|
if (!array_key_exists($class, $this->cacheConfigurationCache)) { |
126
|
1 |
|
$this->cacheConfigurationCache[$class] = CacheConfiguration::create($this->cacheConfiguration[$class]); |
127
|
1 |
|
} |
128
|
|
|
|
129
|
1 |
|
return $this->cacheConfigurationCache[$class]; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param string $class |
134
|
|
|
* @param array $options |
135
|
|
|
*/ |
136
|
1 |
|
public function setCacheConfiguration($class, array $options = null) |
137
|
|
|
{ |
138
|
1 |
|
$this->cacheConfiguration[$class] = $options; |
139
|
|
|
|
140
|
1 |
|
if (null === $this->cacheConfiguration[$class]) { |
141
|
|
|
unset($this->cacheConfiguration[$class]); |
142
|
|
|
} |
143
|
1 |
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* |
147
|
|
|
* |
148
|
|
|
* @param string $class |
149
|
|
|
* @param CacheConfigurationInterface $configuration |
150
|
|
|
*/ |
151
|
|
|
public function setCacheConfigurationInstance($class, CacheConfigurationInterface $configuration) |
152
|
|
|
{ |
153
|
|
|
$this->cacheConfigurationCache[$class] = $configuration; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return TypeRegistryInterface |
158
|
|
|
*/ |
159
|
23 |
|
public function getTypeRegistry() |
160
|
|
|
{ |
161
|
23 |
|
return $this->typeRegistry; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param TypeRegistryInterface $typeRegistry |
166
|
|
|
*/ |
167
|
25 |
|
public function setTypeRegistry(TypeRegistryInterface $typeRegistry) |
168
|
|
|
{ |
169
|
25 |
|
$this->typeRegistry = $typeRegistry; |
170
|
25 |
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return string |
174
|
|
|
*/ |
175
|
25 |
|
public function getProxyDir() |
176
|
|
|
{ |
177
|
25 |
|
return $this->proxyDir; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param string $proxyDir |
182
|
|
|
*/ |
183
|
25 |
|
public function setProxyDir($proxyDir) |
184
|
|
|
{ |
185
|
25 |
|
$this->proxyDir = $proxyDir; |
186
|
25 |
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return string |
190
|
|
|
*/ |
191
|
25 |
|
public function getProxyNamespace() |
192
|
|
|
{ |
193
|
25 |
|
return $this->proxyNamespace; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param string $proxyNamespace |
198
|
|
|
*/ |
199
|
25 |
|
public function setProxyNamespace($proxyNamespace) |
200
|
|
|
{ |
201
|
25 |
|
$this->proxyNamespace = $proxyNamespace; |
202
|
25 |
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return boolean |
206
|
|
|
*/ |
207
|
25 |
|
public function isAutogenerateProxies() |
208
|
|
|
{ |
209
|
25 |
|
return $this->autogenerateProxies; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param boolean $autogenerateProxies |
214
|
|
|
*/ |
215
|
|
|
public function setAutogenerateProxies($autogenerateProxies) |
216
|
|
|
{ |
217
|
|
|
$this->autogenerateProxies = $autogenerateProxies; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return MappingDriver |
222
|
|
|
*/ |
223
|
25 |
|
public function getDriver() |
224
|
|
|
{ |
225
|
25 |
|
return $this->driver; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param MappingDriver $driver |
230
|
|
|
*/ |
231
|
25 |
|
public function setDriver($driver) |
232
|
|
|
{ |
233
|
25 |
|
$this->driver = $driver; |
234
|
25 |
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return EntityMetadataFactory |
238
|
|
|
*/ |
239
|
25 |
|
public function getMetadataFactory() |
240
|
|
|
{ |
241
|
25 |
|
return $this->metadataFactory; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param string $metadataFactory |
246
|
|
|
*/ |
247
|
25 |
|
public function setMetadataFactory($metadataFactory) |
248
|
|
|
{ |
249
|
25 |
|
$this->metadataFactory = $metadataFactory; |
|
|
|
|
250
|
25 |
|
} |
251
|
|
|
} |
252
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..