function TextTrimmedFormatter::preRenderSummary
Same name in other branches
- 9 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::preRenderSummary()
- 10 core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::preRenderSummary()
- 11.x core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextTrimmedFormatter::preRenderSummary()
Pre-render callback: Renders a processed text element's #markup as a summary.
Parameters
array $element: A structured array with the following key-value pairs:
- #markup: the filtered text (as filtered by filter_pre_render_text())
- #format: containing the machine name of the filter format to be used to filter the text. Defaults to the fallback format. See filter_fallback_format().
- #text_summary_trim_length: the desired character length of the summary (used by text_summary())
Return value
array The passed-in element with the filtered text in '#markup' trimmed.
See also
filter_pre_render_text()
File
-
core/
modules/ text/ src/ Plugin/ Field/ FieldFormatter/ TextTrimmedFormatter.php, line 123
Class
- TextTrimmedFormatter
- Plugin implementation of the 'text_trimmed' formatter.
Namespace
Drupal\text\Plugin\Field\FieldFormatterCode
public static function preRenderSummary(array $element) {
$element['#markup'] = text_summary($element['#markup'], $element['#format'], $element['#text_summary_trim_length']);
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.