function CKEditor5PluginManager::isPluginDisabled

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::isPluginDisabled()
  2. 10 core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::isPluginDisabled()

Checks whether a plugin must be disabled due to unmet conditions.

Parameters

\Drupal\ckeditor5\Plugin\CKEditor5PluginInterface $plugin: A CKEditor 5 plugin instance.

\Drupal\editor\EditorInterface $editor: A configured text editor object.

Return value

bool Whether the plugin is disabled due to unmet conditions.

1 call to CKEditor5PluginManager::isPluginDisabled()
CKEditor5PluginManager::getEnabledDefinitions in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php

File

core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php, line 476

Class

CKEditor5PluginManager
Provides a CKEditor 5 plugin manager.

Namespace

Drupal\ckeditor5\Plugin

Code

protected function isPluginDisabled(CKEditor5PluginInterface $plugin, EditorInterface $editor) : bool {
    assert($plugin->getPluginDefinition()
        ->hasConditions());
    foreach ($plugin->getPluginDefinition()
        ->getConditions() as $condition_type => $required_value) {
        switch ($condition_type) {
            case 'toolbarItem':
                if (!in_array($required_value, $editor->getSettings()['toolbar']['items'])) {
                    return TRUE;
                }
                break;
            case 'imageUploadStatus':
                $image_upload_status = $editor->getImageUploadSettings()['status'] ?? FALSE;
                return $image_upload_status !== $required_value;
            case 'filter':
                $filters = $editor->getFilterFormat()
                    ->filters();
                assert($filters instanceof FilterPluginCollection);
                if (!$filters->has($required_value) || !$filters->get($required_value)->status) {
                    return TRUE;
                }
                break;
            case 'requiresConfiguration':
                $intersection = array_intersect($plugin->getConfiguration(), $required_value);
                return $intersection !== $required_value;
            case 'plugins':
                // Tricky: this cannot yet be evaluated here. It will evaluated later.
                // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getEnabledDefinitions()
                return FALSE;
        }
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.