ConfigImporter
class ConfigImporter (View source)
Defines a configuration importer.
A config importer imports the changes into the configuration system. To determine which changes to import a StorageComparer in used.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Provides dependency injection friendly methods for serialization.
Constants
| LOCK_NAME |
The name used to identify the lock. |
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected StorageComparerInterface | $storageComparer | The storage comparer used to discover configuration changes. |
|
| protected EventDispatcherInterface | $eventDispatcher | The event dispatcher used to notify subscribers. |
|
| protected ConfigManagerInterface | $configManager | The configuration manager. |
|
| protected LockBackendInterface | $lock | The used lock backend instance. |
|
| protected TypedConfigManagerInterface | $typedConfigManager | The typed config manager. |
|
| protected array | $processedConfiguration | List of configuration file changes processed by the import(). |
|
| protected array | $processedExtensions | List of extension changes processed by the import(). |
|
| protected array | $extensionChangelist | List of extension changes to be processed by the import(). |
|
| protected bool | $validated | Indicates changes to import have been validated. |
|
| protected ModuleHandlerInterface | $moduleHandler | The module handler. |
|
| protected ThemeHandlerInterface | $themeHandler | The theme handler. |
|
| protected bool | $processedSystemTheme | Flag set to import system.theme during processing theme install and uninstalls. |
|
| protected array | $errors | A log of any errors encountered. |
|
| protected int | $totalExtensionsToProcess | The total number of extensions to process. |
|
| protected int | $totalConfigurationToProcess | The total number of configuration objects to process. |
|
| protected ModuleInstallerInterface | $moduleInstaller | The module installer. |
|
| protected ModuleExtensionList | $moduleExtensionList | The module extension list. |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Constructs a configuration import object.
Logs an error message.
Returns error messages created while running the import.
Gets the configuration storage comparer.
Resets the storage comparer and processed list.
Gets an empty list of extensions to process.
Checks if there are any unprocessed configuration changes.
Gets list of processed changes.
Sets a change as processed.
Gets a list of unprocessed changes for a given operation.
Gets list of processed extension changes.
Sets an extension change as processed.
Populates the extension change list.
Gets a list changes for extensions.
Gets a list of unprocessed changes for extensions.
Imports the changelist to the target storage.
Calls a config import step.
Initializes the config importer in preparation for processing a batch.
Gets the next extension operation to perform.
Gets the next configuration operation to perform.
Dispatches validate event for a ConfigImporter object.
Processes a configuration change.
Processes an extension change.
Checks that the operation is still valid.
Writes a configuration change from the source to the target storage.
Invokes import* methods on configuration entity storage.
Imports a configuration entity rename.
Determines if an import is already running.
Gets all the service dependencies from \Drupal.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
__construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, TranslationInterface $string_translation, ModuleExtensionList $extension_list_module)
Constructs a configuration import object.
logError(string $message)
Logs an error message.
array
getErrors()
Returns error messages created while running the import.
StorageComparerInterface
getStorageComparer()
Gets the configuration storage comparer.
$this
reset()
Resets the storage comparer and processed list.
protected array
getEmptyExtensionsProcessedList()
Gets an empty list of extensions to process.
bool
hasUnprocessedConfigurationChanges()
Checks if there are any unprocessed configuration changes.
array
getProcessedConfiguration(string $collection = StorageInterface::DEFAULT_COLLECTION)
Gets list of processed changes.
protected
setProcessedConfiguration(string $collection, string $op, string $name)
Sets a change as processed.
array
getUnprocessedConfiguration(string $op, string $collection = StorageInterface::DEFAULT_COLLECTION)
Gets a list of unprocessed changes for a given operation.
array
getProcessedExtensions()
Gets list of processed extension changes.
protected
setProcessedExtension(string $type, string $op, string $name)
Sets an extension change as processed.
protected
createExtensionChangelist()
Populates the extension change list.
array
getExtensionChangelist(string $type, string $op = NULL)
Gets a list changes for extensions.
protected array
getUnprocessedExtensions(string $type)
Gets a list of unprocessed changes for extensions.
$this
import()
Imports the changelist to the target storage.
doSyncStep(string|callable $sync_step, array $context)
Calls a config import step.
array
initialize()
Initializes the config importer in preparation for processing a batch.
protected
processExtensions(array|ArrayAccess $context)
Processes extensions as a batch operation.
protected
processConfigurations(array|ArrayAccess $context)
Processes configuration as a batch operation.
protected
processMissingContent(array|ArrayAccess $context)
Handles processing of missing content.
protected
finish(array|ArrayAccess $context)
Finishes the batch.
protected array|bool
getNextExtensionOperation()
Gets the next extension operation to perform.
protected array|bool
getNextConfigurationOperation()
Gets the next configuration operation to perform.
validate()
Dispatches validate event for a ConfigImporter object.
Events should throw a \Drupal\Core\Config\ConfigImporterException to prevent an import from occurring.
protected
processConfiguration(string $collection, string $op, string $name)
Processes a configuration change.
protected
processExtension(string $type, string $op, string $name)
Processes an extension change.
protected bool
checkOp(string $collection, string $op, string $name)
Checks that the operation is still valid.
During a configuration import secondary writes and deletes are possible. This method checks that the operation is still valid before processing a configuration change.
protected
importConfig(string $collection, string $op, string $name)
Writes a configuration change from the source to the target storage.
protected bool
importInvokeOwner(string $collection, string $op, string $name)
Invokes import* methods on configuration entity storage.
Allow modules to take over configuration change operations for higher-level configuration data.
protected bool
importInvokeRename(string $collection, string $rename_name)
Imports a configuration entity rename.
bool
alreadyImporting()
Determines if an import is already running.
protected
reInjectMe()
Gets all the service dependencies from \Drupal.
Since the ConfigImporter handles module installation the kernel and the container can be rebuilt and altered during processing. It is necessary to keep the services used by the importer in sync.