You are here

public function LlamaContextualAndButton::isEnabled in Drupal 8

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

Class

LlamaContextualAndButton
Defines a "LlamaContextualAndButton" plugin, with a contextually OR toolbar builder-enabled "llama" feature.

Namespace

Drupal\ckeditor_test\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {

  // Automatically enable this plugin if the Strike 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;
}