protected function StorageComparer::addChangelistUpdate

protected StorageComparer::addChangelistUpdate($collection)

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.

File

core/lib/Drupal/Core/Config/StorageComparer.php, line 256

Class

StorageComparer
Defines a config storage comparer.

Namespace

Drupal\Core\Config

Code

protected function addChangelistUpdate($collection) {
  $recreates = array();
  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', array($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]));

  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!StorageComparer.php/function/StorageComparer::addChangelistUpdate/8.1.x