public function SearchApiAlgoliaBackend::viewSettings 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::viewSettings()
- 3.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::viewSettings()
File
- src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php, line 167
Class
- SearchApiAlgoliaBackend
- Class SearchApiAlgoliaBackend.
Namespace
Drupal\search_api_algolia\Plugin\search_api\backendCode
public function viewSettings() {
try {
$this
->connect();
} catch (\Exception $e) {
$this
->getLogger()
->warning('Could not connect to Algolia backend.');
}
$info = [];
// Application ID.
$info[] = [
'label' => $this
->t('Application ID'),
'info' => $this
->getApplicationId(),
];
// API Key.
$info[] = [
'label' => $this
->t('API Key'),
'info' => $this
->getApiKey(),
];
// Available indexes.
$indexes = $this
->getAlgolia()
->listIndexes();
$indexes_list = [];
if (isset($indexes['items'])) {
foreach ($indexes['items'] as $index) {
$indexes_list[] = $index['name'];
}
}
$info[] = [
'label' => $this
->t('Available Algolia indexes'),
'info' => implode(', ', $indexes_list),
];
return $info;
}