X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Fsrc%2FFieldStorageConfigStorage.php;h=4d23c9eedbb860d15ecbebac06f59d08dd40bd95;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=7a793f6829ba769f18e9c2e2aa1e7bed8456e3b7;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/field/src/FieldStorageConfigStorage.php b/web/core/modules/field/src/FieldStorageConfigStorage.php index 7a793f682..4d23c9eed 100644 --- a/web/core/modules/field/src/FieldStorageConfigStorage.php +++ b/web/core/modules/field/src/FieldStorageConfigStorage.php @@ -3,19 +3,20 @@ namespace Drupal\field; use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; use Drupal\Core\Config\Entity\ConfigEntityStorage; 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,18 +35,18 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { 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 FieldStorageConfigStorage object. @@ -62,17 +63,19 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { * 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. + * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache + * The memory cache. */ - 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) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_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, MemoryCacheInterface $memory_cache) { + parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; - $this->state = $state; $this->fieldTypeManager = $field_type_manager; + $this->deletedFieldsRepository = $deleted_fields_repository; } /** @@ -86,8 +89,9 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { $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'), + $container->get('entity.memory_cache') ); } @@ -104,7 +108,7 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { // 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 +121,14 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { } } - // 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; + } } }