CodebaseSizeAll.php in Site Audit 8.3
File
src/Plugin/SiteAuditCheck/CodebaseSizeAll.php
View source
<?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class CodebaseSizeAll extends SiteAuditCheckBase {
public function getResultFail() {
return $this
->t('Empty, or unable to determine the size due to a permission error.');
}
public function getResultInfo() {
return $this
->t('Total size: @size_all', [
'@size_all' => human_filesize($this->registry->size_all_kb * 1024),
]);
}
public function getResultPass() {
}
public function getResultWarn() {
}
public function getAction() {
}
public function calculateScore() {
try {
exec('du -s -x ' . DRUPAL_ROOT, $result);
$this->registry->size_all_kb = trim(explode("\t", $result[0])[0]);
if (!$this->registry->size_all_kb && !is_numeric($this->registry->size_all_kb)) {
$this->abort = TRUE;
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_FAIL;
}
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
} catch (Exception $e) {
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_FAIL;
}
}
}