protected function StorageComparer::addChangelistUpdate in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Config/StorageComparer.php \Drupal\Core\Config\StorageComparer::addChangelistUpdate()
Creates the update changelist.
The list of updates is sorted so that dependencies are created before configuration entities that depend on them. For example, field storages should be updated before fields.
Parameters
string $collection: The storage collection to operate on.
1 call to StorageComparer::addChangelistUpdate()
- StorageComparer::createChangelist in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php
File
- core/
lib/ Drupal/ Core/ Config/ StorageComparer.php, line 252
Class
- StorageComparer
- Defines a config storage comparer.
Namespace
Drupal\Core\ConfigCode
protected function addChangelistUpdate($collection) {
$recreates = [];
foreach (array_intersect($this->sourceNames[$collection], $this->targetNames[$collection]) as $name) {
$source_data = $this
->getSourceStorage($collection)
->read($name);
$target_data = $this
->getTargetStorage($collection)
->read($name);
if ($source_data !== $target_data) {
if (isset($source_data['uuid']) && $source_data['uuid'] !== $target_data['uuid']) {
// The entity has the same file as an existing entity but the UUIDs do
// not match. This means that the entity has been recreated so config
// synchronization should do the same.
$recreates[] = $name;
}
else {
$this
->addChangeList($collection, 'update', [
$name,
]);
}
}
}
if (!empty($recreates)) {
// Recreates should become deletes and creates. Deletes should be ordered
// so that dependencies are deleted first.
$this
->addChangeList($collection, 'create', $recreates, $this->sourceNames[$collection]);
$this
->addChangeList($collection, 'delete', $recreates, array_reverse($this->targetNames[$collection]));
}
}