init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\MultiLocaleTranslation\Model\Queue;
|
||||
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
|
||||
class CronConsumer
|
||||
{
|
||||
private const XML_PATH_TASKS_PER_RUN = 'esun_multilocale_translation/queue/tasks_per_run';
|
||||
private const XML_PATH_TIME_LIMIT = 'esun_multilocale_translation/queue/time_limit';
|
||||
|
||||
public function __construct(
|
||||
private readonly QueueProcessor $queueProcessor,
|
||||
private readonly ScopeConfigInterface $scopeConfig
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(): void
|
||||
{
|
||||
$tasksPerRun = min(50, max(1, (int)$this->scopeConfig->getValue(self::XML_PATH_TASKS_PER_RUN)));
|
||||
$timeLimit = min(300, max(10, (int)$this->scopeConfig->getValue(self::XML_PATH_TIME_LIMIT)));
|
||||
$this->queueProcessor->process($tasksPerRun, $timeLimit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user