function drush_search_api_disable in Search API 7
Same name and namespace in other branches
- 8 search_api.drush.inc \drush_search_api_disable()
Disable index(es).
Parameters
string|integer $index_id: The index name or id which should be disabled.
File
- ./
search_api.drush.inc, line 277 - Drush commands for SearchAPI.
Code
function drush_search_api_disable($index_id = NULL) {
if (search_api_drush_static(__FUNCTION__)) {
return;
}
$indexes = search_api_drush_get_index($index_id);
if (empty($indexes)) {
return;
}
foreach ($indexes as $index) {
$vars = array(
'!index' => $index->name,
);
if ($index->enabled) {
$success = FALSE;
try {
if ($success = search_api_index_disable($index->id)) {
drush_log(dt("The index !index was successfully disabled.", $vars), 'ok');
}
} catch (SearchApiException $e) {
drush_log($e
->getMessage(), 'error');
}
if (!$success) {
drush_log(dt("Error disabling index !index.", $vars), 'error');
}
}
else {
drush_log(dt("The index !index is already disabled.", $vars), 'error');
}
}
}