Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SystemConfigSubscriber.php

function SystemConfigSubscriber::onConfigImporterValidateNotEmpty

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 58

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();
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal