You are here

public function ScaytCKEditorButton::isEnabled in CKEditor SpellCheckAsYouType (SCAYT) 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/ScaytCKEditorButton.php, line 257

Class

ScaytCKEditorButton
Defines the "scayt" plugin.

Namespace

Drupal\ckeditor_scayt\Plugin\CKEditorPlugin

Code

public function isEnabled(Editor $editor) {
  $settings = $editor
    ->getSettings();
  foreach ($settings['toolbar']['rows'] as $row) {
    foreach ($row as $group) {
      foreach ($group['items'] as $button) {
        if ($button === 'Scayt') {
          return TRUE;
        }
      }
    }
  }
  return FALSE;
}