You are here

public static function CKEditorPluginManager::getEnabledButtons in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/ckeditor/src/CKEditorPluginManager.php \Drupal\ckeditor\CKEditorPluginManager::getEnabledButtons()
  2. 9 core/modules/ckeditor/src/CKEditorPluginManager.php \Drupal\ckeditor\CKEditorPluginManager::getEnabledButtons()

Gets the enabled toolbar buttons in the given text editor instance.

Parameters

\Drupal\editor\Entity\Editor $editor: A configured text editor object.

Return value

string[] A list of the toolbar buttons enabled in the given text editor instance.

3 calls to CKEditorPluginManager::getEnabledButtons()
CKEditorPluginManager::getEnabledPluginFiles in core/modules/ckeditor/src/CKEditorPluginManager.php
Retrieves enabled plugins' files, keyed by plugin ID.
CKEditorPluginManagerTest::testGetEnabledButtons in core/modules/ckeditor/tests/src/Unit/CKEditorPluginManagerTest.php
@covers ::getEnabledButtons @dataProvider providerGetEnabledButtons
Internal::getConfig in core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php

File

core/modules/ckeditor/src/CKEditorPluginManager.php, line 121

Class

CKEditorPluginManager
Provides a CKEditor Plugin plugin manager.

Namespace

Drupal\ckeditor

Code

public static function getEnabledButtons(Editor $editor) {
  $toolbar_rows = [];
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row_number => $row) {
    $toolbar_rows[] = array_reduce($settings['toolbar']['rows'][$row_number], function ($result, $button_group) {
      return array_merge($result, $button_group['items']);
    }, []);
  }
  return array_unique(NestedArray::mergeDeepArray($toolbar_rows));
}