Change record status: 
Project: 
Introduced in branch: 
8.0.x
Description: 

The procedural functions in Field API to sanitize strings have been replaced by AllowedTagsXssTrait.

Following functions have been removed:

  • field_filter_xss
  • _field_filter_xss_allowed_tags
  • _field_filter_xss_display_allowed_tags

You can now use Drupal\Core\Field\AllowedTagsXssTrait and the following methods:

  • fieldFilterXss
  • allowedTags
  • displayAllowedTags

Drupal 7

function number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  if ($settings['prefix_suffix']) {
    $prefixes = isset($instance['settings']['prefix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['prefix'])) : array('');
  }
}

Drupal 8

use Drupal\Core\Field\AllowedTagsXssTrait;

abstract class NumericFormatterBase extends FormatterBase {

  use AllowedTagsXssTrait;

  public function viewElements(FieldItemListInterface $items) {
    if ($this->getSetting('prefix_suffix')) {
       $prefixes = isset($settings['prefix']) ? array_map(array($this, 'fieldFilterXss'), explode('|', $settings['prefix'])) : array('');
    }
  }
}

Comments

Anonymous’s picture

This is freakin' ugly!