public function SearchApiAlgoliaBackend::deleteItems in Search API Algolia 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::deleteItems()
- 3.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::deleteItems()
File
- src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php, line 372
Class
- SearchApiAlgoliaBackend
- Class SearchApiAlgoliaBackend.
Namespace
Drupal\search_api_algolia\Plugin\search_api\backendCode
public function deleteItems(IndexInterface $index, array $ids) {
// Deleting all items included in the $ids array.
if ($this->languageManager
->isMultilingual()) {
foreach ($this->languageManager
->getLanguages() as $language) {
try {
// Connect to the Algolia index for specific language.
$this
->connect($index, '', $language
->getId());
} catch (\Exception $e) {
$this
->getLogger()
->error('Failed to connect to Algolia index while deleting indexed items, Error: @message', [
'@message' => $e
->getMessage(),
]);
return;
}
$response = $this
->getAlgoliaIndex()
->deleteObjects($ids);
$this
->getLogger()
->notice('Deletion requested for IDs: @ids on Algolia for Language: @language, Response: @response.', [
'@response' => json_encode($response),
'@language' => $language
->getId(),
'@ids' => implode(',', $ids),
]);
}
}
else {
// Connect to the Algolia index.
try {
$this
->connect($index);
} catch (\Exception $e) {
$this
->getLogger()
->error('Failed to connect to Algolia index while deleting indexed items, Error: @message', [
'@message' => $e
->getMessage(),
]);
return;
}
$response = $this
->getAlgoliaIndex()
->deleteObjects($ids);
$this
->getLogger()
->notice('Deletion requested for IDs: @ids on Algolia. Response: @response.', [
'@response' => json_encode($response),
'@ids' => implode(',', $ids),
]);
}
}