abstract class ScheduledTaskHandler implements MessageSubscriberInterface
{ protected EntityRepository
$scheduledTaskRepository;
public function __construct(EntityRepository
$scheduledTaskRepository) { $this->scheduledTaskRepository =
$scheduledTaskRepository;
} public function __invoke(ScheduledTask
$task): void
{ $taskId =
$task->
getTaskId();
if ($taskId === null
) { // run task independent of the schedule
$this->
run();
return;
} /** @var ScheduledTaskEntity|null $taskEntity */
$taskEntity =
$this->scheduledTaskRepository
->
search(new Criteria([$taskId]), Context::
createDefaultContext())