diff --git a/src/ConfigIgnoreConfig.php b/src/ConfigIgnoreConfig.php
index fc1927f..7f9ac7d 100644
--- a/src/ConfigIgnoreConfig.php
+++ b/src/ConfigIgnoreConfig.php
@@ -197,6 +197,26 @@ final class ConfigIgnoreConfig {
public function isIgnored(string $collection, string $name, string $direction, string $operation) {
$parts = [];
foreach ($this->data[$operation][$direction] as $pattern) {
+ // Get collection from the pattern.
+ $collection_pattern = '*';
+ if (strpos($pattern, '|') !== FALSE) {
+ // Divide the pattern into collection and pattern.
+ [$collection_pattern, $pattern] = explode('|', $pattern, 2);
+ $pattern = trim($pattern);
+
+ // If collection pattern includes a wildcard then move it to the
+ // config name pattern.
+ if ($collection_pattern[0] === '~') {
+ $collection_pattern = ltrim($collection_pattern, '~');
+ $pattern = '~' . ltrim($pattern, '~');
+ }
+ }
+
+ // Skip if the collection pattern does not match.
+ if (!self::wildcardMatch($collection_pattern, $collection)) {
+ continue;
+ }
+
// Early return when the line matches.
if ($pattern === '~' . $name) {
return FALSE;
diff --git a/src/Form/IgnoreSettingsForm.php b/src/Form/IgnoreSettingsForm.php
index c050c9f..1d13362 100644
--- a/src/Form/IgnoreSettingsForm.php
+++ b/src/Form/IgnoreSettingsForm.php
@@ -48,6 +48,10 @@ Examples:
- * (will ignore everything)
- ~webform.webform.contact (will force import for this configuration, even if ignored by a wildcard)
- user.mail:register_no_approval_required.body (will ignore the body of the no approval required email setting, but will not ignore other user.mail configuration.)
+- language.*|* (will ignore all language collections)
+- language.fr|* (will ignore all fr language collection)
+- language.fr|field.field.* (will ignore all fr field translations)
+- ~language.fr|field.field.media.file.field_media_file (will force import for certain field translation)
');
$form['mode'] = [
diff --git a/tests/src/Kernel/IgnoreKernelTest.php b/tests/src/Kernel/IgnoreKernelTest.php
index 287eb93..377c83a 100644
--- a/tests/src/Kernel/IgnoreKernelTest.php
+++ b/tests/src/Kernel/IgnoreKernelTest.php
@@ -171,12 +171,29 @@ class IgnoreKernelTest extends KernelTestBase {
[],
[],
];
- yield 'do not remove translation when ignored' => [
+ yield 'do not remove config and translation when ignored' => [
'simple',
['config_test.system'],
- ['de' => ['config_test.system' => ['foo' => 'Neues Foo']]],
+ [
+ '' => ['config_test.system' => ['foo' => 'New Foo']],
+ 'de' => ['config_test.system' => ['foo' => 'Nieuw Foo']],
+ ],
[],
- ['de' => ['config_test.system' => ['foo' => 'Neues Foo']]],
+ [
+ '' => ['config_test.system' => ['foo' => 'New Foo']],
+ 'de' => ['config_test.system' => ['foo' => 'Nieuw Foo']],
+ ],
+ ];
+ yield 'do not remove only de translation when ignored' => [
+ 'simple',
+ ['language.de|config_test.system'],
+ [
+ '' => ['config_test.system' => ['foo' => 'New Foo']],
+ 'de' => ['config_test.system' => ['foo' => 'Nieuw Foo']],
+ 'fr' => ['config_test.system' => ['foo' => 'Neues Foo']],
+ ],
+ [],
+ ['de' => ['config_test.system' => ['foo' => 'Nieuw Foo']]],
];
yield 'do not remove translation when key is ignored' => [
'simple',
@@ -199,6 +216,18 @@ class IgnoreKernelTest extends KernelTestBase {
['se' => ['config_test.system' => ['foo' => 'Ny foo']]],
[],
];
+ yield 'ignore only fr lang collection' => [
+ 'simple',
+ ['language.fr|*'],
+ [],
+ [
+ '' => ['config_test.system' => ['foo' => 'FR Bar', '404' => 'herp']],
+ 'fr' => ['config_test.system' => ['foo' => 'FR Bar']],
+ ],
+ [
+ '' => ['config_test.system' => ['foo' => 'FR Bar', '404' => 'herp']],
+ ],
+ ];
yield 'new config is ignored' => [
'simple',
['config_test.*'],
@@ -220,6 +249,30 @@ class IgnoreKernelTest extends KernelTestBase {
],
],
];
+ yield 'new collection is ignored' => [
+ 'simple',
+ ['language.*|config_test.*'],
+ ['' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'E']]],
+ [
+ '' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'N']],
+ 'de' => ['config_test.dynamic.exist' => ['label' => 'DE']],
+ ],
+ ['' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'N']]],
+ ];
+ yield 'new collection is ignored except FR' => [
+ 'simple',
+ ['language.*|config_test.*', '~language.fr|config_test.*'],
+ ['' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'E']]],
+ [
+ '' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'N']],
+ 'de' => ['config_test.dynamic.exist' => ['label' => 'DE']],
+ 'fr' => ['config_test.dynamic.exist' => ['label' => 'FR']],
+ ],
+ [
+ '' => ['config_test.dynamic.exist' => ['id' => 'exist', 'label' => 'N']],
+ 'fr' => ['config_test.dynamic.exist' => ['label' => 'FR']],
+ ],
+ ];
yield 'new config is not ignored in lenient mode' => [
'lenient',
['config_test.*'],
@@ -434,7 +487,7 @@ class IgnoreKernelTest extends KernelTestBase {
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);
+ $data = NestedArray::mergeDeepArray([$storage->read($name), $data], TRUE);
}
$storage->write($name, $data);
}