function PluginManagerDependentValidatorTrait::getEnableableDisabledPlugins

Same name in other branches
  1. 9 core/modules/ckeditor5/src/Plugin/Validation/Constraint/PluginManagerDependentValidatorTrait.php \Drupal\ckeditor5\Plugin\Validation\Constraint\PluginManagerDependentValidatorTrait::getEnableableDisabledPlugins()
  2. 11.x core/modules/ckeditor5/src/Plugin/Validation/Constraint/PluginManagerDependentValidatorTrait.php \Drupal\ckeditor5\Plugin\Validation\Constraint\PluginManagerDependentValidatorTrait::getEnableableDisabledPlugins()

Gets all disabled CKEditor 5 plugin definitions the user can enable.

Parameters

\Drupal\editor\EditorInterface $text_editor: A Text Editor config entity configured to use CKEditor 5.

Return value

\Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition[] A list of CKEditor 5 plugin definitions keyed by plugin ID.

2 calls to PluginManagerDependentValidatorTrait::getEnableableDisabledPlugins()
SourceEditingRedundantTagsConstraintValidator::validate in core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php
StyleSensibleElementConstraintValidator::validate in core/modules/ckeditor5/src/Plugin/Validation/Constraint/StyleSensibleElementConstraintValidator.php

File

core/modules/ckeditor5/src/Plugin/Validation/Constraint/PluginManagerDependentValidatorTrait.php, line 74

Class

PluginManagerDependentValidatorTrait
Common functionality for many CKEditor 5 validation constraints.

Namespace

Drupal\ckeditor5\Plugin\Validation\Constraint

Code

private function getEnableableDisabledPlugins(EditorInterface $text_editor) {
    $disabled_plugins = array_diff_key($this->pluginManager
        ->getDefinitions(), $this->pluginManager
        ->getEnabledDefinitions($text_editor));
    // Only consider plugins that can be explicitly enabled by the user: plugins
    // that have a toolbar item and do not have conditions. Those are the only
    // plugins that are truly available for the site builder to enable without
    // other consequences.
    // In the future, we may choose to expand this, but it will require complex
    // infrastructure to generate messages that explain which of the conditions
    // are already fulfilled and which are not.
    $enableable_disabled_plugins = array_filter($disabled_plugins, function (CKEditor5PluginDefinition $definition) {
        return $definition->hasToolbarItems() && !$definition->hasConditions();
    });
    return $enableable_disabled_plugins;
}

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