<?php

/**
 * @file
 * Drupal APC instrumentation for Munin: installation.
 *
 * @copyright (c) 2011-2019 Ouest Systèmes Informatiques
 *
 * Licensed under the General Public License version 2 or later.
 */

/**
 * Implements hook_enable().
 */
function munin_apc_enable() {
  variable_set('menu_rebuild_needed', TRUE);
}

/**
 * Implements hook_disable().
 */
function munin_apc_disable() {
  variable_set('menu_rebuild_needed', TRUE);
}

/**
 * Implements hook_requirements().
 *
 * Since this module requires PHP >= 7.1, the only suported version of APC is
 * actually APCu.
 */
function munin_apc_requirements($phase) {
  $requirements = [];
  $t = get_t();
  if (!function_exists('apcu_sma_info') || !function_exists('apcu_cache_info')) {
    $requirements['munin_apc'] = [
      'title' => $t('APCu'),
      'description' => $t('APCu functions apc_sma_info / apcu_cache_info not found'),
      'severity' => REQUIREMENT_ERROR,
    ];
  }

  return $requirements;
}