getWildcardSubset example


  }

  /** * @covers ::getWildcardSubset * @covers ::getConcreteSubset * @covers ::getPlainTagsSubset * @covers ::extractPlainTagsSubset * @dataProvider providerSubsets */
  public function testSubsets(HTMLRestrictions $input, HTMLRestrictions $expected_wildcard_subset, HTMLRestrictions $expected_concrete_subset, HTMLRestrictions $expected_plain_tags_subset, HTMLRestrictions $expected_extracted_plain_tags_subset): void {
    $this->assertEquals($expected_wildcard_subset$input->getWildcardSubset());
    $this->assertEquals($expected_concrete_subset$input->getConcreteSubset());
    $this->assertEquals($expected_plain_tags_subset$input->getPlainTagsSubset());
    $this->assertEquals($expected_extracted_plain_tags_subset$input->extractPlainTagsSubset());
  }

  public function providerSubsets(): \Generator {
    yield 'empty set' => [
      new HTMLRestrictions([]),
      new HTMLRestrictions([]),
      new HTMLRestrictions([]),
      new HTMLRestrictions([]),
      

  private function pluginsSupplyingTagsMessage(HTMLRestrictions $overlap, array $plugin_definitions, HTMLRestrictions $enabled_plugin_restrictions): string {
    $message_array = [];
    $message_string = '';
    foreach ($plugin_definitions as $definition) {
      if ($definition->hasElements()) {
        $plugin_capabilities = HTMLRestrictions::fromString(implode(' ', $definition->getElements()));

        // If this plugin supports wildcards, resolve them.         if (!$plugin_capabilities->getWildcardSubset()->allowsNothing()) {
          $plugin_capabilities = $plugin_capabilities
            // Resolve wildcards.             ->merge($enabled_plugin_restrictions)
            ->diff($enabled_plugin_restrictions);
        }

        // Skip plugins that provide a subset, only mention the plugin that         // actually provides the overlap.         // For example: avoid listing the image alignment/captioning plugins         // when matching `<img src>`; only lists the main image plugin.         if (!$overlap->diff($plugin_capabilities)->allowsNothing()) {
          

  private static function applyOperation(HTMLRestrictions $a, HTMLRestrictions $b, string $operation_method_name): HTMLRestrictions {
    // 1. Operation applied to wildcard tags that exist in both operands.     // For example: <$text-container id> in both operands.     $a_wildcard = $a->getWildcardSubset();
    $b_wildcard = $b->getWildcardSubset();
    $wildcard_op_result = $a_wildcard->$operation_method_name($b_wildcard);

    // Early return if both operands contain only wildcard tags.     if (count($a_wildcard->elements) === count($a->elements) && count($b_wildcard->elements) === count($b->elements)) {
      return $wildcard_op_result;
    }

    // 2. Operation applied with wildcard tags resolved into concrete tags.     // For example: <p class="text-align-center"> in the first operand and     // <$text-container class="text-align-center"> in the second


    // Evaluate `plugins` condition.     foreach ($definitions_with_plugins_condition as $plugin_id => $definition) {
      if (!empty(array_diff($definition->getConditions()['plugins']array_keys($definitions)))) {
        unset($definitions[$plugin_id]);
      }
    }

    if (!isset($definitions['ckeditor5_arbitraryHtmlSupport'])) {
      $restrictions = new HTMLRestrictions($this->getProvidedElements(array_keys($definitions)$editor, FALSE));
      if ($restrictions->getWildcardSubset()->allowsNothing()) {
        // This is only reached if arbitrary HTML is not enabled. If wildcard         // tags (such as $text-container) are present, they need to         // be resolved via the wildcardHtmlSupport plugin.         // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getCKEditor5PluginConfig()         unset($definitions['ckeditor5_wildcardHtmlSupport']);
      }
    }
    // When arbitrary HTML is already supported, there is no need to support     // wildcard tags.     else {
      unset($definitions['ckeditor5_wildcardHtmlSupport']);
    }
Home | Imprint | This part of the site doesn't use cookies.