You are here

Lifetime.php in Site Audit 7

Contains \SiteAudit\Check\Cache\Lifetime.

File

Check/Cache/Lifetime.php
View source
<?php

/**
 * @file
 * Contains \SiteAudit\Check\Cache\Lifetime.
 */

/**
 * Class SiteAuditCheckCacheLifetime.
 */
class SiteAuditCheckCacheLifetime extends SiteAuditCheckAbstract {

  /**
   * Implements \SiteAudit\Check\Abstract\getLabel().
   */
  public function getLabel() {
    return dt('Minimum cache lifetime');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getDescription().
   */
  public function getDescription() {
    return dt('Verify that Drupal\'s minimum cache lifetime is set to never expire.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultFail().
   */
  public function getResultFail() {
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultInfo().
   */
  public function getResultInfo() {
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultPass().
   */
  public function getResultPass() {
    return dt('Minimum cache lifetime is set to none.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultWarn().
   */
  public function getResultWarn() {
    global $conf;
    return dt('Minimum cache lifetime is set to @minutes min.', array(
      '@minutes' => round($conf['cache_lifetime'] / 60),
    ));
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getAction().
   */
  public function getAction() {
    if (!in_array($this->score, array(
      SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS,
    ))) {
      return dt('Go to /admin/config/development/performance and set "Minimum cache lifetime" to none.');
    }
  }

  /**
   * Implements \SiteAudit\Check\Abstract\calculateScore().
   */
  public function calculateScore() {
    global $conf;
    if (!isset($conf['cache_lifetime']) || !$conf['cache_lifetime']) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }

}

Classes

Namesort descending Description
SiteAuditCheckCacheLifetime Class SiteAuditCheckCacheLifetime.