You are here

protected function FieldFormatterWithInlineSettings::getViewDisplay in (Entity Reference) Field Formatters 8

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

Gets entity view display for a bundle.

Parameters

string $bundle_id: The bundle ID.

Return value

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

Overrides FieldFormatterBase::getViewDisplay

File

src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php, line 311

Class

FieldFormatterWithInlineSettings
Plugin implementation of the 'link' formatter.

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
        ->getSetting('target_type'),
      'bundle' => $bundle_id,
      'status' => TRUE,
    ]);
    $display
      ->setComponent($this
      ->getSetting('field_name'), [
      'type' => $this
        ->getSetting('type'),
      'settings' => $this
        ->getSetting('settings'),
      'label' => $this
        ->getSetting('label'),
    ]);
    $this->viewDisplay[$bundle_id] = $display;
  }
  return $this->viewDisplay[$bundle_id];
}