public function ViewModeFieldFormatter::getFieldFormatter in Entity Embed 8
Constructs a field formatter.
Return value
\Drupal\Core\Field\FormatterInterface The formatter object.
Overrides FieldFormatterEntityEmbedDisplayBase::getFieldFormatter
File
- src/
Plugin/ entity_embed/ EntityEmbedDisplay/ ViewModeFieldFormatter.php, line 24
Class
- ViewModeFieldFormatter
- Entity Embed Display reusing entity reference field formatters.
Namespace
Drupal\entity_embed\Plugin\entity_embed\EntityEmbedDisplayCode
public function getFieldFormatter() {
if (!isset($this->fieldFormatter)) {
$display = [
'type' => $this
->getFieldFormatterId(),
'settings' => [
'view_mode' => $this
->getPluginDefinition()['view_mode'],
],
'label' => 'hidden',
];
// Create the formatter plugin. Will use the default formatter for that
// field type if none is passed.
$this->fieldFormatter = $this->formatterPluginManager
->getInstance([
'field_definition' => $this
->getFieldDefinition(),
'view_mode' => '_entity_embed',
'configuration' => $display,
]);
}
return $this->fieldFormatter;
}