public function Language::settingsForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language::settingsForm()
Returns a settings form to configure this CKEditor plugin.
If the plugin's behavior depends on extensive options and/or external data, then the implementing module can choose to provide a separate, global configuration page rather than per-text-editor settings. In that case, this form should provide a link to the separate settings page.
Parameters
array $form: An empty form array to be populated with a configuration form, if any.
\Drupal\Core\Form\FormStateInterface $form_state: The state of the entire filter administration form.
\Drupal\editor\Entity\Editor $editor: A configured text editor object.
Return value
array A render array for the settings form.
Overrides CKEditorPluginConfigurableInterface::settingsForm
File
- core/
modules/ ckeditor/ src/ Plugin/ CKEditorPlugin/ Language.php, line 99
Class
- Language
- Defines the "language" plugin.
Namespace
Drupal\ckeditor\Plugin\CKEditorPluginCode
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
// Defaults.
$config = [
'language_list' => 'un',
];
$settings = $editor
->getSettings();
if (isset($settings['plugins']['language'])) {
$config = $settings['plugins']['language'];
}
$predefined_languages = LanguageManager::getStandardLanguageList();
$form['language_list'] = [
'#title' => $this
->t('Language list'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => [
'un' => $this
->t("United Nations' official languages"),
'all' => $this
->t('All @count languages', [
'@count' => count($predefined_languages),
]),
],
'#default_value' => $config['language_list'],
'#description' => $this
->t('The list of languages to show in the language dropdown. The basic list will only show the <a href=":url">six official languages of the UN</a>. The extended list will show all @count languages that are available in Drupal.', [
':url' => 'https://www.un.org/en/sections/about-un/official-languages',
'@count' => count($predefined_languages),
]),
'#attached' => [
'library' => [
'ckeditor/drupal.ckeditor.language.admin',
],
],
];
return $form;
}