You are here

public function SiteAuditCheckContentFieldCount::calculateScore in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Content/FieldCount.php \SiteAuditCheckContentFieldCount::calculateScore()

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

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Content/FieldCount.php, line 98
Contains \SiteAudit\Check\Content\FieldCount.

Class

SiteAuditCheckContentFieldCount
Class SiteAuditCheckContentFieldCount.

Code

public function calculateScore() {
  $map = \Drupal::entityManager()
    ->getFieldMap();
  $this->registry['fields'] = array();
  $this->registry['default_fields'] = array(
    'body',
    'comment_body',
  );
  foreach ($map as $entity => $fields) {
    foreach ($fields as $field => $description) {
      if (preg_match('/^field\\_/', $field) || in_array($field, $this->registry['default_fields'])) {
        $this->registry['fields'][$field] = $description['type'];
      }
    }
  }
  if (count($this->registry['fields']) == 0) {
    $this->abort;
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
  }
  elseif (count($this->registry['fields']) > 75) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}