Mercurial > hg > isophonics-drupal-site
comparison core/modules/field/src/Entity/FieldStorageConfig.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
396 | 396 |
397 /** | 397 /** |
398 * {@inheritdoc} | 398 * {@inheritdoc} |
399 */ | 399 */ |
400 public static function preDelete(EntityStorageInterface $storage, array $field_storages) { | 400 public static function preDelete(EntityStorageInterface $storage, array $field_storages) { |
401 $state = \Drupal::state(); | 401 /** @var \Drupal\Core\Field\DeletedFieldsRepositoryInterface $deleted_fields_repository */ |
402 $deleted_fields_repository = \Drupal::service('entity_field.deleted_fields_repository'); | |
402 | 403 |
403 // Set the static flag so that we don't delete field storages whilst | 404 // Set the static flag so that we don't delete field storages whilst |
404 // deleting fields. | 405 // deleting fields. |
405 static::$inDeletion = TRUE; | 406 static::$inDeletion = TRUE; |
406 | 407 |
407 // Delete or fix any configuration that is dependent, for example, fields. | 408 // Delete or fix any configuration that is dependent, for example, fields. |
408 parent::preDelete($storage, $field_storages); | 409 parent::preDelete($storage, $field_storages); |
409 | 410 |
410 // Keep the field definitions in the state storage so we can use them later | 411 // Keep the field storage definitions in the deleted fields repository so we |
411 // during field_purge_batch(). | 412 // can use them later during field_purge_batch(). |
412 $deleted_storages = $state->get('field.storage.deleted') ?: []; | |
413 /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ | 413 /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ |
414 foreach ($field_storages as $field_storage) { | 414 foreach ($field_storages as $field_storage) { |
415 // Only mark a field for purging if there is data. Otherwise, just remove | 415 // Only mark a field for purging if there is data. Otherwise, just remove |
416 // it. | 416 // it. |
417 $target_entity_storage = \Drupal::entityTypeManager()->getStorage($field_storage->getTargetEntityTypeId()); | 417 $target_entity_storage = \Drupal::entityTypeManager()->getStorage($field_storage->getTargetEntityTypeId()); |
418 if (!$field_storage->deleted && $target_entity_storage instanceof FieldableEntityStorageInterface && $target_entity_storage->countFieldData($field_storage, TRUE)) { | 418 if (!$field_storage->deleted && $target_entity_storage instanceof FieldableEntityStorageInterface && $target_entity_storage->countFieldData($field_storage, TRUE)) { |
419 $config = $field_storage->toArray(); | 419 $storage_definition = clone $field_storage; |
420 $config['deleted'] = TRUE; | 420 $storage_definition->deleted = TRUE; |
421 $config['bundles'] = $field_storage->getBundles(); | 421 $deleted_fields_repository->addFieldStorageDefinition($storage_definition); |
422 $deleted_storages[$field_storage->uuid()] = $config; | |
423 } | 422 } |
424 } | 423 } |
425 | |
426 $state->set('field.storage.deleted', $deleted_storages); | |
427 } | 424 } |
428 | 425 |
429 /** | 426 /** |
430 * {@inheritdoc} | 427 * {@inheritdoc} |
431 */ | 428 */ |