@@ -100,13 +100,12 @@ protected function clearAlgoliaReplicaSettingCache($primaryIndexName = null): vo
100
100
* relevant to the Magento integration
101
101
*
102
102
* @param string $primaryIndexName
103
- * @param int $storeId
104
103
* @return string[]
105
104
*/
106
105
protected function getMagentoReplicaConfigurationFromAlgolia (string $ primaryIndexName ): array
107
106
{
108
107
$ algoliaReplicas = $ this ->getReplicaConfigurationFromAlgolia ($ primaryIndexName );
109
- $ magentoReplicas = $ this ->getPossibleMagentoReplicaSettings ($ primaryIndexName , $ algoliaReplicas );
108
+ $ magentoReplicas = $ this ->getMagentoReplicaSettings ($ primaryIndexName , $ algoliaReplicas );
110
109
return array_values (array_intersect ($ magentoReplicas , $ algoliaReplicas ));
111
110
}
112
111
@@ -116,7 +115,7 @@ protected function getMagentoReplicaConfigurationFromAlgolia(string $primaryInde
116
115
* @param string[] $algoliaReplicas
117
116
* @return string[]
118
117
*/
119
- protected function getPossibleMagentoReplicaSettings (string $ baseIndexName , array $ algoliaReplicas ): array
118
+ protected function getMagentoReplicaSettings (string $ baseIndexName , array $ algoliaReplicas ): array
120
119
{
121
120
return array_filter (
122
121
$ algoliaReplicas ,
@@ -128,13 +127,12 @@ function ($algoliaReplicaSetting) use ($baseIndexName) {
128
127
129
128
/**
130
129
* @param string $primaryIndexName
131
- * @param int $storeId
132
130
* @return array
133
131
*/
134
- protected function getNonMagentoReplicaConfigurationFromAlgolia (string $ primaryIndexName, int $ storeId ): array
132
+ protected function getNonMagentoReplicaConfigurationFromAlgolia (string $ primaryIndexName ): array
135
133
{
136
134
$ algoliaReplicas = $ this ->getReplicaConfigurationFromAlgolia ($ primaryIndexName );
137
- $ magentoReplicas = $ this ->getPossibleMagentoReplicaSettings ($ primaryIndexName , $ algoliaReplicas );
135
+ $ magentoReplicas = $ this ->getMagentoReplicaSettings ($ primaryIndexName , $ algoliaReplicas );
138
136
return array_diff ($ algoliaReplicas , $ magentoReplicas );
139
137
}
140
138
@@ -176,7 +174,7 @@ function ($sort) use ($mode) {
176
174
* @throws LocalizedException
177
175
* @throws NoSuchEntityException
178
176
*/
179
- protected function getPossibleMagentoReplicaSettingsFromConfig (string $ primaryIndexName , int $ storeId , bool $ refreshCache = false ): array
177
+ protected function getMagentoReplicaSettingsFromConfig (string $ primaryIndexName , int $ storeId , bool $ refreshCache = false ): array
180
178
{
181
179
if ($ refreshCache || !isset ($ this ->_magentoReplicaPossibleConfig [$ storeId ])) {
182
180
$ sortConfig = $ this ->replicaState ->getChangeState ($ storeId ) === ReplicaState::REPLICA_STATE_CHANGED
@@ -205,19 +203,19 @@ public function handleReplicas(string $primaryIndexName, int $storeId, array $pr
205
203
}
206
204
207
205
/**
208
- * @param $primaryIndexName
206
+ * @param string $indexName
209
207
* @param int $storeId
210
208
* @return string[] Replicas added or modified by this operation
211
209
* @throws LocalizedException
212
210
* @throws NoSuchEntityException
213
211
* @throws AlgoliaException
214
212
*/
215
- protected function setReplicasOnPrimaryIndex ($ indexName , int $ storeId ): array
213
+ protected function setReplicasOnPrimaryIndex (string $ indexName , int $ storeId ): array
216
214
{
217
215
$ sortingIndices = $ this ->configHelper ->getSortingIndices ($ indexName , $ storeId );
218
216
$ newMagentoReplicasSetting = $ this ->transformSortingIndicesToReplicaSetting ($ sortingIndices );
219
- $ oldMagentoReplicasSetting = $ this ->getMagentoReplicaConfigurationFromAlgolia ($ indexName, $ storeId );
220
- $ nonMagentoReplicasSetting = $ this ->getNonMagentoReplicaConfigurationFromAlgolia ($ indexName, $ storeId );
217
+ $ oldMagentoReplicasSetting = $ this ->getMagentoReplicaConfigurationFromAlgolia ($ indexName );
218
+ $ nonMagentoReplicasSetting = $ this ->getNonMagentoReplicaConfigurationFromAlgolia ($ indexName );
221
219
$ oldMagentoReplicaIndices = $ this ->getBareIndexNamesFromReplicaSetting ($ oldMagentoReplicasSetting );
222
220
$ newMagentoReplicaIndices = $ this ->getBareIndexNamesFromReplicaSetting ($ newMagentoReplicasSetting );
223
221
@@ -267,6 +265,11 @@ protected function getBareIndexNameFromReplicaSetting(string $replicaSetting): s
267
265
return preg_replace ('/.*\((.*)\).*/ ' , '$1 ' , $ replicaSetting );
268
266
}
269
267
268
+ /**
269
+ * @param array $replicasToDelete
270
+ * @return void
271
+ * @throws AlgoliaException
272
+ */
270
273
protected function deleteReplicas (array $ replicasToDelete ): void
271
274
{
272
275
foreach ($ replicasToDelete as $ deletedReplica ) {
0 commit comments