You are here

public function SiteAuditCheckExtensionsDev::calculateScore in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Extensions/Dev.php \SiteAuditCheckExtensionsDev::calculateScore()

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

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Extensions/Dev.php, line 102
Contains \SiteAudit\Check\Extensions\Dev.

Class

SiteAuditCheckExtensionsDev
Class SiteAuditCheckExtensionsDev.

Code

public function calculateScore() {
  $this->registry['extensions_dev'] = array();
  $extension_info = $this->registry['extensions'];
  uasort($extension_info, '_drush_pm_sort_extensions');
  $dev_extensions = $this
    ->getExtensions();
  foreach ($extension_info as $key => $extension) {
    $row = array();
    $status = drush_get_extension_status($extension);

    // Only enabled extensions.
    if (!in_array($status, array(
      'enabled',
    ))) {
      unset($extension_info[$key]);
      continue;
    }

    // Not in the list of known development modules.
    if (!array_key_exists($extension
      ->getName(), $dev_extensions)) {
      unset($extension_info[$key]);
      continue;
    }

    // Do not report modules that are dependencies of other modules, such
    // as field_ui in Drupal Commerce.
    if (isset($extension->required_by) && !empty($extension->required_by)) {
      unset($extension_info[$key]);
      continue;
    }

    // Name.
    $row[] = $extension->label;

    // Reason.
    $row[] = $dev_extensions[$extension
      ->getName()];
    $this->registry['extensions_dev'][$extension
      ->getName()] = $row;
  }
  if (!empty($this->registry['extensions_dev'])) {
    if (site_audit_env_is_dev()) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}