Mercurial > hg > isophonics-drupal-site
diff core/modules/field/src/FieldStorageConfigStorage.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 |
line wrap: on
line diff
--- a/core/modules/field/src/FieldStorageConfigStorage.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/modules/field/src/FieldStorageConfigStorage.php Mon Apr 23 09:46:53 2018 +0100 @@ -7,15 +7,15 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Field\DeletedFieldsRepositoryInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\State\StateInterface; /** - * Controller class for "field storage" configuration entities. + * Storage handler for "field storage" configuration entities. */ class FieldStorageConfigStorage extends ConfigEntityStorage { @@ -34,13 +34,6 @@ protected $entityManager; /** - * The state keyvalue collection. - * - * @var \Drupal\Core\State\StateInterface - */ - protected $state; - - /** * The field type plugin manager. * * @var \Drupal\Core\Field\FieldTypePluginManagerInterface @@ -48,6 +41,13 @@ protected $fieldTypeManager; /** + * The deleted fields repository. + * + * @var \Drupal\Core\Field\DeletedFieldsRepositoryInterface + */ + protected $deletedFieldsRepository; + + /** * Constructs a FieldStorageConfigStorage object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -62,17 +62,17 @@ * The entity manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\State\StateInterface $state - * The state key value store. - * @param \Drupal\Component\Plugin\PluginManagerInterface\FieldTypePluginManagerInterface $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager. + * @param \Drupal\Core\Field\DeletedFieldsRepositoryInterface $deleted_fields_repository + * The deleted fields repository. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository) { parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; - $this->state = $state; $this->fieldTypeManager = $field_type_manager; + $this->deletedFieldsRepository = $deleted_fields_repository; } /** @@ -86,8 +86,8 @@ $container->get('language_manager'), $container->get('entity.manager'), $container->get('module_handler'), - $container->get('state'), - $container->get('plugin.manager.field.field_type') + $container->get('plugin.manager.field.field_type'), + $container->get('entity_field.deleted_fields_repository') ); } @@ -104,7 +104,7 @@ // Get field storages living in configuration. If we are explicitly looking // for deleted storages only, this can be skipped, because they will be - // retrieved from state below. + // retrieved from the deleted fields repository below. if (empty($conditions['deleted'])) { if (isset($conditions['entity_type']) && isset($conditions['field_name'])) { // Optimize for the most frequent case where we do have a specific ID. @@ -117,11 +117,14 @@ } } - // Merge deleted field storages (living in state) if needed. + // Merge deleted field storage definitions from the deleted fields + // repository if needed. if ($include_deleted || !empty($conditions['deleted'])) { - $deleted_storages = $this->state->get('field.storage.deleted') ?: []; - foreach ($deleted_storages as $id => $config) { - $storages[$id] = $this->create($config); + $deleted_storage_definitions = $this->deletedFieldsRepository->getFieldStorageDefinitions(); + foreach ($deleted_storage_definitions as $id => $field_storage_definition) { + if ($field_storage_definition instanceof FieldStorageConfigInterface) { + $storages[$id] = $field_storage_definition; + } } }