prometheusio_exporter-8.x-1.x-dev/prometheusio_exporter.module

prometheusio_exporter.module
<?php

/**
 * @file
 * This is the Prometheus Exporter module for exporting metrics.
 */

use Drupal\prometheusio_exporter_cache\Cache\CacheMetricsCacheTagsInvalidator;

/**
 * Implements hook_modules_uninstalled().
 *
 * Removes config for any sub-modules that provide plugins.
 *
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
function prometheusio_exporter_modules_uninstalled($modules, $is_syncing) {
  // Here we do some additional cleanup for tag metrics since it has some race
  // conditions with core during module uninstall.
  if (in_array('prometheusio_exporter_cache', $modules)) {
    $promBridge = \Drupal::service('prometheusio_exporter.prometheus_bridge');
    $promBridge->removeMetricsOfSource(CacheMetricsCacheTagsInvalidator::class);
  }
  if (!$is_syncing) {
    /** @var \Drupal\prometheusio_exporter\MetricsCollectorManagerInterface $collector_manager */
    $collector_manager = \Drupal::service('prometheusio_exporter.metrics_collector_manager');
    $collector_manager->syncPluginConfig();
  }
}

/**
 * Implements hook_modules_installed().
 *
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
function prometheusio_exporter_modules_installed($modules, $is_syncing) {
  if (!$is_syncing) {
    /** @var \Drupal\prometheusio_exporter\MetricsCollectorManagerInterface $collector_manager */
    $collector_manager = \Drupal::service('prometheusio_exporter.metrics_collector_manager');
    $collector_manager->syncPluginConfig();
  }
}

/**
 * Implements hook_module_preinstall().
 *
 * Launch an exception if webprofiler is present.
 * The hook_requirements in .install is enough for web based module
 * installation but not enough for (all versions of) drush.
 * See https://github.com/drush-ops/drush/pull/4337 .
 */
function prometheusio_exporter_module_preinstall() {
  if (\Drupal::service('module_handler')->moduleExists('webprofiler')) {
    $extension_config = \Drupal::configFactory()->getEditable('core.extension');
    $modules = $extension_config->get('module');
    unset($modules['prometheusio_exporter']);
    $extension_config->set('module', $modules)->save(TRUE);
    drupal_flush_all_caches();
    throw new \Exception('Prometheus.io Exporter is incompatible with webprofiler, please uninstall webprofiler first.');
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc