Progress.php in Ultimate Cron 8.2
File
src/Progress/Progress.php
View source
<?php
namespace Drupal\ultimate_cron\Progress;
use Drupal\Core\KeyValueStore\KeyValueFactory;
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
class Progress implements ProgressInterface {
protected $progressUpdated = 0;
protected $interval = 1;
protected $keyValue;
public function __construct(KeyValueFactoryInterface $key_value_factory, $interval = 1) {
$this->keyValue = $key_value_factory
->get('uc-progress');
$this->interval = $interval;
}
public function getProgress($job_id) {
$value = $this->keyValue
->get($job_id);
return $value;
}
public function getProgressMultiple($job_ids) {
$values = $this->keyValue
->getMultiple($job_ids);
return $values;
}
public function setProgress($job_id, $progress) {
if (microtime(TRUE) >= $this->progressUpdated + $this->interval) {
$this->keyValue
->set($job_id, $progress);
$this->progressUpdated = microtime(TRUE);
return TRUE;
}
return FALSE;
}
}