You are here

protected function ParagraphsTrimmedFormatterBase::getSummaryFieldValue in Paragraphs Trimmed 8

Returns the value of the summary field.

2 calls to ParagraphsTrimmedFormatterBase::getSummaryFieldValue()
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 152

Class

ParagraphsTrimmedFormatterBase
Base class for paragraph trimmed formatters.

Namespace

Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter

Code

protected function getSummaryFieldValue($items) {
  $value = '';
  if ($field_name = $this
    ->getSetting('summary_field')) {
    $entity = $items
      ->getEntity();
    $source_field_definition = FieldStorageConfig::loadByName($entity
      ->getEntityTypeId(), $field_name);
    $main_property = $source_field_definition
      ->getMainPropertyName();
    $value = $entity->{$field_name}->{$main_property};
  }
  return $value;
}