CapacityDiagnosticCheck.php in Purge 8.3
File
src/Plugin/Purge/DiagnosticCheck/CapacityDiagnosticCheck.php
View source
<?php
namespace Drupal\purge\Plugin\Purge\DiagnosticCheck;
use Drupal\purge\Plugin\Purge\Purger\PurgersServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CapacityDiagnosticCheck extends DiagnosticCheckBase implements DiagnosticCheckInterface {
protected $purgePurgers;
public final function __construct(array $configuration, $plugin_id, $plugin_definition, PurgersServiceInterface $purge_purgers) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->purgePurgers = $purge_purgers;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('purge.purgers'));
}
public function run() {
$tracker = $this->purgePurgers
->capacityTracker();
$this->value = $tracker
->getRemainingInvalidationsLimit();
$ideal_limit = $tracker
->getIdealConditionsLimit();
$placeholders = [
'@limit' => $this->value,
'@ideallimit' => $ideal_limit,
];
if ($this->value === 0) {
$this->recommendation = $this
->t("There is no purging capacity available.");
return self::SEVERITY_WARNING;
}
elseif ($this->value < 5) {
$this->recommendation = $this
->t("Your system invalidates just @limit items through webserver-initiated processing. If you notice that purge cannot keep up with its queue, reconsider your configuration.", $placeholders);
return self::SEVERITY_WARNING;
}
else {
$this->recommendation = $this
->t("Your system can invalidate @limit items when you're processing through webserver-initiated requests. Under ideal conditions - for example via Drush - the capacity would be @ideallimit.", $placeholders);
return self::SEVERITY_OK;
}
}
}