class FilterUrl

Provides a filter to convert URLs into links.

Plugin annotation


@Filter(
  id = "filter_url",
  module = "filter",
  title = @Translation("Convert URLs into links"),
  type = FILTER_TYPE_MARKUP_LANGUAGE,
  settings = {
    "filter_url_length" = 72
  }
)

Hierarchy

Expanded class hierarchy of FilterUrl

File

drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterUrl.php, line 27
Contains \Drupal\filter\Plugin\Filter\FilterUrl.

Namespace

Drupal\filter\Plugin\Filter
View source
class FilterUrl extends FilterBase {

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, array &$form_state) {
    $form['filter_url_length'] = array(
      '#type' => 'number',
      '#title' => t('Maximum link text length'),
      '#default_value' => $this->settings['filter_url_length'],
      '#min' => 1,
      '#field_suffix' => t('characters'),
      '#description' => 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, $cache, $cache_id) {
    return _filter_url($text, $this);
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
FilterBase::$bag protected property A collection of all filters this filter participates in.
FilterBase::$cache public property A Boolean indicating whether the text processed by this filter may be cached.
FilterBase::$module public property The name of the module that owns this filter.
FilterBase::$plugin_id protected property The plugin ID of this filter.
FilterBase::$settings public property An associative array containing the configured settings of this filter.
FilterBase::$status public property A Boolean indicating whether this filter is enabled.
FilterBase::$weight public property The weight of this filter compared to others in a filter collection.
FilterBase::export public function Exports the complete configuration of this filter plugin instance. Overrides FilterInterface::export
FilterBase::getDescription public function Returns the administrative description for this filter plugin. Overrides FilterInterface::getDescription
FilterBase::getLabel public function Returns the administrative label for this filter plugin. Overrides FilterInterface::getLabel
FilterBase::getType public function Returns the processing type of this filter plugin. Overrides FilterInterface::getType
FilterBase::prepare public function Prepares the text for processing. Overrides FilterInterface::prepare
FilterBase::setPluginConfiguration public function Sets the configuration for this filter plugin instance. Overrides FilterInterface::setPluginConfiguration
FilterBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
FilterUrl::process public function Performs the filter processing. Overrides FilterInterface::process
FilterUrl::settingsForm public function Generates a filter's settings form. Overrides FilterBase::settingsForm
FilterUrl::tips public function Generates a filter's tip. Overrides FilterBase::tips
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId