public function SiteAuditCheckBlockCacheReport::calculateScore in Site Audit 7
Implements \SiteAudit\Check\Abstract\calculateScore().
Overrides SiteAuditCheckAbstract::calculateScore
File
- Check/
Block/ CacheReport.php, line 86 - Contains \SiteAudit\Check\Block\CacheReport.
Class
- SiteAuditCheckBlockCacheReport
- Class SiteAuditCheckBlockCacheReport.
Code
public function calculateScore() {
$blocks = _block_rehash($this->registry['theme_default']);
// Only check enabled blocks.
foreach ($blocks as $bid => $block) {
if ($block['region'] == -1) {
unset($blocks[$bid]);
}
}
// Make sure there are blocks to check.
if (empty($blocks)) {
$this->abort = TRUE;
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
// Human readable order.
usort($blocks, function ($a, $b) {
return strcmp($a['module'] . $a['delta'], $b['module'] . $b['delta']);
});
$this->registry['blocks'] = array();
foreach ($blocks as $block) {
$this->registry['blocks'][] = array(
'module' => $block['module'],
'info' => $block['info'],
'state' => $this
->getCacheStateLabel($block['cache']),
);
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}