You are here

protected function CKEditor5PluginManager::mergeDefinitionValues in Drupal 10

Returns array of merged values for the given plugin definitions.

Parameters

string $get_method: Which CKEditor5PluginDefinition getter to call to get values to merge.

\Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition[] $definitions: The plugin definitions whose values to merge.

Return value

array List of merged values for the given plugin definition method.

4 calls to CKEditor5PluginManager::mergeDefinitionValues()
CKEditor5PluginManager::getAdminLibraries in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
Gets a list of all admin library names.
CKEditor5PluginManager::getCKEditor5PluginConfig in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
Gets the configuration for the CKEditor 5 plugins enabled in this editor.
CKEditor5PluginManager::getEnabledLibraries in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
Gets a list of libraries required for the editor.
CKEditor5PluginManager::getToolbarItems in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
Gets a list of all toolbar items.

File

core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php, line 394

Class

CKEditor5PluginManager
Provides a CKEditor5 plugin manager.

Namespace

Drupal\ckeditor5\Plugin

Code

protected function mergeDefinitionValues(string $get_method, array $definitions) : array {
  assert(method_exists(CKEditor5PluginDefinition::class, $get_method));
  $has_method = 'has' . substr($get_method, 3);
  assert(method_exists(CKEditor5PluginDefinition::class, $has_method));
  $per_plugin = array_filter(array_map(function (CKEditor5PluginDefinition $definition) use ($get_method, $has_method) {
    if ($definition
      ->{$has_method}()) {
      return $definition
        ->{$get_method}();
    }
  }, $definitions));
  return array_reduce($per_plugin, function (array $result, $current) : array {
    return is_array($current) && is_array(reset($current)) ? $result + $current : array_merge($result, (array) $current);
  }, []);
}