public function ConfigManager::diff in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::diff()
- 9 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::diff()
File
- core/lib/Drupal/Core/Config/ConfigManager.php, line 159
Class
- ConfigManager
- The ConfigManager provides helper functions for the configuration system.
Namespace
Drupal\Core\Config
Code
public function diff(StorageInterface $source_storage, StorageInterface $target_storage, $source_name, $target_name = NULL, $collection = StorageInterface::DEFAULT_COLLECTION) {
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
$source_storage = $source_storage
->createCollection($collection);
$target_storage = $target_storage
->createCollection($collection);
}
if (!isset($target_name)) {
$target_name = $source_name;
}
$source_data = explode("\n", Yaml::encode($source_storage
->read($source_name)));
$target_data = explode("\n", Yaml::encode($target_storage
->read($target_name)));
if ($source_data === [
'false',
]) {
$source_data = [
(string) $this
->t('File added'),
];
}
if ($target_data === [
'false',
]) {
$target_data = [
(string) $this
->t('File removed'),
];
}
return new Diff($source_data, $target_data);
}