3 namespace Drupal\filter_test\Plugin\Filter;
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\filter\FilterProcessResult;
7 use Drupal\filter\Plugin\FilterBase;
10 * Provides a test filter to associate cache contexts.
13 * id = "filter_test_cache_contexts",
14 * title = @Translation("Testing filter"),
15 * description = @Translation("Does not change content; associates cache contexts."),
16 * type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
19 class FilterTestCacheContexts extends FilterBase {
24 public function process($text, $langcode) {
25 $result = new FilterProcessResult($text);
26 // The changes made by this filter are language-specific.
27 $result->addCacheContexts(['languages:' . LanguageInterface::TYPE_CONTENT]);