Commit c564f491 authored by tlyngej's avatar tlyngej Committed by bircher

Replace hardcoded suffix (*) used as joker char, and instead use a constant

parent 33a51373
......@@ -19,8 +19,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* )
*/
class IgnoreFilter extends ConfigFilterBase implements ContainerFactoryPluginInterface {
const FORCE_EXCLUSION_PREFIX = '~';
const INCLUDE_SUFFIX = '*';
/**
* The active configuration storage.
......@@ -89,9 +90,9 @@ class IgnoreFilter extends ConfigFilterBase implements ContainerFactoryPluginInt
foreach ($this->configuration['ignored'] as $config_ignore_setting) {
// Check if the last character in the string is an asterisk.
// If so, it means that it is a wildcard.
if (Unicode::substr($config_ignore_setting, -1) == '*') {
if (Unicode::substr($config_ignore_setting, -1) == static::INCLUDE_SUFFIX) {
// Remove the asterisk character from the end of the string.
$config_ignore_setting = rtrim($config_ignore_setting, '*');
$config_ignore_setting = rtrim($config_ignore_setting, static::INCLUDE_SUFFIX);
// Test if the start of the config, we are checking, are matching
// the $config_ignore_setting string. If it is a match, mark
// that config name to be ignored.
......
......@@ -2,7 +2,7 @@
namespace Drupal\config_ignore\Tests;
use Drupal\config_ignore\ConfigImporterIgnore;
use Drupal\config_ignore\Plugin\ConfigFilter\IgnoreFilter;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Serialization\Yaml;
......@@ -25,7 +25,7 @@ class ConfigIgnoreTest extends WebTestBase {
* The profile to install as a basis for testing.
*
* We need to change it form the standard 'testing' profile as that will not
* print the title on the page, which we use for testing.
* print the title on the page, which we use for testing.'*'
*
* @var string
*/
......@@ -79,7 +79,7 @@ class ConfigIgnoreTest extends WebTestBase {
$this->config('system.site')->set('name', 'Test import')->save();
// Set the system.site:name to be ignored upon config import.
$this->config('config_ignore.settings')->set('ignored_config_entities', ['system.*'])->save();
$this->config('config_ignore.settings')->set('ignored_config_entities', ['system.' . IgnoreFilter::INCLUDE_SUFFIX])->save();
// Assemble a change that will try and override the current value.
$config = $this->config('system.site')->set('name', 'Import has changed title');
......@@ -118,7 +118,7 @@ class ConfigIgnoreTest extends WebTestBase {
$this->config('system.site')->set('name', 'Test import')->save();
// Set the system.site:name to be (force-) imported upon config import.
$settings = [ConfigImporterIgnore::FORCE_EXCLUSION_PREFIX . 'system.site'];
$settings = [IgnoreFilter::FORCE_EXCLUSION_PREFIX . 'system.site'];
$this->config('config_ignore.settings')->set('ignored_config_entities', $settings)->save();
// Assemble a change that will try and override the current value.
......@@ -162,8 +162,8 @@ class ConfigIgnoreTest extends WebTestBase {
// Set system.* configs to be ignored and system.site:name to be (force-)
// imported upon config import.
$settings = [
'system.*',
ConfigImporterIgnore::FORCE_EXCLUSION_PREFIX . 'system.site',
'system.' . IgnoreFilter::INCLUDE_SUFFIX,
IgnoreFilter::FORCE_EXCLUSION_PREFIX . 'system.site',
];
$this->config('config_ignore.settings')->set('ignored_config_entities', $settings)->save();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment