You are here

public static function ConfigExportIgnoreConfigSplitService::matchConfigName in Config Export Ignore 8

Match a config entity name against the list of ignored config entities.

Parameters

string $config_name: The name of the config entity to match against all ignored entities.

Return value

bool True, if the config entity is to be ignored, false otherwise.

1 call to ConfigExportIgnoreConfigSplitService::matchConfigName()
ConfigExportIgnoreConfigSplitService::export in src/ConfigExportIgnoreConfigSplitService.php
Export the configuration.

File

src/ConfigExportIgnoreConfigSplitService.php, line 94

Class

ConfigExportIgnoreConfigSplitService
Overrides exports service and removes specified configuration form export.

Namespace

Drupal\config_export_ignore

Code

public static function matchConfigName($config_name) {
  $config_ignore_settings = \Drupal::config('config_export_ignore.settings')
    ->get('configuration_names');
  if ($config_ignore_settings) {

    // If the string is an excluded config, don't ignore it.
    foreach ($config_ignore_settings as $config_ignore_setting) {
      if (substr($config_ignore_setting, 0, 1) === static::FORCE_EXCLUSION_PREFIX && fnmatch(substr($config_ignore_setting, 1), $config_name)) {
        return FALSE;
      }
    }
    foreach ($config_ignore_settings as $config_ignore_setting) {

      // Test if the config_name is in the ignore list using a shell like
      // validation function to test the config_ignore_setting pattern.
      if (fnmatch($config_ignore_setting, $config_name)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}