ConfigEntityStorage::importUpdate

public ConfigEntityStorage::importUpdate($name, Config $new_config, Config $old_config)

Updates entities upon synchronizing configuration changes.

Parameters

string $name: The name of the configuration object.

\Drupal\Core\Config\Config $new_config: A configuration object containing the new configuration data.

\Drupal\Core\Config\Config $old_config: A configuration object containing the old configuration data.

Throws

\Drupal\Core\Config\ConfigImporterException Thrown when the config entity that should be updated can not be found.

Overrides ImportableEntityStorageInterface::importUpdate

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php, line 393

Class

ConfigEntityStorage
Defines the storage class for configuration entities.

Namespace

Drupal\Core\Config\Entity

Code

public function importUpdate($name, Config $new_config, Config $old_config) {
  $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
  $entity = $this->load($id);
  if (!$entity) {
    throw new ConfigImporterException("Attempt to update non-existing entity '$id'.");
  }
  $entity->setSyncing(TRUE);
  $entity = $this->updateFromStorageRecord($entity, $new_config->get());
  $entity->save();
  return TRUE;
}
doc_Drupal
2016-10-29 08:52:55
Comments
Leave a Comment

Please login to continue.