CachePageExpire.php in Site Audit 8.3
File
src/Plugin/SiteAuditCheck/CachePageExpire.php
View source
<?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class CachePageExpire extends SiteAuditCheckBase {
public function getResultFail() {
return $this
->t('Expiration of cached pages not set!');
}
public function getResultInfo() {
return $this
->getResultFail();
}
public function getResultPass() {
return $this
->t('Expiration of cached pages is set to @minutes min.', [
'@minutes' => round(\Drupal::config('system.performance')
->get('cache.page.max_age') / 60),
]);
}
public function getResultWarn() {
return $this
->t('Expiration of cached pages only set to @minutes min.', [
'@minutes' => round(\Drupal::config('system.performance')
->get('cache.page.max_age') / 60),
]);
}
public function getAction() {
}
public function calculateScore() {
$config = \Drupal::config('system.performance')
->get('cache.page.max_age');
if ($config == 0) {
if (site_audit_env_is_dev()) {
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
}
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_FAIL;
}
elseif ($config >= 900) {
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_PASS;
}
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_WARN;
}
}