function domain_config_ui_preprocess_page in Domain Access 8
Implements hook_preprocess_page().
File
- domain_config_ui/
domain_config_ui.module, line 15 - Allows saving of domain specific configuration through the UI.
Code
function domain_config_ui_preprocess_page(&$variables) {
$content = [];
if (!domain_config_ui_route_is_admin()) {
return;
}
if (!domain_config_ui_path_is_registered()) {
$content = [
'domain_config_ui_admin' => domain_config_ui_admin_form('enable'),
];
}
else {
$content = [
'domain_config_ui_admin' => domain_config_ui_admin_form('disable'),
];
// Add a message below the form showing the current domain.
$form = \Drupal::formBuilder()
->getForm('Drupal\\domain_config_ui\\Form\\SwitchForm');
if (isset($form['domain_config_ui']['domain']['#options'])) {
$options = $form['domain_config_ui']['domain']['#options'];
}
if ($form['#access'] && ($warning_message = domain_config_ui_save_warning_message($options))) {
$content['domain_config_ui_switch_warning'] = $warning_message;
}
// Add domain switch form to the top of the content region.
$content['domain_config_ui_switch'] = $form;
}
if ($content) {
$variables['page']['content'] = array_merge($content, $variables['page']['content']);
}
}