ConfigSubscriber.php in Search API Multilingual Solr Search 8
File
src/EventSubscriber/ConfigSubscriber.php
View source
<?php
namespace Drupal\search_api_solr_multilingual\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\ConfigInstallerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ConfigSubscriber implements EventSubscriberInterface {
protected $configInstaller;
public function __construct(ConfigInstallerInterface $configInstaller) {
$this->configInstaller = $configInstaller;
}
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = array(
'onConfigSave',
);
return $events;
}
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',
];
$this->configInstaller
->installOptionalConfig(NULL, $restrict_by_dependency);
}
}
}
Classes
Name |
Description |
ConfigSubscriber |
Provides a ConfigSubscriber that adds language-specific Solr Field Types. |