function EntityField::getFieldStorageDefinition
Same name in other branches
- 9 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getFieldStorageDefinition()
- 8.9.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::getFieldStorageDefinition()
- 10 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.
Throws
\Exception If no field storage definition was found for the given entity type and field name.
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 click sorter.
- 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 362
Class
- EntityField
- A field that displays entity field data.
Namespace
Drupal\views\Plugin\views\fieldCode
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();
}
// If there is still no field storage definition found, we are dealing with
// a bundle field. Get the storage from the field definition on the first
// bundle we find which has this field.
$bundles = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
foreach ($bundles as $bundle_id => $bundle) {
$bundle_fields = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $bundle_id);
if (isset($this->definition['field_name']) && isset($bundle_fields[$this->definition['field_name']])) {
return $bundle_fields[$this->definition['field_name']]
->getFieldStorageDefinition();
}
}
throw new \Exception("No field storage definition found for entity type {$this->definition['entity_type']} and field {$this->definition['field_name']} on view {$this->view->storage->id()}");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.