3 namespace Drupal\filter\Plugin\Filter;
5 use Drupal\filter\FilterProcessResult;
6 use Drupal\filter\Plugin\FilterBase;
9 * Provides a fallback placeholder filter to use for missing filters.
11 * The filter system uses this filter to replace missing filters (for example,
12 * if a filter module has been disabled) that are still part of defined text
13 * formats. It returns an empty string.
17 * title = @Translation("Provides a fallback for missing filters. Do not use."),
18 * type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
22 class FilterNull extends FilterBase {
25 * Tracks if an alert about this filter has been logged.
29 protected $logged = FALSE;
34 public function __construct(array $configuration, $plugin_id, $plugin_definition) {
35 // Once per filter, log that a filter plugin was missing.
38 \Drupal::logger('filter')->alert('Missing filter plugin: %filter.', ['%filter' => $plugin_id]);
40 parent::__construct($configuration, $plugin_id, $plugin_definition);
46 public function process($text, $langcode) {
47 return new FilterProcessResult('');
53 public function getHTMLRestrictions() {
54 // Nothing is allowed.
55 return ['allowed' => []];
61 public function tips($long = FALSE) {
62 return $this->t('Missing filter. All text is removed');