Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / filter / src / Plugin / Filter / FilterNull.php
1 <?php
2
3 namespace Drupal\filter\Plugin\Filter;
4
5 use Drupal\filter\FilterProcessResult;
6 use Drupal\filter\Plugin\FilterBase;
7
8 /**
9  * Provides a fallback placeholder filter to use for missing filters.
10  *
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.
14  *
15  * @Filter(
16  *   id = "filter_null",
17  *   title = @Translation("Provides a fallback for missing filters. Do not use."),
18  *   type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
19  *   weight = -10
20  * )
21  */
22 class FilterNull extends FilterBase {
23
24   /**
25    * Tracks if an alert about this filter has been logged.
26    *
27    * @var bool
28    */
29   protected $logged = FALSE;
30
31   /**
32    * {@inheritdoc}
33    */
34   public function __construct(array $configuration, $plugin_id, $plugin_definition) {
35     // Once per filter, log that a filter plugin was missing.
36     if (!$this->logged) {
37       $this->logged = TRUE;
38       \Drupal::logger('filter')->alert('Missing filter plugin: %filter.', ['%filter' => $plugin_id]);
39     }
40     parent::__construct($configuration, $plugin_id, $plugin_definition);
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function process($text, $langcode) {
47     return new FilterProcessResult('');
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getHTMLRestrictions() {
54     // Nothing is allowed.
55     return ['allowed' => []];
56   }
57
58   /**
59    * {@inheritdoc}
60    */
61   public function tips($long = FALSE) {
62     return $this->t('Missing filter. All text is removed');
63   }
64
65 }