1 | <?php |
||||
2 | |||||
3 | namespace Mdiyakov\DoctrineSolrBundle\Config; |
||||
4 | |||||
5 | use Mdiyakov\DoctrineSolrBundle\Schema\Schema; |
||||
6 | |||||
7 | class Config |
||||
8 | { |
||||
9 | |||||
10 | /** |
||||
11 | * @var \string[][] |
||||
12 | */ |
||||
13 | private $indexedEntities; |
||||
14 | |||||
15 | /** |
||||
16 | * @var Schema[] |
||||
17 | */ |
||||
18 | private $entitySchemaMap = []; |
||||
19 | |||||
20 | /** |
||||
21 | * @var string[] |
||||
22 | */ |
||||
23 | private $entitiesClasses = []; |
||||
24 | |||||
25 | /** |
||||
26 | * @var Schema[] |
||||
27 | */ |
||||
28 | private $schemes = []; |
||||
29 | |||||
30 | /** |
||||
31 | * @var array|\string[][] |
||||
32 | */ |
||||
33 | private $filters = []; |
||||
34 | |||||
35 | /** |
||||
36 | * @var array |
||||
37 | */ |
||||
38 | private $entitiesConfigMap = []; |
||||
39 | |||||
40 | /** |
||||
41 | * @var \string[] |
||||
42 | */ |
||||
43 | private $solariumClients; |
||||
44 | |||||
45 | /** |
||||
46 | * @param string[][] $indexedEntities |
||||
47 | * @param string[][] $schemes |
||||
48 | * @param string[][] $filters |
||||
49 | * @param string[] $solariumClients |
||||
50 | */ |
||||
51 | public function __construct($indexedEntities, $schemes, $filters, $solariumClients) |
||||
52 | { |
||||
53 | $configValidator = new ConfigValidator(); |
||||
54 | foreach ($indexedEntities as $entityConfig) { |
||||
55 | $schemaName = $entityConfig['schema']; |
||||
56 | $configValidator->validate($entityConfig, $schemes, $filters, $solariumClients); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
57 | |||||
58 | /** todo should be moved to some SchemaProvider class */ |
||||
59 | if (!isset($this->schemes[$schemaName])) { |
||||
60 | $schema = new Schema( |
||||
61 | $schemaName, |
||||
62 | $schemes[$schemaName]['client'], |
||||
63 | $schemes[$schemaName]['document_unique_field'], |
||||
0 ignored issues
–
show
$schemes[$schemaName]['document_unique_field'] of type string is incompatible with the type string[] expected by parameter $documentUniqueFieldConfig of Mdiyakov\DoctrineSolrBun...a\Schema::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
64 | $schemes[$schemaName]['fields'], |
||||
0 ignored issues
–
show
$schemes[$schemaName]['fields'] of type string is incompatible with the type array<mixed,string[]> expected by parameter $fieldsConfig of Mdiyakov\DoctrineSolrBun...a\Schema::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
65 | $schemes[$schemaName]['config_entity_fields'] |
||||
0 ignored issues
–
show
$schemes[$schemaName]['config_entity_fields'] of type string is incompatible with the type array<mixed,string[]> expected by parameter $configEntityFields of Mdiyakov\DoctrineSolrBun...a\Schema::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
66 | ); |
||||
67 | $this->schemes[$schemaName] = $schema; |
||||
68 | } |
||||
69 | |||||
70 | $this->entitySchemaMap[$entityConfig['class']] = $schema; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
71 | $this->entitiesClasses[$entityConfig['class']] = true; |
||||
72 | $this->entitiesConfigMap[$entityConfig['class']] = $entityConfig; |
||||
73 | } |
||||
74 | |||||
75 | $this->filters = $filters; |
||||
76 | $this->indexedEntities = $indexedEntities; |
||||
0 ignored issues
–
show
It seems like
$indexedEntities of type array<mixed,string[]> is incompatible with the declared type array<mixed,string[]> of property $indexedEntities .
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.. ![]() |
|||||
77 | $this->solariumClients = $solariumClients; |
||||
0 ignored issues
–
show
It seems like
$solariumClients of type string[] is incompatible with the declared type string[] of property $solariumClients .
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.. ![]() |
|||||
78 | } |
||||
79 | |||||
80 | /** |
||||
81 | * @param string $class |
||||
82 | * @return Schema|null |
||||
83 | */ |
||||
84 | public function getSchemaByEntityClass($class) |
||||
85 | { |
||||
86 | if (array_key_exists($class, $this->entitySchemaMap)) { |
||||
87 | return $this->entitySchemaMap[$class]; |
||||
88 | } |
||||
89 | |||||
90 | return null; |
||||
91 | } |
||||
92 | |||||
93 | |||||
94 | /** |
||||
95 | * @param string $schemaName |
||||
96 | * @return Schema|null |
||||
97 | */ |
||||
98 | public function getSchemaByName($schemaName) |
||||
99 | { |
||||
100 | if (array_key_exists($schemaName, $this->schemes)) { |
||||
101 | return $this->schemes[$schemaName]; |
||||
102 | } |
||||
103 | |||||
104 | return null; |
||||
105 | } |
||||
106 | |||||
107 | /** |
||||
108 | * @param string $class |
||||
109 | * @return string|null |
||||
110 | * |
||||
111 | */ |
||||
112 | public function getClientByEntityClass($class) |
||||
113 | { |
||||
114 | return array_key_exists($class, $this->entityClientMap) ? $this->entityClientMap[$class] : null; |
||||
0 ignored issues
–
show
|
|||||
115 | } |
||||
116 | |||||
117 | /** |
||||
118 | * @param $class |
||||
119 | * @return null|\string[][] |
||||
120 | */ |
||||
121 | public function getEntityConfig($class) |
||||
122 | { |
||||
123 | return array_key_exists($class, $this->entitiesConfigMap) ? $this->entitiesConfigMap[$class] : null; |
||||
124 | } |
||||
125 | |||||
126 | /** |
||||
127 | * @return string[] |
||||
128 | */ |
||||
129 | public function getIndexedClasses() |
||||
130 | { |
||||
131 | return array_keys($this->entitiesClasses); |
||||
132 | } |
||||
133 | |||||
134 | /** |
||||
135 | * @return array |
||||
136 | */ |
||||
137 | public function getIndexedEntities() |
||||
138 | { |
||||
139 | return $this->indexedEntities; |
||||
140 | } |
||||
141 | |||||
142 | /** |
||||
143 | * @return array|\string[][] |
||||
144 | */ |
||||
145 | public function getFilters() |
||||
146 | { |
||||
147 | return $this->filters; |
||||
148 | } |
||||
149 | |||||
150 | /** |
||||
151 | * @param string $clientName |
||||
152 | * @return null|string |
||||
153 | */ |
||||
154 | public function getSolariumClient($clientName) |
||||
155 | { |
||||
156 | return (array_key_exists($clientName, $this->solariumClients)) ? $this->solariumClients[$clientName] : null; |
||||
0 ignored issues
–
show
|
|||||
157 | } |
||||
158 | } |