You are here

protected function EntityFieldManager::buildFieldStorageDefinitions in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::buildFieldStorageDefinitions()
  2. 10 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::buildFieldStorageDefinitions()

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.

1 call to EntityFieldManager::buildFieldStorageDefinitions()
EntityFieldManager::getFieldStorageDefinitions in core/lib/Drupal/Core/Entity/EntityFieldManager.php
Gets the field storage definitions for a content entity type.

File

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

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;
}