StorageComparer::addChangeList

protected StorageComparer::addChangeList($collection, $op, array $changes, array $sort_order = NULL)

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.

File

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

Class

StorageComparer
Defines a config storage comparer.

Namespace

Drupal\Core\Config

Code

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.");
    }
  }
}
doc_Drupal
2016-10-29 09:44:37
Comments
Leave a Comment

Please login to continue.