protected function FieldFormatterFromViewDisplay::getViewDisplay in (Entity Reference) Field Formatters 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/FieldFormatterFromViewDisplay.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterFromViewDisplay::getViewDisplay()
- 3.x src/Plugin/Field/FieldFormatter/FieldFormatterFromViewDisplay.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterFromViewDisplay::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/ FieldFormatterFromViewDisplay.php, line 124
Class
- FieldFormatterFromViewDisplay
- Plugin implementation of the 'link' formatter.
Namespace
Drupal\field_formatter\Plugin\Field\FieldFormatterCode
protected function getViewDisplay($bundle_id) {
if (!isset($this->viewDisplay[$bundle_id])) {
$field_name = $this
->getSetting('field_name');
$entity_type_id = $this->fieldDefinition
->getSetting('target_type');
if (($view_mode = $this
->getSetting('view_mode')) && ($view_display = EntityViewDisplay::load($entity_type_id . '.' . $bundle_id . '.' . $view_mode))) {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
$components = $view_display
->getComponents();
foreach ($components as $component_name => $component) {
if ($component_name != $field_name) {
$view_display
->removeComponent($component_name);
}
}
$this->viewDisplay[$bundle_id] = $view_display;
}
}
return $this->viewDisplay[$bundle_id];
}