protected static function IgnoreKernelTest::modifyStorage in Config Ignore 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/IgnoreKernelTest.php \Drupal\Tests\config_ignore\Kernel\IgnoreKernelTest::modifyStorage()
Helper method to modify a config storage.
Parameters
\Drupal\Core\Config\StorageInterface $storage: The storage to modify.
array $modifications: The modifications keyed by language.
1 call to IgnoreKernelTest::modifyStorage()
- IgnoreKernelTest::setUpStorages in tests/
src/ Kernel/ IgnoreKernelTest.php - Set up the active, sync and expected storages.
File
- tests/
src/ Kernel/ IgnoreKernelTest.php, line 306
Class
- IgnoreKernelTest
- Test the transformations.
Namespace
Drupal\Tests\config_ignore\KernelCode
protected static function modifyStorage(StorageInterface $storage, array $modifications) {
foreach ($modifications as $lang => $configs) {
$lang = $lang === '' ? StorageInterface::DEFAULT_COLLECTION : 'language.' . $lang;
$storage = $storage
->createCollection($lang);
if ($configs === NULL) {
// If it is set to null explicitly remove everything.
$storage
->deleteAll();
return;
}
foreach ($configs as $name => $data) {
if ($data !== FALSE) {
if (is_array($storage
->read($name))) {
// Merge nested arrays if the storage already has data.
$data = NestedArray::mergeDeep($storage
->read($name), $data);
}
$storage
->write($name, $data);
}
else {
// A config name set to false means deleting it.
$storage
->delete($name);
}
}
}
}