class FilterTestPlaceholders in Drupal 10
Same name and namespace in other branches
- 8 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php \Drupal\filter_test\Plugin\Filter\FilterTestPlaceholders
- 9 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestPlaceholders.php \Drupal\filter_test\Plugin\Filter\FilterTestPlaceholders
Provides a test filter to use placeholders.
Plugin annotation
@Filter(
id = "filter_test_placeholders",
title = @Translation("Testing filter"),
description = @Translation("Appends a placeholder to the content; associates #lazy_builder callback."),
type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
)
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\filter_test\Plugin\Filter\FilterTestPlaceholders implements TrustedCallbackInterface
- class \Drupal\filter\Plugin\FilterBase implements FilterInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FilterTestPlaceholders
File
- core/
modules/ filter/ tests/ filter_test/ src/ Plugin/ Filter/ FilterTestPlaceholders.php, line 20
Namespace
Drupal\filter_test\Plugin\FilterView source
class FilterTestPlaceholders extends FilterBase implements TrustedCallbackInterface {
/**
* {@inheritdoc}
*/
public function process($text, $langcode) {
$result = new FilterProcessResult($text);
$placeholder = $result
->createPlaceholder('\\Drupal\\filter_test\\Plugin\\Filter\\FilterTestPlaceholders::renderDynamicThing', [
'llama',
]);
$result
->setProcessedText($text . '<p>' . $placeholder . '</p>');
return $result;
}
/**
* #lazy_builder callback; builds a render array containing the dynamic thing.
*
* @param string $thing
* A "thing" string.
*
* @return array
* A renderable array.
*/
public static function renderDynamicThing($thing) {
return [
'#markup' => new FormattableMarkup('This is a dynamic @thing.', [
'@thing' => $thing,
]),
];
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'renderDynamicThing',
];
}
}
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. | ||
FilterTestPlaceholders:: |
public | function |
Performs the filter processing. Overrides FilterInterface:: |
|
FilterTestPlaceholders:: |
public static | function | #lazy_builder callback; builds a render array containing the dynamic thing. | |
FilterTestPlaceholders:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
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. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |