function FilterTestRestrictTagsAndAttributes::getHTMLRestrictions

Same name in other branches
  1. 9 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php \Drupal\filter_test\Plugin\Filter\FilterTestRestrictTagsAndAttributes::getHTMLRestrictions()
  2. 8.9.x core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php \Drupal\filter_test\Plugin\Filter\FilterTestRestrictTagsAndAttributes::getHTMLRestrictions()
  3. 10 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php \Drupal\filter_test\Plugin\Filter\FilterTestRestrictTagsAndAttributes::getHTMLRestrictions()

Overrides FilterBase::getHTMLRestrictions

File

core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php, line 38

Class

FilterTestRestrictTagsAndAttributes
Provides a test filter to restrict HTML tags and attributes.

Namespace

Drupal\filter_test\Plugin\Filter

Code

public function getHTMLRestrictions() {
    $restrictions = $this->settings['restrictions'];
    // The configuration system stores FALSE as '0' and TRUE as '1'. Fix that.
    if (isset($restrictions['allowed'])) {
        foreach ($restrictions['allowed'] as $tag => $attributes_or_bool) {
            if (!is_array($attributes_or_bool)) {
                $restrictions['allowed'][$tag] = (bool) $attributes_or_bool;
            }
            else {
                foreach ($attributes_or_bool as $attr => $attribute_values_or_bool) {
                    if (!is_array($attribute_values_or_bool)) {
                        $restrictions['allowed'][$tag][$attr] = (bool) $attribute_values_or_bool;
                    }
                    else {
                        foreach ($attribute_values_or_bool as $attribute_value => $bool) {
                            $restrictions['allowed'][$tag][$attr][$attribute_value] = (bool) $bool;
                        }
                    }
                }
            }
        }
    }
    return $restrictions;
}

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