You are here

public static function ConfigImporterIgnore::matchConfigName in Config 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.

3 calls to ConfigImporterIgnore::matchConfigName()
ConfigImporterIgnore::preImport in src/ConfigImporterIgnore.php
Gather config that we want to keep.
config_ignore_form_config_admin_import_form_alter in ./config_ignore.module
Implements hook_form_FORM_ID_alter().
drush_config_ignore_pre_config_import in ./config_ignore.drush.inc
Print out a message regarding what config that will be ignored.

File

src/ConfigImporterIgnore.php, line 118

Class

ConfigImporterIgnore
Class ConfigImporterIgnore.

Namespace

Drupal\config_ignore

Code

public static function matchConfigName($config_name) {
  $config_ignore_settings = \Drupal::config('config_ignore.settings')
    ->get('ignored_config_entities');
  \Drupal::moduleHandler()
    ->invokeAll('config_ignore_settings_alter', [
    &$config_ignore_settings,
  ]);

  // If the string is an excluded config, don't ignore it.
  if (in_array(static::FORCE_EXCLUSION_PREFIX . $config_name, $config_ignore_settings, TRUE)) {
    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;
}