You are here

class ConfigSubscriber in Apache Solr Multilingual 8

Hierarchy

  • class \Drupal\apachesolr_multilingual\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigSubscriber

1 string reference to 'ConfigSubscriber'
apachesolr_multilingual.services.yml in ./apachesolr_multilingual.services.yml
apachesolr_multilingual.services.yml
1 service uses ConfigSubscriber
apachesolr_multilingual.config_subscriber in ./apachesolr_multilingual.services.yml
Drupal\apachesolr_multilingual\EventSubscriber\ConfigSubscriber

File

src/EventSubscriber/ConfigSubscriber.php, line 14
Contains \Drupal\apachesolr_multilingual\EventSubscriber\ConfigSubscriber.

Namespace

Drupal\apachesolr_multilingual\EventSubscriber
View source
class ConfigSubscriber implements EventSubscriberInterface {

  /**
   * The config installer.
   */
  protected $configInstaller;

  /**
   * @param $configInstaller
   *   The Config Installer.
   */
  public function __construct(ConfigInstallerInterface $configInstaller) {
    $this->configInstaller = $configInstaller;
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[ConfigEvents::SAVE][] = array(
      'onConfigSave',
    );
    return $events;
  }
  function onConfigSave(ConfigCrudEvent $event) {
    $saved_config = $event
      ->getConfig();
    if (preg_match('@^language\\.entity\\.(.+)@', $saved_config
      ->getName(), $matches) && $matches[1] != 'und') {
      $restrict_by_dependency = [
        'module' => 'apachesolr_multilingual',
      ];

      // installOptionalConfig will not replace existing configs
      // and it contains a dependency check so we need not perform
      // any checks ourselves
      $this->configInstaller
        ->installOptionalConfig(NULL, $restrict_by_dependency);
    }

    // drupal_set_message($saved_config->getName());
    // drupal_set_message(print_r($saved_config->getRawData(), TRUE));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSubscriber::$configInstaller protected property The config installer.
ConfigSubscriber::getSubscribedEvents static function Returns an array of event names this subscriber wants to listen to.
ConfigSubscriber::onConfigSave function
ConfigSubscriber::__construct public function