You are here

mongodb_watchdog.install in MongoDB 8

MongoDB watchdog install file.

File

mongodb_watchdog/mongodb_watchdog.install
View source
<?php

/**
 * @file
 * MongoDB watchdog install file.
 */

/**
 * Implements hook_install().
 */
function mongodb_watchdog_install() {

  /** @var \Drupal\mongodb\Logger\Logger $logger */
  $logger = \Drupal::service('mongo.logger');
  $logger
    ->ensureIndexes();
}

/**
 * Implements hook_uninstall().
 *
 * Drop /all/ the watchdog collections.
 */
function mongodb_watchdog_uninstall() {

  /** @var \Drupal\mongodb\Logger\Logger $logger */
  $logger = \Drupal::service('mongo.logger');
  $count = $logger
    ->uninstall();
  if ($count) {
    drupal_set_message(\Drupal::translation()
      ->formatPlural($count, 'Dropped 1 watchdog collection', 'Dropped @count watchdog collections'));
  }
}

Functions