You are here

public function CkeditorBootstrapTable::isEnabled in CKEditor Bootstrap Table 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/CkeditorBootstrapTable.php, line 52

Class

CkeditorBootstrapTable
Defines the "btbutton" plugin.

Namespace

Drupal\ckeditor_bootstrap_table\Plugin\CKEditorPlugin

Code

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

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