public function Editor::getAttachments

Implements \Drupal\edit\EditPluginInterface::getAttachments().

Overrides EditPluginInterface::getAttachments

File

drupal/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php, line 72
Contains \Drupal\editor\Plugin\InPlaceEditor\Editor.

Class

Editor
Defines the formatted text editor.

Namespace

Drupal\editor\Plugin\InPlaceEditor

Code

public function getAttachments() {
  global $user;
  $user_format_ids = array_keys(filter_formats($user));
  $manager = drupal_container()
    ->get('plugin.manager.editor');
  $definitions = $manager
    ->getDefinitions();

  // Filter the current user's formats to those that support inline editing.
  $formats = array();
  foreach ($user_format_ids as $format_id) {
    $editor = editor_load($format_id);
    if ($editor && isset($definitions[$editor->editor]) && isset($definitions[$editor->editor]['supports_inline_editing']) && $definitions[$editor->editor]['supports_inline_editing'] === TRUE) {
      $formats[] = $format_id;
    }
  }

  // Get the attachments for all text editors that the user might use.
  $attachments = $manager
    ->getAttachments($formats);

  // Also include editor.module's formatted text editor.
  $attachments['library'][] = array(
    'editor',
    'edit.formattedTextEditor.editor',
  );
  return $attachments;
}