function drush_onlyone_enable_validate in Allow a content type only once (Only One) 8
Same name and namespace in other branches
- 7 onlyone.drush.inc \drush_onlyone_enable_validate()
Implements drush_hook_COMMAND_validate().
File
- ./
onlyone.drush.inc, line 186 - Drush commands related to the Only One module.
Code
function drush_onlyone_enable_validate() {
$args = func_get_args();
if (!_drush_onlyone_validate_content_type($args)) {
return;
}
$availables_content_types = array_keys(Drupal::service('onlyone')
->getAvailableContentTypes());
$not_available_content_types = array_diff($args, $availables_content_types);
if (count($not_available_content_types)) {
$names = implode(', ', $not_available_content_types);
$singular = "The following content type can't be configured in 'Only One content' mode: @names";
$plural = "The following content types can't be configured in 'Only One content' mode: @names";
$message = _onlyone_drush_plural(count($not_available_content_types), $singular, $plural, [
'@names' => $names,
]);
return drush_set_error('ONLYONE_NON_AVAILABLE_CONTENT_TYPE', $message);
}
}