setDefaultRunInterval example

$tasks = [new InvalidateCacheTask()new CreateAliasTask()new CleanupCartTask()];
        $parameterBag = new ParameterBag([
            'shopware.cache.invalidation.delay' => 10,
            'elasticsearch.enabled' => false,
        ]);

        $registeredTask = new ScheduledTaskEntity();

        $registeredTask->setId('1');
        $registeredTask->setName(CleanupCartTask::getTaskName());
        $registeredTask->setRunInterval(CleanupCartTask::getDefaultInterval());
        $registeredTask->setDefaultRunInterval(CleanupCartTask::getDefaultInterval());
        $registeredTask->setStatus(ScheduledTaskDefinition::STATUS_SCHEDULED);
        $registeredTask->setNextExecutionTime(new \DateTimeImmutable());
        $registeredTask->setScheduledTaskClass(CleanupCartTask::class);

        /** @var StaticEntityRepository<ScheduledTaskCollection> $staticRepository */
        $staticRepository = new StaticEntityRepository([
            new ScheduledTaskCollection([$registeredTask]),
        ]);

        (new TaskRegistry($tasks$staticRepository$parameterBag))->registerTasks();

        
Home | Imprint | This part of the site doesn't use cookies.