protected function ConfigImporter::importInvokeOwner in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::importInvokeOwner()
- 9 core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::importInvokeOwner()
Invokes import* methods on configuration entity storage.
Allow modules to take over configuration change operations for higher-level configuration data.
@todo Add support for other extension types; e.g., themes etc.
Parameters
string $collection: The configuration collection.
string $op: The change operation to get the unprocessed list for, either delete, create, rename, or update.
string $name: The name of the configuration to process.
Return value
bool TRUE if the configuration was imported as a configuration entity. FALSE otherwise.
Throws
\Drupal\Core\Entity\EntityStorageException Thrown if the data is owned by an entity type, but the entity storage does not support imports.
File
- core/
lib/ Drupal/ Core/ Config/ ConfigImporter.php, line 972
Class
- ConfigImporter
- Defines a configuration importer.
Namespace
Drupal\Core\ConfigCode
protected function importInvokeOwner($collection, $op, $name) {
// Renames are handled separately.
if ($op == 'rename') {
return $this
->importInvokeRename($collection, $name);
}
// Validate the configuration object name before importing it.
// Config::validateName($name);
if ($entity_type = $this->configManager
->getEntityTypeIdByName($name)) {
$old_config = new Config($name, $this->storageComparer
->getTargetStorage($collection), $this->eventDispatcher, $this->typedConfigManager);
if ($old_data = $this->storageComparer
->getTargetStorage($collection)
->read($name)) {
$old_config
->initWithData($old_data);
}
$data = $this->storageComparer
->getSourceStorage($collection)
->read($name);
$new_config = new Config($name, $this->storageComparer
->getTargetStorage($collection), $this->eventDispatcher, $this->typedConfigManager);
if ($data !== FALSE) {
$new_config
->setData($data);
}
$method = 'import' . ucfirst($op);
$entity_storage = $this->configManager
->getEntityTypeManager()
->getStorage($entity_type);
// Call to the configuration entity's storage to handle the configuration
// change.
if (!$entity_storage instanceof ImportableEntityStorageInterface) {
throw new EntityStorageException(sprintf('The entity storage "%s" for the "%s" entity type does not support imports', get_class($entity_storage), $entity_type));
}
$entity_storage
->{$method}($name, $new_config, $old_config);
$this
->setProcessedConfiguration($collection, $op, $name);
return TRUE;
}
return FALSE;
}