You are here

site_audit.module in Site Audit 8.3

Contains hooks and functions for the site_audit.module.

File

site_audit.module
View source
<?php

/**
 * @file
 * Contains hooks and functions for the site_audit.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function site_audit_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the site_audit module.
    case 'help.page.site_audit':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Site Audit is a Drupal site analysis platform that generates reports with actionable best practice recommendations.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Determine if in a development environment.
 *
 * @return bool
 *   Whether the site is in a development environment.
 */
function site_audit_env_is_dev() {

  // Acquia.
  if (defined('AH_SITE_ENVIRONMENT')) {
    return !in_array(PANTHEON_ENVIRONMENT, [
      'test',
      'prod',
    ]);
  }

  // Pantheon.
  if (defined('PANTHEON_ENVIRONMENT')) {
    return !in_array(PANTHEON_ENVIRONMENT, [
      'test',
      'live',
    ]);
  }
  return FALSE;
}
if (!function_exists('human_filesize')) {

  /**
   * create the human readable file size
   * @see https://gist.github.com/liunian/9338301
   *
   * @param $size
   * @param int $precision
   * @return string
   */
  function human_filesize($size, $precision = 2) {
    static $units = array(
      'B',
      'KB',
      'MB',
      'GB',
      'TB',
      'PB',
      'EB',
      'ZB',
      'YB',
    );
    $step = 1024;
    $i = 0;
    while ($size / $step > 0.9) {
      $size = $size / $step;
      $i++;
    }
    return round($size, $precision) . ' ' . $units[$i];
  }
}

Functions

Namesort descending Description
site_audit_env_is_dev Determine if in a development environment.
site_audit_help Implements hook_help().