function ConfigImporter::processMissingContent

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::processMissingContent()
  2. 10 core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::processMissingContent()
  3. 11.x core/lib/Drupal/Core/Config/ConfigImporter.php \Drupal\Core\Config\ConfigImporter::processMissingContent()

Handles processing of missing content.

Parameters

array|\ArrayAccess $context: Standard batch context.

File

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

Class

ConfigImporter
Defines a configuration importer.

Namespace

Drupal\Core\Config

Code

protected function processMissingContent(&$context) {
    $sandbox =& $context['sandbox']['config'];
    if (!isset($sandbox['missing_content'])) {
        $missing_content = $this->configManager
            ->findMissingContentDependencies();
        $sandbox['missing_content']['data'] = $missing_content;
        $sandbox['missing_content']['total'] = count($missing_content);
    }
    else {
        $missing_content = $sandbox['missing_content']['data'];
    }
    if (!empty($missing_content)) {
        $event = new MissingContentEvent($missing_content);
        // Fire an event to allow listeners to create the missing content.
        $this->eventDispatcher
            ->dispatch(ConfigEvents::IMPORT_MISSING_CONTENT, $event);
        $sandbox['missing_content']['data'] = $event->getMissingContent();
    }
    $current_count = count($sandbox['missing_content']['data']);
    if ($current_count) {
        $context['message'] = $this->t('Resolving missing content');
        $context['finished'] = ($sandbox['missing_content']['total'] - $current_count) / $sandbox['missing_content']['total'];
    }
    else {
        $context['finished'] = 1;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.