You are here

protected function FieldWrapperBase::getViewDisplay in (Entity Reference) Field Formatters 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/FieldWrapperBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldWrapperBase::getViewDisplay()
  2. 3.x src/Plugin/Field/FieldFormatter/FieldWrapperBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldWrapperBase::getViewDisplay()

Returns a view display object used to render the content of the field.

Parameters

string $bundle_id: The bundle ID.

Return value

\Drupal\Core\Entity\Display\EntityViewDisplayInterface Entity view display.

File

src/Plugin/Field/FieldFormatter/FieldWrapperBase.php, line 257

Class

FieldWrapperBase
Wraps an existing field.

Namespace

Drupal\field_formatter\Plugin\Field\FieldFormatter

Code

protected function getViewDisplay($bundle_id) {
  if (!isset($this->viewDisplay[$bundle_id])) {
    $display = EntityViewDisplay::create([
      'targetEntityType' => $this->fieldDefinition
        ->getTargetEntityTypeId(),
      'bundle' => $bundle_id,
      'status' => TRUE,
    ]);
    $display
      ->setComponent($this->fieldDefinition
      ->getName(), [
      'type' => $this
        ->getSetting('type'),
      'settings' => $this
        ->getSetting('settings'),
    ]);
    $this->viewDisplay[$bundle_id] = $display;
  }
  return $this->viewDisplay[$bundle_id];
}