You are here

protected function EntityField::getFormatterInstance in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getFormatterInstance()

Returns the field formatter instance.

Return value

\Drupal\Core\Field\FormatterInterface|null The field formatter instance.

2 calls to EntityField::getFormatterInstance()
EntityField::buildOptionsForm in core/modules/views/src/Plugin/views/field/EntityField.php
Default options form that provides the label widget that all fields should have.
EntityField::calculateDependencies in core/modules/views/src/Plugin/views/field/EntityField.php
Calculates dependencies for the configured plugin.

File

core/modules/views/src/Plugin/views/field/EntityField.php, line 985

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

protected function getFormatterInstance($format = NULL) {
  if (!isset($format)) {
    $format = $this->options['type'];
  }
  $settings = $this->options['settings'] + $this->formatterPluginManager
    ->getDefaultSettings($format);
  $options = [
    'field_definition' => $this
      ->getFieldDefinition(),
    'configuration' => [
      'type' => $format,
      'settings' => $settings,
      'label' => '',
      'weight' => 0,
    ],
    'view_mode' => '_custom',
  ];
  return $this->formatterPluginManager
    ->getInstance($options);
}