_filter_url example

// Get FilterUrl object.     $filter = $this->filters['filter_url'];
    $filter->setConfiguration([
      'settings' => [
        'filter_url_length' => 496,
      ],
    ]);
    $path = __DIR__ . '/../..';

    $input = file_get_contents($path . '/filter.url-input.txt');
    $expected = file_get_contents($path . '/filter.url-output.txt');
    $result = _filter_url($input$filter);
    $this->assertSame($expected$result, 'Complex HTML document was correctly processed.');

    $pcre_backtrack_limit = ini_get('pcre.backtrack_limit');
    // Setting this limit to the smallest possible value should cause PCRE     // errors and break the various preg_* functions used by _filter_url().     ini_set('pcre.backtrack_limit', 1);

    // If PCRE errors occur, _filter_url() should return the exact same text.     // Case of a small and simple HTML document.     $input = $expected = '<p>www.test.com</p>';
    $result = _filter_url($input$filter);
    
'#min' => 1,
      '#field_suffix' => $this->t('characters'),
      '#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.'),
    ];
    return $form;
  }

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    return new FilterProcessResult(_filter_url($text$this));
  }

  /** * {@inheritdoc} */
  public function tips($long = FALSE) {
    return $this->t('Web page addresses and email addresses turn into links automatically.');
  }

}
Home | Imprint | This part of the site doesn't use cookies.