private function EntityReferenceDisplayFormatterTrait::getDisplayFields in Entity Reference Display 8
Retrieve available display mode fields.
3 calls to EntityReferenceDisplayFormatterTrait::getDisplayFields()
- EntityReferenceDisplayFormatterTrait::settingsForm in src/
Plugin/ Field/ FieldFormatter/ EntityReferenceDisplayFormatterTrait.php - EntityReferenceDisplayFormatterTrait::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ EntityReferenceDisplayFormatterTrait.php - EntityReferenceDisplayFormatterTrait::viewElements in src/
Plugin/ Field/ FieldFormatter/ EntityReferenceDisplayFormatterTrait.php
File
- src/
Plugin/ Field/ FieldFormatter/ EntityReferenceDisplayFormatterTrait.php, line 109
Class
- EntityReferenceDisplayFormatterTrait
- Plugin trait for the 'entity_reference_display' formatters.
Namespace
Drupal\entity_reference_display\Plugin\Field\FieldFormatterCode
private function getDisplayFields() {
$display_fields = [];
// Get all fields associated with current entity.
$entity_type = $this->fieldDefinition
->getTargetEntityTypeId();
$entity_bundle = $this->fieldDefinition
->getTargetBundle();
$entity_fields = \Drupal::service('entity_field.manager')
->getFieldDefinitions($entity_type, $entity_bundle);
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
foreach ($entity_fields as $key => $field) {
// Find display mode fields.
if ($field
->getType() == 'entity_reference_display') {
$display_fields[$key] = $field
->getLabel();
}
}
return $display_fields;
}