function CKEditor5PluginManager::mergeDefinitionValues

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::mergeDefinitionValues()
  2. 10 core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::mergeDefinitionValues()

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
CKEditor5PluginManager::getCKEditor5PluginConfig in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
CKEditor5PluginManager::getEnabledLibraries in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
CKEditor5PluginManager::getToolbarItems in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php

File

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

Class

CKEditor5PluginManager
Provides a CKEditor 5 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);
    }, []);
}

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