SystemConfigSubscriber::onConfigImporterValidateNotEmpty

public SystemConfigSubscriber::onConfigImporterValidateNotEmpty(ConfigImporterEvent $event)

Checks that the configuration synchronization is valid.

This event listener prevents deleting all configuration. If there is nothing to import then event propagation is stopped because there is no config import to validate.

Parameters

\Drupal\Core\Config\ConfigImporterEvent $event: The config import event.

File

core/modules/system/src/SystemConfigSubscriber.php, line 57

Class

SystemConfigSubscriber
System Config subscriber.

Namespace

Drupal\system

Code

public function onConfigImporterValidateNotEmpty(ConfigImporterEvent $event) {
  $importList = $event->getConfigImporter()->getStorageComparer()->getSourceStorage()->listAll();
  if (empty($importList)) {
    $event->getConfigImporter()->logError($this->t('This import is empty and if applied would delete all of your configuration, so has been rejected.'));
    $event->stopPropagation();
  }
}
doc_Drupal
2016-10-29 09:45:41
Comments
Leave a Comment

Please login to continue.