function Media::getDynamicPluginConfig

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

Overrides CKEditor5PluginDefault::getDynamicPluginConfig

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Media.php, line 171

Class

Media
CKEditor 5 Media plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor) : array {
    $dynamic_plugin_config = $static_plugin_config;
    $dynamic_plugin_config['drupalMedia']['previewURL'] = Url::fromRoute('media.filter.preview')->setRouteParameter('filter_format', $editor->getFilterFormat()
        ->id())
        ->toString(TRUE)
        ->getGeneratedUrl();
    [
        $element_style_configuration,
        $toolbar_configuration,
    ] = self::configureViewModes($editor);
    $dynamic_plugin_config['drupalElementStyles']['viewMode'] = $element_style_configuration;
    if ($this->getConfiguration()['allow_view_mode_override']) {
        $dynamic_plugin_config['drupalMedia']['toolbar'][] = $toolbar_configuration;
    }
    $dynamic_plugin_config['drupalMedia']['metadataUrl'] = self::getUrlWithReplacedCsrfTokenPlaceholder(Url::fromRoute('ckeditor5.media_entity_metadata')->setRouteParameter('editor', $editor->id()));
    $dynamic_plugin_config['drupalMedia']['previewCsrfToken'] = \Drupal::csrfToken()->get('X-Drupal-MediaPreview-CSRF-Token');
    return $dynamic_plugin_config;
}

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