You are here

public function LlamaContextual::isEnabled in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextual.php \Drupal\ckeditor_test\Plugin\CKEditorPlugin\LlamaContextual::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/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextual.php, line 21

Class

LlamaContextual
Defines a "Llama" plugin, with a contextually enabled "llama" feature.

Namespace

Drupal\ckeditor_test\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {

  // Automatically enable this plugin if the Underline button is enabled.
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row) {
    foreach ($row as $group) {
      if (in_array('Strike', $group['items'])) {
        return TRUE;
      }
    }
  }
  return FALSE;
}