You are here

public function CKEditor4To5UpgradePluginManager::computeCKEditor5PluginSubsetConfiguration in Drupal 10

Computes elements subset configuration for CKEditor 5 plugin.

Every CKEditor 5 plugin that implements the elements subset interface must implement this as well, to ensure a smooth upgrade path.

Parameters

string $cke5_plugin_id: The CKEditor 5 plugin whose subset configuration needs to be computed.

\Drupal\filter\FilterFormatInterface $text_format: The text format based on whose restrictions this should be computed.

Return value

array|null NULL if not needed, otherwise a configuration array (which can itself be a subset of the default configuration of this CKEditor 5 plugin: perhaps only some of the configuration values determine the subset).

Throws

\OutOfBoundsException Thrown when no upgrade path exists.

\LogicException Thrown when a plugin claims to provide an upgrade path but does not.

See also

\Drupal\ckeditor5\Plugin\CKEditor5PluginElementsSubsetInterface

File

core/modules/ckeditor5/src/Plugin/CKEditor4To5UpgradePluginManager.php, line 214

Class

CKEditor4To5UpgradePluginManager
Provides a CKEditor 4 to 5 upgrade plugin manager.

Namespace

Drupal\ckeditor5\Plugin

Code

public function computeCKEditor5PluginSubsetConfiguration(string $cke5_plugin_id, FilterFormatInterface $text_format) : ?array {
  $this
    ->validateAndBuildMaps();
  if (!isset($this->cke5SubsetConfigurationMap[$cke5_plugin_id])) {
    throw new \OutOfBoundsException(sprintf('No upgrade path found for the "%s" elements subset configuration.', $cke5_plugin_id));
  }
  $plugin_id = $this->cke5SubsetConfigurationMap[$cke5_plugin_id];
  try {
    return $this
      ->createInstance($plugin_id)
      ->computeCKEditor5PluginSubsetConfiguration($cke5_plugin_id, $text_format);
  } catch (\OutOfBoundsException $e) {
    throw new \LogicException(sprintf('The "%s" CKEditor4To5Upgrade plugin claims to provide an upgrade path for the "%s" CKEditor 4 plugin settings but does not.', $plugin_id, $cke5_plugin_id));
  }
}