You are here

public function SiteAuditCheckBestPracticesMultisite::calculateScore in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/BestPractices/Multisite.php \SiteAuditCheckBestPracticesMultisite::calculateScore()

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/BestPractices/Multisite.php, line 81
Contains \SiteAudit\Check\BestPractices\Multisite.

Class

SiteAuditCheckBestPracticesMultisite
Class SiteAuditCheckBestPracticesMultisite.

Code

public function calculateScore() {
  $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
  $handle = opendir($drupal_root . '/sites/');
  $this->registry['multisites'] = array();
  while (FALSE !== ($entry = readdir($handle))) {
    if (!in_array($entry, array(
      '.',
      '..',
      'default',
      'all',
      'example.sites.php',
      'README.txt',
      '.svn',
      '.DS_Store',
    ))) {
      if (is_dir($drupal_root . '/sites/' . $entry)) {
        $this->registry['multisites'][] = $entry;
      }
    }
  }
  closedir($handle);
  if ($this->registry['multisite_enabled']) {
    if (drush_get_option('vendor') == 'pantheon') {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
    }
    if (!empty($this->registry['multisites'])) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  elseif (!empty($this->registry['multisites'])) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}