WatchdogCount.php in Site Audit 8.3        
                          
                  
                        
  
  
  
  
  
File
  src/Plugin/SiteAuditCheck/WatchdogCount.php
  
    View source  
  <?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class WatchdogCount extends SiteAuditCheckBase {
  
  public function getResultFail() {
  }
  
  public function getResultInfo() {
    if (!$this->registry->count_entries) {
      return $this
        ->t('There are no dblog entries.');
    }
    return $this
      ->t('There are @count_entries log entries.', [
      '@count_entries' => number_format($this->registry->count_entries),
    ]);
  }
  
  public function getResultPass() {
  }
  
  public function getResultWarn() {
  }
  
  public function getAction() {
  }
  
  public function calculateScore() {
    if (!isset($this->registry->watchdog_enabled)) {
      $this
        ->checkInvokeCalculateScore('watchdog_enabled');
    }
    if (!$this->registry->watchdog_enabled) {
      return;
    }
    $query = \Drupal::database()
      ->select('watchdog');
    $query
      ->addExpression('COUNT(wid)', 'count');
    $this->registry->count_entries = $query
      ->execute()
      ->fetchField();
    if (!$this->registry->count_entries) {
      $this->abort = TRUE;
    }
    return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
  }
}