function domain_config_ui_save_warning_message in Domain Access 8
Generates the markup for the domain save warning message.
Parameters
array $domain_options: The options for the domain element of the form.
1 call to domain_config_ui_save_warning_message()
- domain_config_ui_preprocess_page in domain_config_ui/
domain_config_ui.module - Implements hook_preprocess_page().
File
- domain_config_ui/
domain_config_ui.module, line 103 - Allows saving of domain specific configuration through the UI.
Code
function domain_config_ui_save_warning_message(array $domain_options = []) {
$manager = \Drupal::service('domain_config_ui.manager');
if ($selected_domain_id = $manager
->getSelectedDomainId()) {
$selected_domain = \Drupal::service('entity_type.manager')
->getStorage('domain')
->load($selected_domain_id);
}
if ($selected_language_id = $manager
->getSelectedLanguageId()) {
$selected_language = \Drupal::service('language_manager')
->getLanguage($selected_language_id);
}
$domain_label = !empty($selected_domain) ? new TranslatableMarkup('the @label domain', [
'@label' => $selected_domain
->label(),
]) : new TranslatableMarkup('all domains without custom configuration');
// In some cases, the user cannot use 'all domains.' In that case, we have to
// use the default option as a label.
if (empty($selected_domain) && !\Drupal::currentUser()
->hasPermission('set default domain configuration')) {
$label = current($domain_options);
$domain_label = new TranslatableMarkup('the @label domain', [
'@label' => $label,
]);
}
$languages = \Drupal::service('language_manager')
->getLanguages();
if (count($languages) > 1) {
$language_label = !empty($selected_language) ? $selected_language
->getName() : new TranslatableMarkup('all languages without custom configuration.');
}
else {
$language_label = !empty($selected_language) ? $selected_language
->getName() : new TranslatableMarkup('all languages.');
}
$message = new TranslatableMarkup('This configuration will be saved for @domain and displayed in @language', [
'@domain' => $domain_label,
'@language' => $language_label,
]);
return [
'#markup' => new FormattableMarkup('<div class="messages messages--warning">@message</div>', [
'@message' => $message,
]),
'#weight' => -1000,
];
}