You are here

PreprocessJs.php in Site Audit 8.2

Same filename and directory in other branches
  1. 7 Check/Cache/PreprocessJs.php

Contains \SiteAudit\Check\Cache\PreprocessJs.

File

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

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

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

  /**
   * Implements \SiteAudit\Check\Abstract\getLabel().
   */
  public function getLabel() {
    return dt('Aggregate JavaScript files in Drupal');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getDescription().
   */
  public function getDescription() {
    return dt('Verify that Drupal is aggregating JavaScript.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultFail().
   */
  public function getResultFail() {
    return dt('JavaScript aggregation is not enabled!');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultInfo().
   */
  public function getResultInfo() {
    return $this
      ->getResultFail();
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultPass().
   */
  public function getResultPass() {
    return dt('JavaScript aggregation is enabled.');
  }

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

  /**
   * 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 check "Aggregate JavaScript files".');
    }
  }

  /**
   * Implements \SiteAudit\Check\Abstract\calculateScore().
   */
  public function calculateScore() {
    $config = \Drupal::config('system.performance')
      ->get('js.preprocess');
    if ($config) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
    }
    if (site_audit_env_is_dev()) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
  }

}

Classes

Namesort descending Description
SiteAuditCheckCachePreprocessJs Class SiteAuditCheckCachePreprocessJs.