You are here

protected function NormalizedStorageComparerTrait::createStorageComparer in Configuration Normalizer 8

Same name and namespace in other branches
  1. 2.0.x src/Config/NormalizedStorageComparerTrait.php \Drupal\config_normalizer\Config\NormalizedStorageComparerTrait::createStorageComparer()

Creates and returns a storage comparer.

Parameters

\Drupal\Core\Config\StorageInterface $source_storage: The source storage.

\Drupal\Core\Config\StorageInterface $target_storage: The target storage.

string $mode: (optional) The normalization mode.

Return value

\Drupal\Core\Config\StorageComparer; A storage comparer.

File

src/Config/NormalizedStorageComparerTrait.php, line 47

Class

NormalizedStorageComparerTrait
Using this trait will add a ::createStorageComparer() method to the class.

Namespace

Drupal\config_normalizer\Config

Code

protected function createStorageComparer(StorageInterface $source_storage, StorageInterface $target_storage, $mode = NormalizedReadOnlyStorageInterface::DEFAULT_NORMALIZATION_MODE) {
  $source_context = [
    'normalization_mode' => $mode,
    'reference_storage_service' => $target_storage,
  ];
  $target_context = [
    'normalization_mode' => $mode,
    'reference_storage_service' => $source_storage,
  ];

  // Set up a storage comparer using normalized storages.
  $storage_comparer = new StorageComparer(new NormalizedReadOnlyStorage($source_storage, $this
    ->getNormalizerManager(), $source_context), new NormalizedReadOnlyStorage($target_storage, $this
    ->getNormalizerManager(), $target_context), $this
    ->getConfigManager());
  return $storage_comparer;
}