X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Fsrc%2FFieldConfigStorage.php;fp=web%2Fcore%2Fmodules%2Ffield%2Fsrc%2FFieldConfigStorage.php;h=a0e460f00f9c74d82c13c37a39f12ee1b9e6e46b;hp=42d9634612387c60faff354910e2a6d98315d328;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/field/src/FieldConfigStorage.php b/web/core/modules/field/src/FieldConfigStorage.php index 42d963461..a0e460f00 100644 --- a/web/core/modules/field/src/FieldConfigStorage.php +++ b/web/core/modules/field/src/FieldConfigStorage.php @@ -5,16 +5,16 @@ namespace Drupal\field; use Drupal\Core\Config\Config; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Field\DeletedFieldsRepositoryInterface; use Drupal\Core\Field\FieldConfigStorageBase; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Component\Uuid\UuidInterface; -use Drupal\Core\State\StateInterface; /** - * Controller class for fields. + * Storage handler for field config. */ class FieldConfigStorage extends FieldConfigStorageBase { @@ -26,18 +26,18 @@ class FieldConfigStorage extends FieldConfigStorageBase { protected $entityManager; /** - * The state keyvalue collection. + * The field type plugin manager. * - * @var \Drupal\Core\State\StateInterface + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ - protected $state; + protected $fieldTypeManager; /** - * The field type plugin manager. + * The deleted fields repository. * - * @var \Drupal\Core\Field\FieldTypePluginManagerInterface + * @var \Drupal\Core\Field\DeletedFieldsRepositoryInterface */ - protected $fieldTypeManager; + protected $deletedFieldsRepository; /** * Constructs a FieldConfigStorage object. @@ -52,16 +52,16 @@ class FieldConfigStorage extends FieldConfigStorageBase { * The language manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\State\StateInterface $state - * The state key value store. * @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, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository) { parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); $this->entityManager = $entity_manager; - $this->state = $state; $this->fieldTypeManager = $field_type_manager; + $this->deletedFieldsRepository = $deleted_fields_repository; } /** @@ -74,8 +74,8 @@ class FieldConfigStorage extends FieldConfigStorageBase { $container->get('uuid'), $container->get('language_manager'), $container->get('entity.manager'), - $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 @@ class FieldConfigStorage extends FieldConfigStorageBase { // Get fields stored in configuration. If we are explicitly looking for // deleted fields 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['bundle']) && isset($conditions['field_name'])) { // Optimize for the most frequent case where we do have a specific ID. @@ -117,16 +117,13 @@ class FieldConfigStorage extends FieldConfigStorageBase { } } - // Merge deleted fields (stored in state) if needed. + // Merge deleted fields from the deleted fields repository if needed. if ($include_deleted || !empty($conditions['deleted'])) { - $deleted_fields = $this->state->get('field.field.deleted') ?: []; - $deleted_storages = $this->state->get('field.storage.deleted') ?: []; - foreach ($deleted_fields as $id => $config) { - // If the field storage itself is deleted, inject it directly in the field. - if (isset($deleted_storages[$config['field_storage_uuid']])) { - $config['field_storage'] = $this->entityManager->getStorage('field_storage_config')->create($deleted_storages[$config['field_storage_uuid']]); + $deleted_field_definitions = $this->deletedFieldsRepository->getFieldDefinitions(); + foreach ($deleted_field_definitions as $id => $field_definition) { + if ($field_definition instanceof FieldConfigInterface) { + $fields[$id] = $field_definition; } - $fields[$id] = $this->create($config); } }