You are here

protected function ConfigIgnoreEventSubscriber::getRules in Config Ignore 8.3

Get config ignore rules.

Return value

array A keyed array containing:

  • 0: (string[]) Array of config ignore patterns
  • 1: (string[]) Exceptions to config ignore patterns.
1 call to ConfigIgnoreEventSubscriber::getRules()
ConfigIgnoreEventSubscriber::getIgnoredConfigs in src/EventSubscriber/ConfigIgnoreEventSubscriber.php
Returns the list of all ignored configs by expanding the wildcards.

File

src/EventSubscriber/ConfigIgnoreEventSubscriber.php, line 275

Class

ConfigIgnoreEventSubscriber
Makes the import/export aware of ignored configs.

Namespace

Drupal\config_ignore\EventSubscriber

Code

protected function getRules() {
  if (isset($this->ignoredConfig)) {
    return $this->ignoredConfig;
  }
  $ignored_configs_patterns = $this->configFactory
    ->get('config_ignore.settings')
    ->get('ignored_config_entities');
  $this->moduleHandler
    ->invokeAll('config_ignore_settings_alter', [
    &$ignored_configs_patterns,
  ]);

  // Builds ignored configs exceptions and remove them from the pattern list.
  $exceptions = [];
  foreach ($ignored_configs_patterns as $delta => $ignored_config_pattern) {
    if (strpos($ignored_config_pattern, '~') === 0) {
      if (strpos($ignored_config_pattern, '*') !== FALSE) {
        throw new \LogicException("A config ignore pattern entry cannot contain both, '~' and '*'.");
      }
      $exceptions[] = substr($ignored_config_pattern, 1);
      unset($ignored_configs_patterns[$delta]);
    }
  }
  $this->ignoredConfig = [
    $ignored_configs_patterns,
    $exceptions,
  ];
  return $this->ignoredConfig;
}