function SystemBrandingOffCanvasForm::buildConfigurationForm

Same name in other branches
  1. 9 core/modules/system/src/Form/SystemBrandingOffCanvasForm.php \Drupal\system\Form\SystemBrandingOffCanvasForm::buildConfigurationForm()
  2. 8.9.x core/modules/system/src/Form/SystemBrandingOffCanvasForm.php \Drupal\system\Form\SystemBrandingOffCanvasForm::buildConfigurationForm()
  3. 11.x core/modules/system/src/Form/SystemBrandingOffCanvasForm.php \Drupal\system\Form\SystemBrandingOffCanvasForm::buildConfigurationForm()

Overrides PluginFormInterface::buildConfigurationForm

File

core/modules/system/src/Form/SystemBrandingOffCanvasForm.php, line 70

Class

SystemBrandingOffCanvasForm
The settings_tray form handler for the SystemBrandingBlock.

Namespace

Drupal\system\Form

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = $this->plugin
        ->buildConfigurationForm($form, $form_state);
    $form['block_branding']['#type'] = 'details';
    $form['block_branding']['#weight'] = 10;
    // Unset links to Site Information form, we can make these changes here.
    unset($form['block_branding']['use_site_name']['#description'], $form['block_branding']['use_site_slogan']['#description']);
    $site_config = $this->configFactory
        ->getEditable('system.site');
    // Load the immutable config to load the overrides.
    $site_config_immutable = $this->configFactory
        ->get('system.site');
    $form['site_information'] = [
        '#type' => 'details',
        '#title' => $this->t('Site details'),
        '#open' => TRUE,
        '#access' => $this->currentUser
            ->hasPermission('administer site configuration') && !$site_config_immutable->hasOverrides('name') && !$site_config_immutable->hasOverrides('slogan'),
    ];
    $form['site_information']['site_name'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Site name'),
        '#default_value' => $site_config->get('name'),
        '#required' => TRUE,
    ];
    $form['site_information']['site_slogan'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Slogan'),
        '#default_value' => $site_config->get('slogan'),
        '#description' => $this->t("How this is used depends on your site's theme."),
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.