ConfigImportSubscriber.php

Contains \Drupal\Core\EventSubscriber\ConfigImportSubscriber.

Namespace

Drupal\Core\EventSubscriber

File

drupal/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
View source
<?php

/**
 * @file
 * Contains \Drupal\Core\EventSubscriber\ConfigImportSubscriber.
 */
namespace Drupal\Core\EventSubscriber;

use Drupal\Core\Config\Config;
use Drupal\Core\Config\ConfigImporterEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Config import subscriber for config import events.
 */
class ConfigImportSubscriber implements EventSubscriberInterface {

  /**
   * Validates the configuration to be imported.
   *
   * @param \Drupal\Core\Config\ConfigImporterEvent $event
   *   The Event to process.
   *
   * @throws \Drupal\Core\Config\ConfigNameException
   */
  public function onConfigImporterValidate(ConfigImporterEvent $event) {
    foreach (array(
      'delete',
      'create',
      'update',
    ) as $op) {
      foreach ($event
        ->getConfigImporter()
        ->getUnprocessed($op) as $name) {
        Config::validateName($name);
      }
    }
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events['config.importer.validate'][] = array(
      'onConfigImporterValidate',
      40,
    );
    $events['config.installer.validate'][] = array(
      'onConfigImporterValidate',
      40,
    );
    return $events;
  }

}

Classes

Namesort descending Description
ConfigImportSubscriber Config import subscriber for config import events.