UsersCountBlocked.php in Site Audit 8.3
File
src/Plugin/SiteAuditCheck/UsersCountBlocked.php
View source
<?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class UsersCountBlocked extends SiteAuditCheckBase {
public function getResultFail() {
}
public function getResultInfo() {
switch ($this->registry->count_users_blocked) {
case 0:
return $this
->t('There are no blocked users.');
break;
default:
return $this
->formatPlural($this->registry->count_users_blocked, 'There is one blocked user.', 'There are @count blocked users.');
break;
}
}
public function getResultPass() {
}
public function getResultWarn() {
}
public function getAction() {
}
public function calculateScore() {
$query = \Drupal::database()
->select('users_field_data', 'ufd');
$query
->addExpression('COUNT(*)', 'count');
$query
->condition('status', 0);
$this->registry->count_users_blocked = $query
->execute()
->fetchField();
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
}
}