You are here

protected function EntityField::getFieldStorageDefinition 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::getFieldStorageDefinition()

Gets the field storage definition.

Return value

\Drupal\Core\Field\FieldStorageDefinitionInterface The field storage definition used by this handler.

Overrides FieldAPIHandlerTrait::getFieldStorageDefinition

5 calls to EntityField::getFieldStorageDefinition()
EntityField::calculateDependencies in core/modules/views/src/Plugin/views/field/EntityField.php
Calculates dependencies for the configured plugin.
EntityField::clickSort in core/modules/views/src/Plugin/views/field/EntityField.php
Called to determine what to tell the clicksorter.
EntityField::defineOptions in core/modules/views/src/Plugin/views/field/EntityField.php
Information about options for all kinds of purposes will be held here.
EntityField::getCacheTags in core/modules/views/src/Plugin/views/field/EntityField.php
The cache tags associated with this object.
EntityField::query in core/modules/views/src/Plugin/views/field/EntityField.php
Called to add the field to a query.

File

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

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

protected function getFieldStorageDefinition() {
  $entity_type_id = $this->definition['entity_type'];
  $field_storage_definitions = $this->entityFieldManager
    ->getFieldStorageDefinitions($entity_type_id);

  // @todo Unify 'entity field'/'field_name' instead of converting back and
  //   forth. https://www.drupal.org/node/2410779
  if (isset($this->definition['field_name']) && isset($field_storage_definitions[$this->definition['field_name']])) {
    return $field_storage_definitions[$this->definition['field_name']];
  }
  if (isset($this->definition['entity field']) && isset($field_storage_definitions[$this->definition['entity field']])) {
    return $field_storage_definitions[$this->definition['entity field']];
  }

  // The list of field storage definitions above does not include computed
  // base fields, so we need to explicitly fetch a list of all base fields in
  // order to support them.
  // @see \Drupal\Core\Entity\EntityFieldManager::getFieldStorageDefinitions()
  $base_fields = $this->entityFieldManager
    ->getBaseFieldDefinitions($entity_type_id);
  if (isset($this->definition['field_name']) && isset($base_fields[$this->definition['field_name']])) {
    return $base_fields[$this->definition['field_name']]
      ->getFieldStorageDefinition();
  }
}