You are here

public function DrupalMedia::isEnabled in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/Plugin/CKEditorPlugin/DrupalMedia.php \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia::isEnabled()

Checks if this plugin should be enabled based on the editor configuration.

The editor's settings can be retrieved via $editor->getSettings().

Parameters

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

Return value

bool

Overrides CKEditorPluginContextualInterface::isEnabled

File

core/modules/media/src/Plugin/CKEditorPlugin/DrupalMedia.php, line 107

Class

DrupalMedia
Defines the "drupalmedia" plugin.

Namespace

Drupal\media\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {
  if (!$editor
    ->hasAssociatedFilterFormat()) {
    return FALSE;
  }

  // Automatically enable this plugin if the text format associated with this
  // text editor uses the media_embed filter.
  $filters = $editor
    ->getFilterFormat()
    ->filters();
  return $filters
    ->has('media_embed') && $filters
    ->get('media_embed')->status;
}