You are here

public function SiteAuditCheckCacheUsedBackends::calculateScore in Site Audit 8.2

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

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Cache/UsedBackends.php, line 86
Contains \SiteAudit\Check\Cache\UsedBackends.

Class

SiteAuditCheckCacheUsedBackends
Class SiteAuditCheckCacheUsedBackends.

Code

public function calculateScore() {
  $container = \Drupal::getContainer();
  foreach ($container
    ->getParameter('cache_bins') as $service => $bin) {
    $backend_class = get_class($container
      ->get($service)) . 'Factory';
    $backend = array_search($backend_class, $this->registry['all_backends']);
    $this->registry['used_backends'][$bin] = $backend;
  }
  if (count(array_unique(array_values($this->registry['used_backends']))) == 1 && array_values($this->registry['used_backends'])[0] == 'cache.backend.database') {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}