You are here

protected function ConfigSplitManager::processEntitiesToChangeOnDependencyRemoval in Configuration Split 2.0.x

Process changes the config manager calculated into the storages.

Parameters

array $changes: The changes from getConfigEntitiesToChangeOnDependencyRemoval().

\Drupal\Core\Config\StorageInterface $storage: The primary config transformation storage.

\Drupal\Core\Config\StorageInterface $split: The split storage.

1 call to ConfigSplitManager::processEntitiesToChangeOnDependencyRemoval()
ConfigSplitManager::splitPreview in src/ConfigSplitManager.php
Split the config of a split to the preview storage.

File

src/ConfigSplitManager.php, line 695

Class

ConfigSplitManager
The manager to split and merge.

Namespace

Drupal\config_split

Code

protected function processEntitiesToChangeOnDependencyRemoval(array $changes, StorageInterface $storage, StorageInterface $split) {

  // Process entities that need to be updated.

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  foreach ($changes['update'] as $entity) {
    $name = $entity
      ->getConfigDependencyName();

    // We use the active store because we also load the entity from it.
    $original = $this->active
      ->read($name);
    $updated = $entity
      ->toArray();
    $diff = $this->patchMerge
      ->createPatch($original, $updated);
    if (!$diff
      ->isEmpty()) {
      $split
        ->write(self::SPLIT_PARTIAL_PREFIX . $name, $diff
        ->toArray());
      $data = $storage
        ->read($name);
      $data = $this->patchMerge
        ->mergePatch($data, $diff);
      $storage
        ->write($name, $data);
    }
  }

  // Process entities that need to be deleted.

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  foreach ($changes['delete'] as $entity) {
    $name = $entity
      ->getConfigDependencyName();
    $split
      ->write($name, $this->active
      ->read($name));
    $storage
      ->delete($name);
  }
}