EntityFieldManager::buildFieldStorageDefinitions

protected EntityFieldManager::buildFieldStorageDefinitions($entity_type_id)

Builds field storage definitions for an entity type.

Parameters

string $entity_type_id: The entity type ID. Only entity types that implement \Drupal\Core\Entity\FieldableEntityInterface are supported

Return value

\Drupal\Core\Field\FieldStorageDefinitionInterface[] An array of field storage definitions, keyed by field name.

File

core/lib/Drupal/Core/Entity/EntityFieldManager.php, line 504

Class

EntityFieldManager
Manages the discovery of entity fields.

Namespace

Drupal\Core\Entity

Code

protected function buildFieldStorageDefinitions($entity_type_id) {
  $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
  $field_definitions = [];

  // Retrieve base field definitions from modules.
  foreach ($this->moduleHandler->getImplementations('entity_field_storage_info') as $module) {
    $module_definitions = $this->moduleHandler->invoke($module, 'entity_field_storage_info', [$entity_type]);
    if (!empty($module_definitions)) {
      // Ensure the provider key actually matches the name of the provider
      // defining the field.
      foreach ($module_definitions as $field_name => $definition) {
        // @todo Remove this check once FieldDefinitionInterface exposes a
        //  proper provider setter. See https://www.drupal.org/node/2225961.
        if ($definition instanceof BaseFieldDefinition) {
          $definition->setProvider($module);
        }
        $field_definitions[$field_name] = $definition;
      }
    }
  }

  // Invoke alter hook.
  $this->moduleHandler->alter('entity_field_storage_info', $field_definitions, $entity_type);

  return $field_definitions;
}
doc_Drupal
2016-10-29 09:05:59
Comments
Leave a Comment

Please login to continue.