You are here

protected function FieldPluginBase::renderTrimText in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::renderTrimText()

Trims the field down to the specified length.

Parameters

array $alter: The alter array of options to use.

  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.

string $value: The string which should be trimmed.

Return value

string The rendered trimmed string.

1 call to FieldPluginBase::renderTrimText()
FieldPluginBase::renderText in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Performs an advanced text render for the item.

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 1374

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

protected function renderTrimText($alter, $value) {
  if (!empty($alter['strip_tags'])) {

    // NOTE: It's possible that some external fields might override the
    // element type.
    $this->definition['element type'] = 'span';
  }
  return static::trimText($alter, $value);
}