FilterTestCacheTags.php

Same filename in other branches
  1. 9 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php
  2. 10 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php
  3. 11.x core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php

Namespace

Drupal\filter_test\Plugin\Filter

File

core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheTags.php

View source
<?php

namespace Drupal\filter_test\Plugin\Filter;

use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

/**
 * Provides a test filter to associate cache tags
 *
 * @Filter(
 *   id = "filter_test_cache_tags",
 *   title = @Translation("Testing filter"),
 *   description = @Translation("Does not change content; associates cache tags."),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
 * )
 */
class FilterTestCacheTags extends FilterBase {
    
    /**
     * {@inheritdoc}
     */
    public function process($text, $langcode) {
        $result = new FilterProcessResult($text);
        $result->addCacheTags([
            'foo:bar',
        ]);
        $result->addCacheTags([
            'foo:baz',
        ]);
        return $result;
    }

}

Classes

Title Deprecated Summary
FilterTestCacheTags Provides a test filter to associate cache tags

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