Skip to content

Commit 6029971

Browse files
committed
MAGE-938 Call out exceptions in interface
1 parent 0415eb2 commit 6029971

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

Api/Product/ReplicaManagerInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ interface ReplicaManagerInterface
2828
*/
2929
public function syncReplicasToAlgolia(int $storeId, array $primaryIndexSettings): void;
3030

31+
/**
32+
* Delete the replica indices on a store index
33+
* @param int $storeId
34+
* @param bool $unused Defaults to false - if true identifies any straggler indices and deletes those, otherwise deletes the replicas it knows aobut
35+
* @return void
36+
*
37+
* @throws LocalizedException
38+
* @throws AlgoliaException
39+
*/
3140
public function deleteReplicasFromAlgolia(int $storeId, bool $unused = false): void;
3241

3342
/**

Console/Command/ReplicaDeleteCommand.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Algolia\AlgoliaSearch\Console\Command;
44

55
use Algolia\AlgoliaSearch\Api\Product\ReplicaManagerInterface;
6+
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
67
use Algolia\AlgoliaSearch\Exceptions\BadRequestException;
78
use Algolia\AlgoliaSearch\Service\StoreNameFetcher;
89
use Magento\Framework\Console\Cli;
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Exception\NoSuchEntityException;
912
use Magento\Store\Model\StoreManagerInterface;
1013
use Symfony\Component\Console\Command\Command;
1114
use Symfony\Component\Console\Input\InputArgument;
@@ -62,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6265
{
6366
$this->output = $output;
6467
$this->input = $input;
65-
68+
6669
$storeIds = (array) $input->getArgument(self::STORE_ARGUMENT);
6770
$unused = $input->getOption(self::UNUSED_OPTION);
6871

@@ -136,6 +139,11 @@ protected function confirmDeleteUnused(array $unusedReplicas): bool
136139
return true;
137140
}
138141

142+
/**
143+
* @throws NoSuchEntityException
144+
* @throws AlgoliaException
145+
* @throws LocalizedException
146+
*/
139147
protected function deleteReplicas(array $storeIds = [], bool $unused = false): void
140148
{
141149
if (count($storeIds)) {
@@ -147,12 +155,22 @@ protected function deleteReplicas(array $storeIds = [], bool $unused = false): v
147155
}
148156
}
149157

158+
/**
159+
* @throws NoSuchEntityException
160+
* @throws LocalizedException
161+
* @throws AlgoliaException
162+
*/
150163
protected function deleteReplicasForStore(int $storeId, bool $unused = false): void
151164
{
152165
$this->output->writeln('<info>Deleting' . ($unused ? ' unused ': ' ') . 'replicas for ' . $this->storeNameFetcher->getStoreName($storeId) . '...</info>');
153166
$this->replicaManager->deleteReplicasFromAlgolia($storeId, $unused);
154167
}
155168

169+
/**
170+
* @throws NoSuchEntityException
171+
* @throws LocalizedException
172+
* @throws AlgoliaException
173+
*/
156174
protected function deleteReplicasForAllStores(bool $unused = false): void
157175
{
158176
$storeIds = array_keys($this->storeManager->getStores());

Service/Product/ReplicaManager.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ protected function clearReplicasSettingInAlgolia(string $primaryIndexName): void
423423
}
424424

425425
/**
426-
* @throws AlgoliaException
427-
* @throws NoSuchEntityException
428-
* @throws LocalizedException
426+
* @inheritDoc
429427
*/
430428
public function deleteReplicasFromAlgolia(int $storeId, bool $unused = false): void
431429
{

0 commit comments

Comments
 (0)