function ContentTranslationUpdatesManager::updateDefinitions

Executes field storage definition updates if needed.

Parameters

array $entity_types: A list of entity type definitions to be processed.

File

core/modules/content_translation/src/ContentTranslationUpdatesManager.php, line 81

Class

ContentTranslationUpdatesManager
Provides the logic needed to update field storage definitions when needed.

Namespace

Drupal\content_translation

Code

public function updateDefinitions(array $entity_types) {
    // Handle field storage definition creation, if needed.
    if ($this->updateManager
        ->needsUpdates()) {
        foreach ($entity_types as $entity_type_id => $entity_type) {
            $storage_definitions = $this->entityFieldManager
                ->getFieldStorageDefinitions($entity_type_id);
            $installed_storage_definitions = $this->entityLastInstalledSchemaRepository
                ->getLastInstalledFieldStorageDefinitions($entity_type_id);
            foreach (array_diff_key($storage_definitions, $installed_storage_definitions) as $storage_definition) {
                
                /** @var $storage_definition \Drupal\Core\Field\FieldStorageDefinitionInterface */
                if ($storage_definition->getProvider() == 'content_translation') {
                    $this->updateManager
                        ->installFieldStorageDefinition($storage_definition->getName(), $entity_type_id, 'content_translation', $storage_definition);
                }
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.