You are here

public static function ConfigImporterIgnore::preImport in Config Ignore 8

Gather config that we want to keep.

Saves the values, that are to be ignored, so that we can put them back in later on.

Parameters

array $context: Context of the config import.

ConfigImporter $config_importer: Config importer object.

File

src/ConfigImporterIgnore.php, line 30

Class

ConfigImporterIgnore
Class ConfigImporterIgnore.

Namespace

Drupal\config_ignore

Code

public static function preImport(array &$context, ConfigImporter $config_importer) {
  $config_to_ignore = [];
  foreach ([
    'delete',
    'create',
    'rename',
    'update',
  ] as $op) {

    // For now, we only support updates.
    if ($op == 'update') {
      foreach ($config_importer
        ->getUnprocessedConfiguration($op) as $config) {
        if (self::matchConfigName($config)) {
          $config_to_ignore[$op][$config] = \Drupal::config($config)
            ->getRawData();
        }
      }
    }

    // We do not support core.extension.
    unset($config_to_ignore[$op]['core.extension']);
  }

  /** @var SharedTempStore $temp_store */
  $temp_store = \Drupal::service('user.shared_tempstore')
    ->get('config_ignore');
  $temp_store
    ->set('config_to_ignore', $config_to_ignore);
  $context['finished'] = 1;
}