function Language::buildConfigurationForm

Same name in this branch
  1. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()
Same name in other branches
  1. 9 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  2. 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()
  3. 8.9.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  4. 10 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  5. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()

Overrides ConditionPluginBase::buildConfigurationForm

File

core/modules/language/src/Plugin/Condition/Language.php, line 72

Class

Language
Provides a 'Language' condition.

Namespace

Drupal\language\Plugin\Condition

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    if ($this->languageManager
        ->isMultilingual()) {
        // Fetch languages.
        $languages = $this->languageManager
            ->getLanguages();
        $langcodes_options = [];
        foreach ($languages as $language) {
            $langcodes_options[$language->getId()] = $language->getName();
        }
        $form['langcodes'] = [
            '#type' => 'checkboxes',
            '#title' => $this->t('Language selection'),
            '#default_value' => $this->configuration['langcodes'],
            '#options' => $langcodes_options,
            '#description' => $this->t('Select languages to enforce. If none are selected, all languages will be allowed.'),
        ];
    }
    else {
        $form['langcodes'] = [
            '#type' => 'value',
            '#default_value' => $this->configuration['langcodes'],
        ];
    }
    return parent::buildConfigurationForm($form, $form_state);
}

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