You are here

protected function ConfigImporter::processConfigurations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::processConfigurations()

Processes configuration as a batch operation.

Parameters

array $context.: The batch context.

File

core/lib/Drupal/Core/Config/ConfigImporter.php, line 570
Contains \Drupal\Core\Config\ConfigImporter.

Class

ConfigImporter
Defines a configuration importer.

Namespace

Drupal\Core\Config

Code

protected function processConfigurations(array &$context) {

  // The first time this is called we need to calculate the total to process.
  // This involves recalculating the changelist which will ensure that if
  // extensions have been processed any configuration affected will be taken
  // into account.
  if ($this->totalConfigurationToProcess == 0) {
    $this->storageComparer
      ->reset();
    foreach ($this->storageComparer
      ->getAllCollectionNames() as $collection) {
      foreach (array(
        'delete',
        'create',
        'rename',
        'update',
      ) as $op) {
        $this->totalConfigurationToProcess += count($this
          ->getUnprocessedConfiguration($op, $collection));
      }
    }
  }
  $operation = $this
    ->getNextConfigurationOperation();
  if (!empty($operation)) {
    if ($this
      ->checkOp($operation['collection'], $operation['op'], $operation['name'])) {
      $this
        ->processConfiguration($operation['collection'], $operation['op'], $operation['name']);
    }
    if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) {
      $context['message'] = $this
        ->t('Synchronizing configuration: @op @name.', array(
        '@op' => $operation['op'],
        '@name' => $operation['name'],
      ));
    }
    else {
      $context['message'] = $this
        ->t('Synchronizing configuration: @op @name in @collection.', array(
        '@op' => $operation['op'],
        '@name' => $operation['name'],
        '@collection' => $operation['collection'],
      ));
    }
    $processed_count = 0;
    foreach ($this->storageComparer
      ->getAllCollectionNames() as $collection) {
      foreach (array(
        'delete',
        'create',
        'rename',
        'update',
      ) as $op) {
        $processed_count += count($this->processedConfiguration[$collection][$op]);
      }
    }
    $context['finished'] = $processed_count / $this->totalConfigurationToProcess;
  }
  else {
    $context['finished'] = 1;
  }
}