FieldConfig::getFieldStorageDefinition

public FieldConfig::getFieldStorageDefinition()

Returns the field storage definition.

Return value

\Drupal\Core\Field\FieldStorageDefinitionInterface The field storage definition.

Overrides FieldDefinitionInterface::getFieldStorageDefinition

File

core/modules/field/src/Entity/FieldConfig.php, line 282

Class

FieldConfig
Defines the Field entity.

Namespace

Drupal\field\Entity

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public function getFieldStorageDefinition() {
  if (!$this->fieldStorage) {
    $fields = $this->entityManager()->getFieldStorageDefinitions($this->entity_type);
    if (!isset($fields[$this->field_name])) {
      throw new FieldException("Attempt to create a field {$this->field_name} that does not exist on entity type {$this->entity_type}.");
    }
    if (!$fields[$this->field_name] instanceof FieldStorageConfigInterface) {
      throw new FieldException("Attempt to create a configurable field of non-configurable field storage {$this->field_name}.");
    }
    $this->fieldStorage = $fields[$this->field_name];
  }
 
  return $this->fieldStorage;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.