1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* This file is part of Phpfastcache. |
5
|
|
|
* |
6
|
|
|
* @license MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files. |
9
|
|
|
* |
10
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
11
|
|
|
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
declare(strict_types=1); |
15
|
|
|
|
16
|
|
|
namespace Phpfastcache\Drivers\Solr; |
17
|
|
|
|
18
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
19
|
|
|
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
20
|
|
|
use Phpfastcache\Core\Pool\TaggableCacheItemPoolInterface; |
21
|
|
|
use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; |
22
|
|
|
use Phpfastcache\Exceptions\PhpfastcacheLogicException; |
23
|
|
|
use Psr\EventDispatcher\EventDispatcherInterface; |
|
|
|
|
24
|
|
|
|
25
|
|
|
class Config extends ConfigurationOption |
26
|
|
|
{ |
27
|
|
|
public const DEFAULT_MAPPING_SCHEMA = [ |
28
|
|
|
Driver::SOLR_DEFAULT_ID_FIELD => Driver::SOLR_DEFAULT_ID_FIELD, |
29
|
|
|
Driver::SOLR_DISCRIMINATOR_FIELD => Driver::SOLR_DISCRIMINATOR_FIELD . '_s', |
30
|
|
|
ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX => ExtendedCacheItemPoolInterface::DRIVER_KEY_WRAPPER_INDEX . '_s', |
31
|
|
|
ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX => ExtendedCacheItemPoolInterface::DRIVER_DATA_WRAPPER_INDEX . '_s', |
32
|
|
|
ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX => ExtendedCacheItemPoolInterface::DRIVER_EDATE_WRAPPER_INDEX . '_s', |
33
|
|
|
ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX => ExtendedCacheItemPoolInterface::DRIVER_MDATE_WRAPPER_INDEX . '_s', |
34
|
|
|
ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX => ExtendedCacheItemPoolInterface::DRIVER_CDATE_WRAPPER_INDEX . '_s', |
35
|
|
|
TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX => TaggableCacheItemPoolInterface::DRIVER_TAGS_WRAPPER_INDEX . '_ss', |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
protected string $host = '127.0.0.1'; |
39
|
|
|
|
40
|
|
|
protected int $port = 8983; |
41
|
|
|
|
42
|
|
|
protected string $coreName = 'phpfastcache'; |
43
|
|
|
|
44
|
|
|
protected string $endpointName = 'phpfastcache'; |
45
|
|
|
|
46
|
|
|
protected string $scheme = 'http'; |
47
|
|
|
|
48
|
|
|
protected string $path = '/'; // Override of ConfigurationOption |
49
|
|
|
|
50
|
|
|
protected array $mappingSchema = self::DEFAULT_MAPPING_SCHEMA; |
51
|
|
|
|
52
|
|
|
protected EventDispatcherInterface $eventDispatcher; |
53
|
|
|
|
54
|
|
|
public function __construct(array $parameters = []) |
55
|
|
|
{ |
56
|
|
|
$this->eventDispatcher = $this->getDefaultEventDispatcher(); |
57
|
|
|
parent::__construct($parameters); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getHost(): string |
64
|
|
|
{ |
65
|
|
|
return $this->host; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $host |
70
|
|
|
* @return Config |
71
|
|
|
* @throws PhpfastcacheLogicException |
72
|
|
|
*/ |
73
|
|
|
public function setHost(string $host): Config |
74
|
|
|
{ |
75
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
76
|
|
|
$this->host = $host; |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return int |
82
|
|
|
*/ |
83
|
|
|
public function getPort(): int |
84
|
|
|
{ |
85
|
|
|
return $this->port; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param int $port |
90
|
|
|
* @return Config |
91
|
|
|
* @throws PhpfastcacheLogicException |
92
|
|
|
*/ |
93
|
|
|
public function setPort(int $port): Config |
94
|
|
|
{ |
95
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
96
|
|
|
$this->port = $port; |
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getCoreName(): string |
104
|
|
|
{ |
105
|
|
|
return $this->coreName; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $coreName |
110
|
|
|
* @return Config |
111
|
|
|
* @throws PhpfastcacheLogicException |
112
|
|
|
*/ |
113
|
|
|
public function setCoreName(string $coreName): Config |
114
|
|
|
{ |
115
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
116
|
|
|
$this->coreName = $coreName; |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getScheme(): string |
124
|
|
|
{ |
125
|
|
|
return $this->scheme; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $scheme |
130
|
|
|
* @return Config |
131
|
|
|
* @throws PhpfastcacheLogicException |
132
|
|
|
*/ |
133
|
|
|
public function setScheme(string $scheme): Config |
134
|
|
|
{ |
135
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
136
|
|
|
$this->scheme = $scheme; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return EventDispatcherInterface |
142
|
|
|
*/ |
143
|
|
|
public function getEventDispatcher(): EventDispatcherInterface |
144
|
|
|
{ |
145
|
|
|
return $this->eventDispatcher; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return EventDispatcherInterface |
150
|
|
|
*/ |
151
|
|
|
protected function getDefaultEventDispatcher(): EventDispatcherInterface |
152
|
|
|
{ |
153
|
|
|
return new class implements EventDispatcherInterface { |
154
|
|
|
public function dispatch(object $event): object |
155
|
|
|
{ |
156
|
|
|
return $event; |
157
|
|
|
} |
158
|
|
|
}; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param EventDispatcherInterface $eventDispatcher |
163
|
|
|
* @return Config |
164
|
|
|
* @throws PhpfastcacheLogicException |
165
|
|
|
*/ |
166
|
|
|
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): Config |
167
|
|
|
{ |
168
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
169
|
|
|
$this->eventDispatcher = $eventDispatcher; |
170
|
|
|
return $this; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return string[] |
175
|
|
|
*/ |
176
|
|
|
public function getMappingSchema(): array |
177
|
|
|
{ |
178
|
|
|
return $this->mappingSchema; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param string[] $mappingSchema |
183
|
|
|
* @return Config |
184
|
|
|
* @throws PhpfastcacheLogicException |
185
|
|
|
* @throws PhpfastcacheInvalidArgumentException |
186
|
|
|
*/ |
187
|
|
|
public function setMappingSchema(array $mappingSchema): Config |
188
|
|
|
{ |
189
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
190
|
|
|
|
191
|
|
|
$diff = array_diff(array_keys(self::DEFAULT_MAPPING_SCHEMA), array_keys($mappingSchema)); |
192
|
|
|
|
193
|
|
|
if ($diff) { |
|
|
|
|
194
|
|
|
throw new PhpfastcacheInvalidArgumentException('Missing keys for the solr mapping schema: ' . \implode(', ', $diff)); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
$this->mappingSchema = $mappingSchema; |
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
|
|
public function getEndpointName(): string |
205
|
|
|
{ |
206
|
|
|
return $this->endpointName; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param string $endpointName |
211
|
|
|
* @return Config |
212
|
|
|
* @throws PhpfastcacheLogicException |
213
|
|
|
*/ |
214
|
|
|
public function setEndpointName(string $endpointName): Config |
215
|
|
|
{ |
216
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
217
|
|
|
$this->endpointName = $endpointName; |
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths