19declare(strict_types=1);
67 if (
null === $logger) {
72 if (
null === $objectJsonService) {
89 array $mailValueObjects,
92 array $contextParameters,
93 int $mailsPerTask = 100
95 $objectsServiceSize = count($mailValueObjects);
97 if ($objectsServiceSize <= 0) {
98 throw new ilException(
'First parameter must contain at least 1 array element');
101 if ($mailsPerTask <= 0) {
104 'The mails per task MUST be a positive integer, "%s" given',
110 foreach ($mailValueObjects as $mailValueObject) {
112 throw new ilException(
'Array MUST contain ilMailValueObjects ONLY');
119 $remainingObjects = [];
120 foreach ($mailValueObjects as $mailValueObject) {
123 $remainingObjects[] = $mailValueObject;
124 if ($taskCounter === $mailsPerTask) {
125 $interaction = $this->
createInteraction($userId, $contextId, $contextParameters, $remainingObjects);
127 $this->
runTask($interaction, $userId);
130 $remainingObjects = [];
134 if ([] !== $remainingObjects) {
135 $interaction = $this->
createInteraction($userId, $contextId, $contextParameters, $remainingObjects);
137 $this->
runTask($interaction, $userId);
141 private function runTask(\
ILIAS\BackgroundTasks\Task $task,
int $userId): void
144 $bucket->setUserId($userId);
146 $bucket->setTask($task);
147 $bucket->setTitle($this->
language->txt(
'mail_bg_task_title'));
149 $this->
logger->info(
'Delegated delivery to background task');
150 $this->taskManager->run($bucket);
156 array $contextParameters,
158 ):
ILIAS\BackgroundTasks\Task {
159 $jsonString = $this->objectJsonService->convertToJson($remainingObjects);
161 $task = $this->taskFactory->createTask(ilMassMailDeliveryJob::class, [
165 serialize($contextParameters),
170 $parameters = [$task, $userId];
172 return $this->taskFactory->createTask(
173 ilMailDeliveryJobUserInteraction::class,
Customizing of pimple-DIC for ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
__construct(TaskManager $taskManager=null, TaskFactory $taskFactory=null, ilLanguage $language=null, ilLogger $logger=null, Container $dic=null, ilMailValueObjectJsonService $objectJsonService=null, int $anonymousUserId=ANONYMOUS_USER_ID)
createInteraction(int $userId, string $contextId, array $contextParameters, $remainingObjects)
runTask(\ILIAS\BackgroundTasks\Task $task, int $userId)
ilMailValueObjectJsonService $objectJsonService
run(array $mailValueObjects, int $userId, string $contextId, array $contextParameters, int $mailsPerTask=100)
Class ChatMainBarProvider \MainMenu\Provider.