public function DiagnosticsService::next in Purge 8.3
Override to log messages when enabled.
Overrides IteratingServiceBaseTrait::next
File
- src/
Plugin/ Purge/ DiagnosticCheck/ DiagnosticsService.php, line 243
Class
- DiagnosticsService
- Provides a service that interacts with diagnostic checks.
Namespace
Drupal\purge\Plugin\Purge\DiagnosticCheckCode
public function next() {
// The following two lines are copied from parent::next(), since we cannot
// call protected IteratingServiceBaseTrait::initializePluginInstances().
$this
->initializePluginInstances();
++$this->position;
// When the diagnostics logger has been granted a single or more grants,
// prerun the tests (results are cached) and log at permitted levels. No
// worries, the tests don't run when logging is disabled (default).
if ($this
->valid() && $this
->getLogger()
->getGrants()) {
$sevmethods = [
DiagnosticCheckInterface::SEVERITY_WARNING => 'warning',
DiagnosticCheckInterface::SEVERITY_ERROR => 'error',
DiagnosticCheckInterface::SEVERITY_INFO => 'info',
DiagnosticCheckInterface::SEVERITY_OK => 'notice',
];
$context = [
'@sev' => $this->instances[$this->position]
->getSeverityString(),
'@msg' => $this->instances[$this->position]
->getRecommendation(),
'@title' => $this->instances[$this->position]
->getTitle(),
];
$method = $sevmethods[$this->instances[$this->position]
->getSeverity()];
$this
->getLogger()
->{$method}('@sev: @title: @msg', $context);
}
}