CacheBinsUsed.php in Site Audit 8.3
File
src/Plugin/SiteAuditCheck/CacheBinsUsed.php
View source
<?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class CacheBinsUsed extends SiteAuditCheckBase {
public function getResultFail() {
}
public function getResultInfo() {
$ret_val = [
'#header' => [
'Service',
'Bin',
],
'#theme' => 'table',
];
foreach ($this->registry->cache_bins_used as $bin => $class) {
$ret_val['#rows'][] = [
$bin,
$class,
];
}
return $ret_val;
}
public function getResultPass() {
}
public function getResultWarn() {
}
public function getAction() {
}
public function calculateScore() {
$container = \Drupal::getContainer();
if (empty($this->registry->cache_bins_all)) {
$container = \Drupal::getContainer();
$services = $container
->getServiceIds();
$this->registry->cache_bins_all = [];
$back_ends = preg_grep('/^cache\\.backend\\./', array_values($services));
foreach ($back_ends as $backend) {
$this->registry->cache_bins_all[$backend] = get_class($container
->get($backend));
}
}
foreach ($container
->getParameter('cache_bins') as $service => $bin) {
$backend_class = get_class($container
->get($service)) . 'Factory';
$backend = array_search($backend_class, $this->registry->cache_bins_all);
$this->registry->cache_bins_used[$bin] = $backend;
}
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
}
}