ConfigImporter::processConfigurations

protected ConfigImporter::processConfigurations(&$context)

Processes configuration as a batch operation.

Parameters

array|\ArrayAccess $context.: The batch context.

File

core/lib/Drupal/Core/Config/ConfigImporter.php, line 568

Class

ConfigImporter
Defines a configuration importer.

Namespace

Drupal\Core\Config

Code

protected function processConfigurations(&$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;
  }
}
doc_Drupal
2016-10-29 08:53:41
Comments
Leave a Comment

Please login to continue.