function FieldConfig::getFieldStorageDefinition
Same name in other branches
- 9 core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::getFieldStorageDefinition()
- 8.9.x core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::getFieldStorageDefinition()
- 10 core/modules/field/src/Entity/FieldConfig.php \Drupal\field\Entity\FieldConfig::getFieldStorageDefinition()
Overrides FieldDefinitionInterface::getFieldStorageDefinition
2 calls to FieldConfig::getFieldStorageDefinition()
- FieldConfig::postCreate in core/
modules/ field/ src/ Entity/ FieldConfig.php - FieldConfig::preSave in core/
modules/ field/ src/ Entity/ FieldConfig.php - Overrides \Drupal\Core\Entity\EntityBase::preSave().
File
-
core/
modules/ field/ src/ Entity/ FieldConfig.php, line 303
Class
- FieldConfig
- Defines the Field entity.
Namespace
Drupal\field\EntityCode
public function getFieldStorageDefinition() {
if (!$this->fieldStorage) {
$field_storage_definition = NULL;
$field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($this->entity_type);
if (isset($field_storage_definitions[$this->field_name])) {
$field_storage_definition = $field_storage_definitions[$this->field_name];
}
elseif ($this->deleted) {
$deleted_storage_definitions = \Drupal::service('entity_field.deleted_fields_repository')->getFieldStorageDefinitions();
foreach ($deleted_storage_definitions as $deleted_storage_definition) {
if ($deleted_storage_definition->getName() === $this->field_name) {
$field_storage_definition = $deleted_storage_definition;
}
}
}
if (!$field_storage_definition) {
throw new FieldException("Attempted to create, modify or delete an instance of field with name {$this->field_name} on entity type {$this->entity_type} when the field storage does not exist.");
}
if (!$field_storage_definition instanceof FieldStorageConfigInterface) {
throw new FieldException("Attempted to create, modify or delete a configurable field of non-configurable field storage {$this->field_name}.");
}
$this->fieldStorage = $field_storage_definition;
}
return $this->fieldStorage;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.