You are here

protected function ParagraphsTrimmedFormatterBase::getSummaryFieldOptions in Paragraphs Trimmed 8

Returns the summary field options.

We just let any field on the entity be used as a summary field.

1 call to ParagraphsTrimmedFormatterBase::getSummaryFieldOptions()
ParagraphsTrimmedFormatterBase::settingsForm in src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatterBase.php
Returns a form to configure settings for the formatter.

File

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

Class

ParagraphsTrimmedFormatterBase
Base class for paragraph trimmed formatters.

Namespace

Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter

Code

protected function getSummaryFieldOptions() {
  $options = [
    '' => '- None -',
  ];
  $entity_type_id = $this->fieldDefinition
    ->getTargetEntityTypeId();
  $bundle = $this->fieldDefinition
    ->getTargetBundle();
  $fields = \Drupal::service('entity_field.manager')
    ->getFieldDefinitions($entity_type_id, $bundle);

  // Only show FieldConfig fields
  foreach ($fields as $field_definition) {
    if ($field_definition instanceof FieldConfigInterface) {
      $options[$field_definition
        ->getName()] = $field_definition
        ->getLabel();
    }
  }
  return $options;
}