You are here

Settings.php in Site Audit 7

Same filename and directory in other branches
  1. 8.2 Check/BestPractices/Settings.php

Contains \SiteAudit\Check\BestPractices\Settings.

File

Check/BestPractices/Settings.php
View source
<?php

/**
 * @file
 * Contains \SiteAudit\Check\BestPractices\Settings.
 */

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

  /**
   * Implements \SiteAudit\Check\Abstract\getLabel().
   */
  public function getLabel() {
    return dt('sites/default/settings.php');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getDescription().
   */
  public function getDescription() {
    return dt('Check if the configuration file exists.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultFail().
   */
  public function getResultFail() {
    return dt('No settings.php found!');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultInfo().
   */
  public function getResultInfo() {
    return dt('settings.php does not exist, but this is a multi-site configuration.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultPass().
   */
  public function getResultPass() {
    return dt('settings.php exists and is not a symbolic link.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getResultWarn().
   */
  public function getResultWarn() {
    return dt('sites/default/settings.php is a symbolic link.');
  }

  /**
   * Implements \SiteAudit\Check\Abstract\getAction().
   */
  public function getAction() {
    if ($this->score == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN) {
      return dt('Don\'t rely on symbolic links for core configuration files; copy settings.php where it should be and remove the symbolic link.');
    }
    if ($this->score == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL) {
      return dt('Even if environment settings are injected, create a stub settings.php file for compatibility.');
    }
  }

  /**
   * Implements \SiteAudit\Check\Abstract\calculateScore().
   */
  public function calculateScore() {
    $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
    if (file_exists($drupal_root . '/sites/default/settings.php')) {
      if (is_link($drupal_root . '/sites/default/settings.php')) {
        return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
      }
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
    }
    if (isset($this->registry['multisites']) && !empty($this->registry['multisites'])) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
  }

}

Classes

Namesort descending Description
SiteAuditCheckBestPracticesSettings Class SiteAuditCheckBestPracticesSettings.