FilterInterface
interface FilterInterface implements ConfigurableInterface, DependentPluginInterface, PluginInspectionInterface (View source)
Defines the interface for text processing filter plugins.
User submitted content is passed through a group of filters before it is output in HTML, in order to remove insecure or unwanted parts, correct or enhance the formatting, transform special keywords, etc. A group of filters is referred to as a "text format". Administrators can create as many text formats as needed. Individual filters can be enabled and configured differently for each text format.
Constants
| TYPE_MARKUP_LANGUAGE |
Non-HTML markup language filters that generate HTML. |
| TYPE_HTML_RESTRICTOR |
HTML tag and attribute restricting filters to prevent XSS attacks. |
| TYPE_TRANSFORM_REVERSIBLE |
Reversible transformation filters. |
| TYPE_TRANSFORM_IRREVERSIBLE |
Irreversible transformation filters. |
Methods
Sets the configuration for this plugin instance.
Calculates dependencies for the configured plugin.
Gets the definition of the plugin implementation.
Returns the processing type of this filter plugin.
Returns the administrative label for this filter plugin.
Returns the administrative description for this filter plugin.
Prepares the text for processing.
Performs the filter processing.
Returns HTML allowed by this filter's configuration.
Generates a filter's tip.
Details
array
getConfiguration()
Gets this plugin's configuration.
setConfiguration(array $configuration)
Sets the configuration for this plugin instance.
array
defaultConfiguration()
Gets default configuration for this plugin.
array
calculateDependencies()
Calculates dependencies for the configured plugin.
Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
int
getType()
Returns the processing type of this filter plugin.
string
getLabel()
Returns the administrative label for this filter plugin.
string
getDescription()
Returns the administrative description for this filter plugin.
array
settingsForm(array $form, FormStateInterface $form_state)
Generates a filter's settings form.
string
prepare(string $text, string $langcode)
Prepares the text for processing.
Filters should not use the prepare method for anything other than escaping, because that would short-circuit the control the user has over the order in which filters are applied.
FilterProcessResult
process(string $text, string $langcode)
Performs the filter processing.
array|false
getHTMLRestrictions()
Returns HTML allowed by this filter's configuration.
May be implemented by filters of the FilterInterface::TYPE_HTML_RESTRICTOR type, this won't be used for filters of other types; they should just return FALSE.
This callback function is only necessary for filters that strip away HTML tags (and possibly attributes) and allows other modules to gain insight in a generic manner into which HTML tags and attributes are allowed by a format.
string|null
tips(bool $long = FALSE)
Generates a filter's tip.
A filter's tips should be informative and to the point. Short tips are preferably one-liners.