You are here

class ConfigImportEventSubscriber in ThemeKey 8

Defines a event listener implementation for config import.

Hierarchy

Expanded class hierarchy of ConfigImportEventSubscriber

1 string reference to 'ConfigImportEventSubscriber'
themekey.services.yml in ./themekey.services.yml
themekey.services.yml
1 service uses ConfigImportEventSubscriber
themekey.config_import_event_subscriber in ./themekey.services.yml
Drupal\themekey\EventSubscriber\ConfigImportEventSubscriber

File

src/EventSubscriber/ConfigImportEventSubscriber.php, line 14

Namespace

Drupal\themekey\EventSubscriber
View source
class ConfigImportEventSubscriber implements EventSubscriberInterface {
  use RuleChainManagerTrait;
  public function onConfigImporterValidate(ConfigImporterEvent $event) {

    // TODO validate chain: check if all rules exist / are already imported
  }
  public function onConfigImporterSave(ConfigCrudEvent $event) {
    $ruleChainManager = $this
      ->getRuleChainManager();
    $ruleChainManager
      ->rebuildOptimizedChain($event
      ->getConfig()
      ->get('chain'));
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[ConfigEvents::IMPORT_VALIDATE][] = array(
      'onConfigImporterValidate',
      20,
    );
    $events[ConfigEvents::SAVE][] = array(
      'onConfigImporterSave',
      20,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigImportEventSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to.
ConfigImportEventSubscriber::onConfigImporterSave public function
ConfigImportEventSubscriber::onConfigImporterValidate public function
RuleChainManagerTrait::$ruleChainManager private property @var
RuleChainManagerTrait::getRuleChainManager protected function Gets the ThemeKey Rule Chain manager. 1
RuleChainManagerTrait::setRuleChainManager public function Sets the ThemeKey Rule Chain manager to use.