FilterTestCacheMerge.php in Drupal 10
Same filename and directory in other branches
Namespace
Drupal\filter_test\Plugin\FilterFile
core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestCacheMerge.phpView source
<?php
namespace Drupal\filter_test\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Drupal\Core\Cache\CacheableMetadata;
/**
* Provides a test filter to merge with CacheableMetadata.
*
* @Filter(
* id = "filter_test_cache_merge",
* title = @Translation("Testing filter"),
* description = @Translation("Does not change content; merges cacheable metadata."),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
* )
*/
class FilterTestCacheMerge extends FilterBase {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
$metadata = new CacheableMetadata();
$metadata
->addCacheTags([
'merge:tag',
]);
$metadata
->addCacheContexts([
'user.permissions',
]);
$result = $result
->merge($metadata);
return $result;
}
}
Classes
Name | Description |
---|---|
FilterTestCacheMerge | Provides a test filter to merge with CacheableMetadata. |