You are here

private function Update400::getPathToMediaBrowserButton in Lightning Media 8.4

Determines the array path to an editor's media_browser embed button.

Parameters

\Drupal\editor\EditorInterface $editor: The editor. It is assumed that it uses CKEditor.

Return value

array The path to the first media_browser embed button found in the editor's toolbar items. Empty if the button is not found at all.

1 call to Update400::getPathToMediaBrowserButton()
Update400::convertEditorsToMediaLibrary in src/Update/Update400.php
Optionally converts WYSIWYG editors to use the media library.

File

src/Update/Update400.php, line 133

Class

Update400
Contains optional updates targeting Lightning Media 4.0.0.

Namespace

Drupal\lightning_media\Update

Code

private function getPathToMediaBrowserButton(EditorInterface $editor) {
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row_key => $row) {
    foreach ($row as $group_key => $group) {
      $item_key = array_search('media_browser', $group['items'], TRUE);
      if ($item_key !== FALSE) {
        return [
          'toolbar',
          'rows',
          $row_key,
          $group_key,
          'items',
          $item_key,
        ];
      }
    }
  }
  return [];
}