public function ConfigSplitCliService::statusOverride in Configuration Split 2.0.x
Get and set status config overrides.
Parameters
string $name: The split name to override.
string|bool $status: The status to set.
\Drush\Style\DrushStyle|object $io: The $io interface of the cli tool calling.
callable $t: The translation function akin to t().
File
- src/
ConfigSplitCliService.php, line 226
Class
- ConfigSplitCliService
- The CLI service class for interoperability.
Namespace
Drupal\config_splitCode
public function statusOverride(string $name, $status, $io, callable $t) {
if ($this
->getSplitFromArgument($name, $io, $t) === NULL) {
return FALSE;
}
$map = [
NULL => 'none/default',
TRUE => 'active',
FALSE => 'inactive',
];
$settings = $this->statusOverride
->getSettingsOverride($name);
if ($settings !== NULL) {
$io
->caution($t('The status for @name is overridden in settings.php to @status', [
'@name' => $name,
'@status' => $map[$settings],
]));
}
if ($status === '') {
$state = $this->statusOverride
->getSplitOverride($name);
$io
->success($t('The status override for @name is @status', [
'@name' => $name,
'@status' => $map[$state],
]));
return TRUE;
}
switch (strtolower((string) $status)) {
case 'active':
case '1':
case 'true':
$state = TRUE;
break;
case 'inactive':
case '0':
case 'false':
$state = FALSE;
break;
case 'default':
case 'null':
case 'none':
$state = NULL;
break;
default:
throw new \InvalidArgumentException(sprintf('The status must be one of "active", "inactive", "default" or "none". %s given', $status));
}
$this->statusOverride
->setSplitOverride($name, $state);
$io
->success($t('The status override for @name was set to @status', [
'@name' => $name,
'@status' => $map[$state],
]));
return TRUE;
}