public function CommandHelper::disableServerCommand in Search API 8
Disables a server.
Parameters
string $serverId: The server's ID.
Throws
\Drupal\search_api\ConsoleException Thrown if the server couldn't be loaded.
\Drupal\Core\Entity\EntityStorageException Thrown if an internal error occurred when saving the server.
File
- src/
Utility/ CommandHelper.php, line 572
Class
- CommandHelper
- Provides functionality to be used by CLI tools.
Namespace
Drupal\search_api\UtilityCode
public function disableServerCommand($serverId) {
$servers = $this
->loadServers([
$serverId,
]);
if (empty($servers)) {
throw new ConsoleException($this
->t('The server could not be loaded.'));
}
/** @var \Drupal\search_api\ServerInterface $server */
$server = $this
->reloadEntityOverrideFree(reset($servers));
$server
->setStatus(FALSE)
->save();
}