public function DomainConfigSettingsForm::buildForm in Domain Site Settings 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ DomainConfigSettingsForm.php, line 90
Class
- DomainConfigSettingsForm
- Save domain config settings.
Namespace
Drupal\domain_site_settings\FormCode
public function buildForm(array $form, FormStateInterface $form_state, DomainInterface $domain = NULL) {
$config = $this
->config('domain_site_settings.domainconfigsettings');
$domain_id = $domain
->id();
$site_config = $this
->config('system.site');
$site_mail = $site_config
->get('mail');
if (empty($site_mail)) {
$site_mail = ini_get('sendmail_from');
}
if ($config
->get($domain_id) != NULL) {
$site_mail = $config
->get($domain_id . '.site_mail');
}
$form['site_information'] = [
'#type' => 'details',
'#title' => $this
->t('Site details'),
'#open' => TRUE,
];
$form['site_information']['site_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Site name'),
'#default_value' => $config
->get($domain_id) != NULL ? $config
->get($domain_id . '.site_name') : $site_config
->get('name'),
'#required' => TRUE,
];
$form['site_information']['site_slogan'] = [
'#type' => 'textfield',
'#title' => $this
->t('Slogan'),
'#default_value' => $config
->get($domain_id) != NULL ? $config
->get($domain_id . '.site_slogan') : $site_config
->get('slogan'),
'#description' => $this
->t("How this is used depends on your site's theme."),
];
$form['site_information']['site_mail'] = [
'#type' => 'email',
'#title' => $this
->t('Email address'),
'#default_value' => $site_mail,
'#description' => $this
->t("The <em>From</em> address in automated emails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this email being flagged as spam.)"),
'#required' => TRUE,
];
$form['front_page'] = [
'#type' => 'details',
'#title' => $this
->t('Front page'),
'#open' => TRUE,
];
$front_page = $site_config
->get('page.front') != '/user/login' ? $this->aliasManager
->getAliasByPath($site_config
->get('page.front')) : '';
$front_page = $config
->get($domain_id) != NULL ? $config
->get($domain_id . '.site_frontpage') : $front_page;
$form['front_page']['site_frontpage'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default front page'),
'#default_value' => $front_page,
'#size' => 40,
'#description' => $this
->t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default front page.'),
'#field_prefix' => $this->requestContext
->getCompleteBaseUrl(),
];
$form['error_page'] = [
'#type' => 'details',
'#title' => $this
->t('Error pages'),
'#open' => TRUE,
];
$form['error_page']['site_403'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default 403 (access denied) page'),
'#default_value' => $config
->get($domain_id) !== NULL ? $config
->get($domain_id . '.site_403') : $site_config
->get('page.403'),
'#size' => 40,
'#description' => $this
->t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
];
$form['error_page']['site_404'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default 404 (not found) page'),
'#default_value' => $config
->get($domain_id) !== NULL ? $config
->get($domain_id . '.site_404') : $site_config
->get('page.404'),
'#size' => 40,
'#description' => $this
->t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
];
$form['domain_id'] = [
'#type' => 'hidden',
'#title' => $this
->t('Domain ID'),
'#default_value' => $domain_id,
];
return parent::buildForm($form, $form_state);
}