private function insertTask(ScheduledTask
$task): void
{ $validTask =
$task->
shouldRun($this->parameterBag
);
try { $this->scheduledTaskRepository->
create([ [ 'name' =>
$task->
getTaskName(),
'scheduledTaskClass' =>
$task::
class,
'runInterval' =>
$task->
getDefaultInterval(),
'defaultRunInterval' =>
$task->
getDefaultInterval(),
'status' =>
$validTask ? ScheduledTaskDefinition::STATUS_SCHEDULED : ScheduledTaskDefinition::STATUS_SKIPPED,
],
], Context::
createDefaultContext());
} catch (UniqueConstraintViolationException
) { // this can happen if the function runs multiple times simultaneously
// we just care that the task is registered afterward so we can safely ignore the error
} } /**
* @return array<string, mixed>
*/