class TestAttributeFilter in Drupal 10
Same name and namespace in other branches
- 8 core/modules/ckeditor/tests/modules/src/Plugin/Filter/TestAttributeFilter.php \Drupal\ckeditor_test\Plugin\Filter\TestAttributeFilter
- 9 core/modules/ckeditor/tests/modules/src/Plugin/Filter/TestAttributeFilter.php \Drupal\ckeditor_test\Plugin\Filter\TestAttributeFilter
A filter that adds a test attribute to any configured HTML tags.
Plugin annotation
@Filter(
id = "test_attribute_filter",
title = @Translation("Test Attribute Filter"),
type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
settings = {
"tags" = {},
},
weight = -10
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\filter\Plugin\FilterBase implements FilterInterface
- class \Drupal\ckeditor_test\Plugin\Filter\TestAttributeFilter
- class \Drupal\filter\Plugin\FilterBase implements FilterInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestAttributeFilter
File
- core/
modules/ ckeditor/ tests/ modules/ src/ Plugin/ Filter/ TestAttributeFilter.php, line 22
Namespace
Drupal\ckeditor_test\Plugin\FilterView source
class TestAttributeFilter extends FilterBase {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) {
$document = Html::load($text);
foreach ($this->settings['tags'] as $tag) {
$tag_elements = $document
->getElementsByTagName($tag);
foreach ($tag_elements as $tag_element) {
$tag_element
->setAttribute('test_attribute', 'test attribute value');
}
}
return new FilterProcessResult(Html::serialize($document));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FilterBase:: |
public | property | The name of the provider that owns this filter. | |
FilterBase:: |
public | property | An associative array containing the configured settings of this filter. | |
FilterBase:: |
public | property | A Boolean indicating whether this filter is enabled. | |
FilterBase:: |
public | property | The weight of this filter compared to others in a filter collection. | |
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | 1 | |
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterBase:: |
public | function | ||
FilterInterface:: |
constant | HTML tag and attribute restricting filters to prevent XSS attacks. | ||
FilterInterface:: |
constant | Non-HTML markup language filters that generate HTML. | ||
FilterInterface:: |
constant | Irreversible transformation filters. | ||
FilterInterface:: |
constant | Reversible transformation filters. | ||
MessengerTrait:: |
protected | property | The messenger. | 18 |
MessengerTrait:: |
public | function | Gets the messenger. | 18 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function | ||
PluginBase:: |
public | function | ||
PluginBase:: |
public | function | 2 | |
PluginBase:: |
public | function | ||
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 3 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 1 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TestAttributeFilter:: |
public | function |
Performs the filter processing. Overrides FilterInterface:: |