1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Elasticsearch\Framework\Indexing; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\Feature; |
6
|
|
|
use Shopware\Core\Framework\Log\Package; |
7
|
|
|
use Shopware\Elasticsearch\Framework\AbstractElasticsearchDefinition; |
8
|
|
|
|
9
|
|
|
#[Package('core')] |
10
|
|
|
class IndexerOffset |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var list<string> |
|
|
|
|
14
|
|
|
*/ |
15
|
|
|
protected array $definitions; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var list<string> |
19
|
|
|
*/ |
20
|
|
|
protected array $allDefinitions; |
21
|
|
|
|
22
|
|
|
protected ?string $languageId = null; |
23
|
|
|
|
24
|
|
|
protected ?string $definition = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param list<string> $languages |
28
|
|
|
* @param iterable<AbstractElasticsearchDefinition> $definitions |
29
|
|
|
* @param array{offset: int|null}|null $lastId |
30
|
|
|
*/ |
31
|
|
|
public function __construct( |
32
|
|
|
protected array $languages, |
33
|
|
|
iterable $definitions, |
34
|
|
|
protected ?int $timestamp, |
35
|
|
|
protected ?array $lastId = null |
36
|
|
|
) { |
37
|
|
|
$mapping = []; |
38
|
|
|
/** @var AbstractElasticsearchDefinition $definition */ |
39
|
|
|
foreach ($definitions as $definition) { |
40
|
|
|
$mapping[] = $definition->getEntityDefinition()->getEntityName(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$this->allDefinitions = $mapping; |
|
|
|
|
44
|
|
|
$this->definitions = $mapping; |
|
|
|
|
45
|
|
|
|
46
|
|
|
$this->selectNextLanguage(); |
47
|
|
|
$this->selectNextDefinition(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @deprecated tag:v6.6.0 - Will be removed. Use selectNextDefinition instead |
52
|
|
|
* |
53
|
|
|
* @phpstan-ignore-next-line ignore needs to be removed when deprecation is removed |
54
|
|
|
*/ |
55
|
|
|
public function setNextDefinition(): ?string |
56
|
|
|
{ |
57
|
|
|
Feature::triggerDeprecationOrThrow( |
58
|
|
|
'v6.6.0.0', |
59
|
|
|
Feature::deprecatedMethodMessage(__CLASS__, __METHOD__, 'v6.6.0.0', 'selectNextDefinition') |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
return $this->selectNextDefinition(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function selectNextDefinition(): ?string |
66
|
|
|
{ |
67
|
|
|
return $this->definition = array_shift($this->definitions); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function resetDefinitions(): void |
71
|
|
|
{ |
72
|
|
|
$this->definitions = $this->allDefinitions; |
|
|
|
|
73
|
|
|
$this->definition = array_shift($this->definitions); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function hasNextDefinition(): bool |
77
|
|
|
{ |
78
|
|
|
return !empty($this->definitions); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @deprecated tag:v6.6.0 - Will be removed. Use selectNextLanguage instead |
83
|
|
|
* |
84
|
|
|
* @phpstan-ignore-next-line ignore needs to be removed when deprecation is removed |
85
|
|
|
*/ |
86
|
|
|
public function setNextLanguage(): ?string |
87
|
|
|
{ |
88
|
|
|
Feature::triggerDeprecationOrThrow( |
89
|
|
|
'v6.6.0.0', |
90
|
|
|
Feature::deprecatedMethodMessage(__CLASS__, __METHOD__, 'v6.6.0.0', 'selectNextLanguage') |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
return $this->selectNextLanguage(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function selectNextLanguage(): ?string |
97
|
|
|
{ |
98
|
|
|
return $this->languageId = array_shift($this->languages); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function hasNextLanguage(): bool |
102
|
|
|
{ |
103
|
|
|
return !empty($this->languages); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function getLanguageId(): ?string |
107
|
|
|
{ |
108
|
|
|
return $this->languageId; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return list<string> |
113
|
|
|
*/ |
114
|
|
|
public function getLanguages(): array |
115
|
|
|
{ |
116
|
|
|
return $this->languages; |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return list<string> |
121
|
|
|
*/ |
122
|
|
|
public function getDefinitions(): array |
123
|
|
|
{ |
124
|
|
|
return $this->definitions; |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function getTimestamp(): ?int |
128
|
|
|
{ |
129
|
|
|
return $this->timestamp; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return array{offset: int|null}|null |
134
|
|
|
*/ |
135
|
|
|
public function getLastId(): ?array |
136
|
|
|
{ |
137
|
|
|
return $this->lastId; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getDefinition(): ?string |
141
|
|
|
{ |
142
|
|
|
return $this->definition; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param array{offset: int|null}|null $lastId |
147
|
|
|
*/ |
148
|
|
|
public function setLastId(?array $lastId): void |
149
|
|
|
{ |
150
|
|
|
$this->lastId = $lastId; |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
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