You are here

public function CKEditor::buildToolbarJSSetting in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::buildToolbarJSSetting()

Builds the "toolbar" configuration part of the CKEditor JS settings.

Parameters

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

Return value

array An array containing the "toolbar" configuration.

See also

getJSSettings()

1 call to CKEditor::buildToolbarJSSetting()
CKEditor::getJSSettings in core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
Returns JavaScript settings to be attached.

File

core/modules/ckeditor/src/Plugin/Editor/CKEditor.php, line 410

Class

CKEditor
Defines a CKEditor-based text editor for Drupal.

Namespace

Drupal\ckeditor\Plugin\Editor

Code

public function buildToolbarJSSetting(Editor $editor) {
  $toolbar = [];
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row) {
    foreach ($row as $group) {
      $toolbar[] = $group;
    }
    $toolbar[] = '/';
  }
  return $toolbar;
}