You are here

public function SearchApiMigrateSubscriber::__construct in Multiversion 8

Constructs a new SearchApiMigrateSubscriber instance.

Parameters

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException The invalid plugin definition exception.

\Drupal\Component\Plugin\Exception\PluginNotFoundException The plugin not found exception.

File

src/EventSubscriber/SearchApiMigrateSubscriber.php, line 38

Class

SearchApiMigrateSubscriber
SearchApiMigrateSubscriber class.

Namespace

Drupal\multiversion\EventSubscriber

Code

public function __construct(ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager) {
  if ($module_handler
    ->moduleExists('search_api')) {
    $indexes = $entity_type_manager
      ->getStorage('search_api_index')
      ->loadMultiple();
    foreach ($indexes as $index_id => $index) {

      // We are interested only in enabled and writable indexes.
      if ($index
        ->status() && !$index
        ->isReadOnly()) {
        $this->indexes[$index_id] = $index;
      }
    }
  }
}