You are here

function acquia_purge_requirements in Acquia Purge 7

Same name and namespace in other branches
  1. 6 acquia_purge.install \acquia_purge_requirements()

Implements hook_requirements().

File

./acquia_purge.install, line 52
Installation file for the Acquia Purge module.

Code

function acquia_purge_requirements($phase) {
  if ($phase == 'runtime') {
    $status_item_name = '_acquia_purge_diagnostics_status';
    $diagnostics = _acquia_purge_service()
      ->diagnostics();
    $requirements = $diagnostics
      ->get();

    // Remove noisy INFO and OK results (except for the status item).
    foreach ($requirements as $name => $result) {
      if ($name === $status_item_name) {
        continue;
      }
      if ($result['severity'] === ACQUIA_PURGE_SEVLEVEL_INFO) {
        unset($requirements[$name]);
      }
      if ($result['severity'] === ACQUIA_PURGE_SEVLEVEL_OK) {
        unset($requirements[$name]);
      }
    }

    // Hide the status item when ERROR-level problems exist.
    if ($diagnostics
      ->isSystemBlocked()) {
      unset($requirements[$status_item_name]);
    }
    return $requirements;
  }
  return array();
}