function ConfigImportSubscriber::onConfigImporterValidate

Same name in this branch
  1. 11.x core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
Same name in other branches
  1. 9 core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
  2. 9 core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php \Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
  3. 8.9.x core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
  4. 8.9.x core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php \Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
  5. 10 core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()
  6. 10 core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php \Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate()

Validates the configuration to be imported.

Parameters

\Drupal\Core\Config\ConfigImporterEvent $event: The Event to process.

Throws

\Drupal\Core\Config\ConfigNameException

Overrides ConfigImportValidateEventSubscriberBase::onConfigImporterValidate

File

core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php, line 70

Class

ConfigImportSubscriber
Config import subscriber for config import events.

Namespace

Drupal\Core\EventSubscriber

Code

public function onConfigImporterValidate(ConfigImporterEvent $event) {
    foreach ([
        'delete',
        'create',
        'update',
    ] as $op) {
        foreach ($event->getConfigImporter()
            ->getUnprocessedConfiguration($op) as $name) {
            try {
                Config::validateName($name);
            } catch (ConfigNameException) {
                $message = $this->t('The config name @config_name is invalid.', [
                    '@config_name' => $name,
                ]);
                $event->getConfigImporter()
                    ->logError($message);
            }
        }
    }
    $config_importer = $event->getConfigImporter();
    if ($config_importer->getStorageComparer()
        ->getSourceStorage()
        ->exists('core.extension')) {
        $this->validateModules($config_importer);
        $this->validateThemes($config_importer);
        $this->validateDependencies($config_importer);
    }
    else {
        $config_importer->logError($this->t('The core.extension configuration does not exist.'));
    }
}

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