function Alignment::getDynamicPluginConfig

Same name and namespace in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::getDynamicPluginConfig()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Alignment::getDynamicPluginConfig()

Filters the alignment options to those chosen in editor config.

Overrides CKEditor5PluginDefault::getDynamicPluginConfig

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php, line 93

Class

Alignment
CKEditor 5 Alignment plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor) : array {
    $enabled_alignments = $this->configuration['enabled_alignments'];
    $all_alignment_options = $static_plugin_config['alignment']['options'];
    $configured_alignment_options = array_filter($all_alignment_options, function ($option) use ($enabled_alignments) {
        return in_array($option['name'], $enabled_alignments, TRUE);
    });
    return [
        'alignment' => [
            'options' => array_values($configured_alignment_options),
        ],
    ];
}

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