make it easier to instantiate ConfigImporter

Created on 30 March 2020, over 5 years ago
Updated 19 September 2023, almost 2 years ago

The ConfigImporter needs a ton of services injecting to its constructor.

This is a pain because anything wishing to use it (such as the config UI provided by core's config module, or Drush, or the Config Devel contrib module) has to instantiate that class taking care of getting all the services.

Proposed solution 1: make it a service

AFAICT the reason for not having it as a service is that its constructor also takes the StorageComparer object, which is what actually holds the details of what config should be imported from where.

Could this be changed so a StorageComparer is passed in with a dedicated method, or as a parameter to import()?

We'd have to handle the BC with ConfigImporter::__construct(), but I can envisage an empty service that implements StorageComparerInterface and so that parameter is satisfied:

DummyBCStorageComparerService implements StorageComparerInterface {
// empty methods here to implement the interface as a bare minimum
}

Proposed solution 2: add a factory class

More details pending...

ConfigImporter {

function __construct(StorageComparerInterface $storage_comparer, etc...) {
// Do nothing with $storage_comparer. Param will be removed in Drupal 10.
}

// New method. API change is that this must be called before doing import() or validate() etc.
function setStorageComparer(StorageComparerInterface $storage_comparer) {
}

}
πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 5 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.

Missing content requested by

πŸ‡¦πŸ‡ΊAustralia dpi
over 1 year ago
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024