protected function FieldWrapperBase::getViewDisplay in (Entity Reference) Field Formatters 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/FieldWrapperBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldWrapperBase::getViewDisplay()
- 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 271
Class
- FieldWrapperBase
- Wraps an existing field.
Namespace
Drupal\field_formatter\Plugin\Field\FieldFormatterCode
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];
}