public function SiteAuditCheckContentFieldInstances::calculateScore in Site Audit 7
Same name and namespace in other branches
- 8.2 Check/Content/FieldInstances.php \SiteAuditCheckContentFieldInstances::calculateScore()
Implements \SiteAudit\Check\Abstract\calculateScore().
Overrides SiteAuditCheckAbstract::calculateScore
File
- Check/
Content/ FieldInstances.php, line 103 - Contains \SiteAudit\Check\Content\FieldInstances.
Class
- SiteAuditCheckContentFieldInstances
- Class SiteAuditCheckContentFieldInstances.
Code
public function calculateScore() {
// Only available in Drupal 7.22 and above.
if (!function_exists('field_info_field_map')) {
$this->abort;
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}
$this->registry['field_api_map'] = field_info_field_map();
$this->registry['field_instance_counts'] = array();
foreach ($this->registry['field_api_map'] as $field_name => $field) {
foreach ($field['bundles'] as $entity_type => $bundle_names) {
foreach ($bundle_names as $bundle_name) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type)
->entityCondition('bundle', $bundle_name)
->fieldCondition($field_name)
->count();
$field_count = $query
->execute();
$this->registry['field_instance_counts'][$bundle_name][$entity_type][$field_name] = $field_count;
}
}
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}