You are here

public function ConfigSubscriber::onConfigSave in Search API Multilingual Solr Search 8

Installs all available Solr Field Types for a new language.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event:

File

src/EventSubscriber/ConfigSubscriber.php, line 44

Class

ConfigSubscriber
Provides a ConfigSubscriber that adds language-specific Solr Field Types.

Namespace

Drupal\search_api_solr_multilingual\EventSubscriber

Code

public function onConfigSave(ConfigCrudEvent $event) {
  $saved_config = $event
    ->getConfig();
  if (preg_match('@^language\\.entity\\.(.+)@', $saved_config
    ->getName(), $matches) && $matches[1] != 'und') {
    $restrict_by_dependency = [
      'module' => 'search_api_solr_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);
  }

  // $this->messenger()->addStatus($saved_config->getName());
  // $this->messenger()->addStatus(print_r($saved_config->getRawData(), TRUE));.
}