Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / filter / src / Plugin / Filter / FilterUrl.php
1 <?php
2
3 namespace Drupal\filter\Plugin\Filter;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\filter\FilterProcessResult;
7 use Drupal\filter\Plugin\FilterBase;
8
9 /**
10  * Provides a filter to convert URLs into links.
11  *
12  * @Filter(
13  *   id = "filter_url",
14  *   title = @Translation("Convert URLs into links"),
15  *   type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
16  *   settings = {
17  *     "filter_url_length" = 72
18  *   }
19  * )
20  */
21 class FilterUrl extends FilterBase {
22
23   /**
24    * {@inheritdoc}
25    */
26   public function settingsForm(array $form, FormStateInterface $form_state) {
27     $form['filter_url_length'] = [
28       '#type' => 'number',
29       '#title' => $this->t('Maximum link text length'),
30       '#default_value' => $this->settings['filter_url_length'],
31       '#min' => 1,
32       '#field_suffix' => $this->t('characters'),
33       '#description' => $this->t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
34     ];
35     return $form;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function process($text, $langcode) {
42     return new FilterProcessResult(_filter_url($text, $this));
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function tips($long = FALSE) {
49     return $this->t('Web page addresses and email addresses turn into links automatically.');
50   }
51
52 }