You are here

protected function ParagraphsTrimmedFormatterBase::getSummaryFieldElement in Paragraphs Trimmed 8

Get the render element for the summary field.

2 calls to ParagraphsTrimmedFormatterBase::getSummaryFieldElement()
ParagraphsSmartTrimFormatter::viewElements in modules/paragraphs_smart_trim/src/Plugin/Field/FieldFormatter/ParagraphsSmartTrimFormatter.php
Builds a renderable array for a field value.
ParagraphsTrimmedFormatter::viewElements in src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatterBase.php, line 168

Class

ParagraphsTrimmedFormatterBase
Base class for paragraph trimmed formatters.

Namespace

Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter

Code

protected function getSummaryFieldElement($items) {
  $value = '';
  if ($field_name = $this
    ->getSetting('summary_field')) {
    $entity = $items
      ->getEntity();

    // Render using the default field formatter.
    $value = $entity->{$field_name}
      ->view([
      'label_display' => 'hidden',
    ]);
  }
  return $value;
}