You are here

public function IndentBlock::isEnabled in CKEditor IndentBlock 8

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

src/Plugin/CKEditorPlugin/IndentBlock.php, line 62

Class

IndentBlock
Defines the "Indent Block" plugin.

Namespace

Drupal\ckeditor_indentblock\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {

  // Enable this plugin, if it is configured as being enabled and at least one
  // of the buttons, Indent or Outdent, is enabled.
  $settings = $editor
    ->getSettings();
  if (isset($settings['plugins']['indentblock']) && $settings['plugins']['indentblock']['enable']) {
    foreach ($settings['toolbar']['rows'] as $row) {
      foreach ($row as $group) {
        foreach ($group['items'] as $button) {
          if ($button === 'Indent' || $button === 'Outdent') {
            return TRUE;
          }
        }
      }
    }
  }
  return FALSE;
}