You are here

public function ContentTranslationUpdatesManager::updateDefinitions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/ContentTranslationUpdatesManager.php \Drupal\content_translation\ContentTranslationUpdatesManager::updateDefinitions()

Executes field storage definition updates if needed.

Parameters

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

1 call to ContentTranslationUpdatesManager::updateDefinitions()
ContentTranslationUpdatesManager::onConfigImporterImport in core/modules/content_translation/src/ContentTranslationUpdatesManager.php
Listener for the ConfigImporter import event.

File

core/modules/content_translation/src/ContentTranslationUpdatesManager.php, line 54
Contains \Drupal\content_translation\ContentTranslationUpdatesManager.

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.
  // @todo Generalize this code in https://www.drupal.org/node/2346013.
  // @todo Handle initial values in https://www.drupal.org/node/2346019.
  if ($this->updateManager
    ->needsUpdates()) {
    foreach ($entity_types as $entity_type_id => $entity_type) {
      $storage_definitions = $this->entityManager
        ->getFieldStorageDefinitions($entity_type_id);
      $installed_storage_definitions = $this->entityManager
        ->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);
        }
      }
    }
  }
}