public function EntityFieldManager::getFieldStorageDefinitions in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::getFieldStorageDefinitions()
- 10 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::getFieldStorageDefinitions()
Gets the field storage definitions for a content entity type.
This returns all field storage definitions for base fields and bundle fields of an entity type. Note that field storage definitions of a base field equal the full base field definition (i.e. they implement FieldDefinitionInterface), while the storage definitions for bundle fields may implement FieldStorageDefinitionInterface only.
Parameters
string $entity_type_id: The entity type ID. Only content entities are supported.
Return value
\Drupal\Core\Field\FieldStorageDefinitionInterface[] The array of field storage definitions for the entity type, keyed by field name.
Overrides EntityFieldManagerInterface::getFieldStorageDefinitions
See also
\Drupal\Core\Field\FieldStorageDefinitionInterface
1 call to EntityFieldManager::getFieldStorageDefinitions()
- EntityFieldManager::getActiveFieldStorageDefinitions in core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php - Gets the active field storage definitions for a content entity type.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php, line 432
Class
- EntityFieldManager
- Manages the discovery of entity fields.
Namespace
Drupal\Core\EntityCode
public function getFieldStorageDefinitions($entity_type_id) {
if (!isset($this->fieldStorageDefinitions[$entity_type_id])) {
$this->fieldStorageDefinitions[$entity_type_id] = [];
// Add all non-computed base fields.
foreach ($this
->getBaseFieldDefinitions($entity_type_id) as $field_name => $definition) {
if (!$definition
->isComputed()) {
$this->fieldStorageDefinitions[$entity_type_id][$field_name] = $definition;
}
}
// Not prepared, try to load from cache.
$cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager
->getCurrentLanguage()
->getId();
if ($cache = $this
->cacheGet($cid)) {
$field_storage_definitions = $cache->data;
}
else {
// Rebuild the definitions and put it into the cache.
$field_storage_definitions = $this
->buildFieldStorageDefinitions($entity_type_id);
$this
->cacheSet($cid, $field_storage_definitions, Cache::PERMANENT, [
'entity_types',
'entity_field_info',
]);
}
$this->fieldStorageDefinitions[$entity_type_id] += $field_storage_definitions;
}
return $this->fieldStorageDefinitions[$entity_type_id];
}