function domain_config_ui_admin_form in Domain Access 8
Generates the markup for the AJAX admin action.
Parameters
string $op: An operation: either 'enable' or 'disable' are allowed.
1 call to domain_config_ui_admin_form()
- 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 47 - Allows saving of domain specific configuration through the UI.
Code
function domain_config_ui_admin_form($op) {
$admin_form = [];
if (\Drupal::currentUser()
->hasPermission('administer domain config ui')) {
$route = \Drupal::routeMatch()
->getRouteObject();
// We make a special exception for the themes overview, which is unique.
// @TODO: make this list extensible.
$special_form = FALSE;
$special_paths = [
'/admin/appearance',
'/admin/appearance/settings',
'/admin/appearance/settings/{theme}',
];
if (in_array($route
->getPath(), $special_paths, TRUE)) {
$special_form = TRUE;
}
if ($route
->hasDefault('_form') || $special_form) {
$base_form = $route
->getDefault('_form');
if ($special_form || is_callable($base_form, TRUE) && method_exists($base_form, 'getEditableConfigNames')) {
$params = [
'op' => $op,
'route_name' => \Drupal::routeMatch()
->getRouteName(),
];
foreach (\Drupal::routeMatch()
->getRawParameters() as $key => $value) {
$params[$key] = $value;
}
$title = new TranslatableMarkup('Enable domain configuration');
if ($op == 'disable') {
$title = new TranslatableMarkup('Disable domain configuration');
}
$admin_form = [
'#type' => 'link',
'#url' => Url::fromRoute('domain_config_ui.inline_action', $params),
'#title' => $title,
'#attributes' => [
'class' => [
'button',
'button--primary',
'button--small',
],
],
'#prefix' => '<p>',
'#suffix' => '</p>',
'#weight' => -10,
];
}
}
}
return $admin_form;
}