X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityDefinitionUpdateManager.php;h=c5d0abd5028ae456ad6b1c417781afe66e604493;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=70dec2c27e34d9bc4291358a58a77d74dd7dbbed;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php b/web/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php index 70dec2c27..c5d0abd50 100644 --- a/web/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php +++ b/web/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php @@ -21,14 +21,29 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte */ protected $entityManager; + /** + * The last installed schema repository. + * + * @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface + */ + protected $entityLastInstalledSchemaRepository; + /** * Constructs a new EntityDefinitionUpdateManager. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository + * The last installed schema repository service. */ - public function __construct(EntityManagerInterface $entity_manager) { + public function __construct(EntityManagerInterface $entity_manager, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository = NULL) { $this->entityManager = $entity_manager; + + if (!isset($entity_last_installed_schema_repository)) { + @trigger_error('The $entity_last_installed_schema_repository parameter was added in Drupal 8.6.x and will be required in 9.0.0. See https://www.drupal.org/node/2973262.', E_USER_DEPRECATED); + $entity_last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository'); + } + $this->entityLastInstalledSchemaRepository = $entity_last_installed_schema_repository; } /** @@ -63,7 +78,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte // Process field storage definition changes. if (!empty($change_list['field_storage_definitions'])) { $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); - $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id); + $original_storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); foreach ($change_list['field_storage_definitions'] as $field_name => $change) { switch ($change) { @@ -108,7 +123,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte // Process field storage definition changes. if (!empty($change_list['field_storage_definitions'])) { $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); - $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id); + $original_storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); foreach ($change_list['field_storage_definitions'] as $field_name => $change) { $storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL; @@ -123,10 +138,17 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte * {@inheritdoc} */ public function getEntityType($entity_type_id) { - $entity_type = $this->entityManager->getLastInstalledDefinition($entity_type_id); + $entity_type = $this->entityLastInstalledSchemaRepository->getLastInstalledDefinition($entity_type_id); return $entity_type ? clone $entity_type : NULL; } + /** + * {@inheritdoc} + */ + public function getEntityTypes() { + return $this->entityLastInstalledSchemaRepository->getLastInstalledDefinitions(); + } + /** * {@inheritdoc} */ @@ -173,7 +195,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte * {@inheritdoc} */ public function getFieldStorageDefinition($name, $entity_type_id) { - $storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id); + $storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); return isset($storage_definitions[$name]) ? clone $storage_definitions[$name] : NULL; } @@ -211,7 +233,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte break; case static::DEFINITION_UPDATED: - $original = $this->entityManager->getLastInstalledDefinition($entity_type_id); + $original = $this->entityLastInstalledSchemaRepository->getLastInstalledDefinition($entity_type_id); $this->entityManager->onEntityTypeUpdate($entity_type, $original); break; } @@ -262,7 +284,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte $change_list = []; foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { - $original = $this->entityManager->getLastInstalledDefinition($entity_type_id); + $original = $this->entityLastInstalledSchemaRepository->getLastInstalledDefinition($entity_type_id); // @todo Support non-storage-schema-changing definition updates too: // https://www.drupal.org/node/2336895. @@ -277,7 +299,7 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte if ($this->entityManager->getStorage($entity_type_id) instanceof DynamicallyFieldableEntityStorageInterface) { $field_changes = []; $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); - $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id); + $original_storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); // Detect created field storage definitions. foreach (array_diff_key($storage_definitions, $original_storage_definitions) as $field_name => $storage_definition) { @@ -311,7 +333,8 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte } // @todo Support deleting entity definitions when we support base field - // purging. See https://www.drupal.org/node/2282119. + // purging. + // @see https://www.drupal.org/node/2907779 $this->entityManager->useCaches(TRUE);