Implements \Drupal\Core\Form\FormInterface::buildForm().
Overrides ConditionPluginBase::buildForm
public function buildForm(array $form, array &$form_state) {
$form = parent::buildForm($form, $form_state);
if (language_multilingual()) {
// Fetch languages.
$languages = language_list(Lang::STATE_ALL);
$langcodes_options = array();
foreach ($languages as $language) {
// @todo $language->name is not wrapped with t(), it should be replaced
// by CMI translation implementation.
$langcodes_options[$language->langcode] = $language->name;
}
$form['langcodes'] = array(
'#type' => 'checkboxes',
'#title' => t('Language selection'),
'#default_value' => !empty($this->configuration['langcodes']) ? $this->configuration['langcodes'] : array(),
'#options' => $langcodes_options,
'#description' => t('Select languages to enforce. If none are selected, all languages will be allowed.'),
);
}
else {
$form['language']['langcodes'] = array(
'#type' => 'value',
'#value' => !empty($this->configuration['langcodes']) ? $this->configuration['langcodes'] : array(),
);
}
return $form;
}