getOtherEnabledPlugins example


  public function validate($value, Constraint $constraint) {
    if (!$constraint instanceof SourceEditingRedundantTagsConstraint) {
      throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\SourceEditingRedundantTagsConstraint');
    }
    if (empty($value)) {
      return;
    }

    $text_editor = $this->createTextEditorObjectFromContext();

    $other_enabled_plugins = $this->getOtherEnabledPlugins($text_editor, 'ckeditor5_sourceEditing');
    $enableable_disabled_plugins = $this->getEnableableDisabledPlugins($text_editor);

    // An array of tags enabled by every plugin other than Source Editing.     $enabled_plugin_elements = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($other_enabled_plugins)$text_editor, FALSE));
    $disabled_plugin_elements = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($enableable_disabled_plugins)$text_editor, FALSE));
    $enabled_plugin_plain_tags = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($other_enabled_plugins)$text_editor, FALSE, TRUE));
    $disabled_plugin_plain_tags = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($enableable_disabled_plugins)$text_editor, FALSE, TRUE));

    // The single element for which source editing is enabled, which we are     // checking now.     $source_enabled_element = HTMLRestrictions::fromString($value);
    
// Ensure the tag is in the range supported by the Style plugin.     $superset = HTMLRestrictions::fromString('<$any-html5-element class>');
    $supported_range = $superset->merge($style_element->extractPlainTagsSubset());
    if (!$style_element->diff($supported_range)->allowsNothing()) {
      $this->context->buildViolation($constraint->nonHtml5TagMessage)
        ->setParameter('@tag', sprintf("<%s>", $tag))
        ->addViolation();
      return;
    }

    // Get the list of tags enabled by every plugin other than Style.     $other_enabled_plugins = $this->getOtherEnabledPlugins($text_editor, 'ckeditor5_style');
    $enableable_disabled_plugins = $this->getEnableableDisabledPlugins($text_editor);

    $other_enabled_plugin_elements = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($other_enabled_plugins)$text_editor, FALSE));
    $disabled_plugin_elements = new HTMLRestrictions($this->pluginManager->getProvidedElements(array_keys($enableable_disabled_plugins)$text_editor, FALSE));

    // Next, validate that the classes specified for this style are not     // supported by an enabled plugin.     if (self::intersectionWithClasses($style_element$other_enabled_plugin_elements)) {
      $this->context->buildViolation($constraint->conflictingEnabledPluginMessage)
        ->setParameter('@tag', sprintf("<%s>", $tag))
        ->setParameter('@classes', implode(", ", $classes))
        
Home | Imprint | This part of the site doesn't use cookies.