You are here

opigno_search.install in Opigno Search 8

Same filename and directory in other branches
  1. 3.x opigno_search.install

Module install/update functionality.

File

opigno_search.install
View source
<?php

/**
 * @file
 * Module install/update functionality.
 */
use Drupal\search_api\Entity\Index;

/**
 * Implements hook_install().
 *
 * Rebuild Index search after install module.
 */
function opigno_search_install() {
  $index = Index::load('default_index');
  $index
    ->disable();
  $index
    ->save();
  $index
    ->enable();
  $index
    ->save();
}

/**
 * Implements hook_update_N().
 *
 * Uninstall core module 'Search'.
 */
function opigno_search_update_8001() {
  $moduleHandler = \Drupal::service('module_handler');
  if ($moduleHandler
    ->moduleExists('search')) {
    \Drupal::service('module_installer')
      ->uninstall([
      'search',
    ]);
  }
}

/**
 * Rebuild Index search after.
 */
function opigno_search_update_8002() {

  // Necessary since ver.2.9 to 2.11.
  $index = Index::load('default_index');
  $index
    ->disable();
  $index
    ->save();
  $index
    ->enable();
  $index
    ->rebuildTracker();
  $index
    ->reindex();
  $index
    ->save();
}

Functions

Namesort descending Description
opigno_search_install Implements hook_install().
opigno_search_update_8001 Implements hook_update_N().
opigno_search_update_8002 Rebuild Index search after.