function StorageComparer::addChangeList
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Config/StorageComparer.php \Drupal\Core\Config\StorageComparer::addChangeList()
- 10 core/lib/Drupal/Core/Config/StorageComparer.php \Drupal\Core\Config\StorageComparer::addChangeList()
- 11.x core/lib/Drupal/Core/Config/StorageComparer.php \Drupal\Core\Config\StorageComparer::addChangeList()
Adds changes to the changelist.
Parameters
string $collection: The storage collection to add changes for.
string $op: The change operation performed. Either delete, create, rename, or update.
array $changes: Array of changes to add to the changelist.
array $sort_order: Array to sort that can be used to sort the changelist. This array must contain all the items that are in the change list.
5 calls to StorageComparer::addChangeList()
- StorageComparer::addChangelistCreate in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php - Creates the create changelist.
- StorageComparer::addChangelistDelete in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php - Creates the delete changelist.
- StorageComparer::addChangelistRename in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php - Creates the rename changelist.
- StorageComparer::addChangelistUpdate in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php - Creates the update changelist.
- StorageComparer::moveRenameToUpdate in core/
lib/ Drupal/ Core/ Config/ StorageComparer.php - Moves a rename operation to an update.
File
-
core/
lib/ Drupal/ Core/ Config/ StorageComparer.php, line 180
Class
- StorageComparer
- Defines a config storage comparer.
Namespace
Drupal\Core\ConfigCode
protected function addChangeList($collection, $op, array $changes, array $sort_order = NULL) {
// Only add changes that aren't already listed.
$changes = array_diff($changes, $this->changelist[$collection][$op]);
$this->changelist[$collection][$op] = array_merge($this->changelist[$collection][$op], $changes);
if (isset($sort_order)) {
$count = count($this->changelist[$collection][$op]);
// Sort the changelist in the same order as the $sort_order array and
// ensure the array is keyed from 0.
$this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op]));
if ($count != count($this->changelist[$collection][$op])) {
throw new \InvalidArgumentException("Sorting the {$op} changelist should not change its length.");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.