function EntityField::getFormatterInstance

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getFormatterInstance()
  2. 10 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getFormatterInstance()
  3. 11.x 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 option form that provides 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.