computeNetNewElementsForPlugin example


  private static function getCandidates(HTMLRestrictions $provided, HTMLRestrictions $still_needed, array $disabled_plugin_definitions): array {
    $plugin_candidates = [];
    if (!$still_needed->allowsNothing()) {
      foreach ($disabled_plugin_definitions as $definition) {
        // Only proceed if the plugin has configured elements and the plugin         // does not have conditions. In the future we could add support for         // automatically enabling filters, but for now we assume that the filter         // configuration cannot be modified.         if (!$definition->hasConditions() && $definition->hasElements()) {
          [$net_new$surplus_additions] = self::computeNetNewElementsForPlugin($provided$still_needed$definition);
          if (!$net_new->allowsNothing()) {
            $plugin_id = $definition->id();
            $creatable_elements = HTMLRestrictions::fromString(implode(' ', $definition->getCreatableElements()));
            $surplus_score = static::computeSurplusScore($surplus_additions$still_needed);
            foreach ($net_new->getAllowedElements() as $tag_name => $attributes_config) {
              // Non-specific attribute restrictions: `FALSE` or `TRUE`.               // TRICKY: PHP does not support boolean array keys, so map these               // to a string. The string must not be a valid attribute name, so               // use a leading and trailing dash.               if (!is_array($attributes_config)) {
                if ($attributes_config === FALSE && !array_key_exists($tag_name$creatable_elements->getAllowedElements())) {
                  
Home | Imprint | This part of the site doesn't use cookies.