|
| __construct (private readonly int $anonymous_user_id=ANONYMOUS_USER_ID, ?TaskManager $task_manager=null, ?TaskFactory $task_factory=null, ?ilLanguage $language=null, ?ilLogger $logger=null, ?Container $dic=null, ?ilMailValueObjectJsonService $object_json_service=null) |
|
| run (array $value_objects, int $usr_id, string $context_id, array $context_parameters, int $mails_per_task=100) |
|
◆ __construct()
◆ createInteraction()
ilMassMailTaskProcessor::createInteraction |
( |
int |
$usr_id, |
|
|
string |
$context_id, |
|
|
array |
$context_parameters, |
|
|
|
$remaining_objects |
|
) |
| |
|
private |
Definition at line 126 of file class.ilMassMailTaskProcessor.php.
Referenced by run().
132 $json_string = $this->object_json_service->convertToJson($remaining_objects);
134 $task = $this->task_factory->createTask(ilMassMailDeliveryJob::class, [
138 serialize($context_parameters),
143 $parameters = [$task, $usr_id];
145 return $this->task_factory->createTask(
146 ilMailDeliveryJobUserInteraction::class,
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
◆ run()
ilMassMailTaskProcessor::run |
( |
array |
$value_objects, |
|
|
int |
$usr_id, |
|
|
string |
$context_id, |
|
|
array |
$context_parameters, |
|
|
int |
$mails_per_task = 100 |
|
) |
| |
- Parameters
-
| list<ilMailValueObject> | $value_objects - One MailValueObject = One Task |
int | $usr_id | - User ID of the user who executes the background task |
string | $context_id | - context ID of the Background task |
array | $context_parameters | - context parameters for the background tasks |
int | $mails_per_task | - Defines how many mails will be added before a background task is executed |
- Exceptions
-
Definition at line 63 of file class.ilMassMailTaskProcessor.php.
References createInteraction(), and runTask().
70 $num_value_objects = count($value_objects);
72 if ($num_value_objects <= 0) {
73 throw new ilMailException(
'First parameter must contain at least 1 array element');
76 if ($mails_per_task <= 0) {
79 'The mails per task MUST be a positive integer, "%s" given',
85 foreach ($value_objects as $value_object) {
87 throw new ilMailException(
'Array MUST contain ilMailValueObjects ONLY');
92 $remaining_objects = [];
93 foreach ($value_objects as $value_object) {
96 $remaining_objects[] = $value_object;
97 if ($task_counter === $mails_per_task) {
98 $interaction = $this->
createInteraction($usr_id, $context_id, $context_parameters, $remaining_objects);
100 $this->
runTask($interaction, $usr_id);
103 $remaining_objects = [];
107 if ([] !== $remaining_objects) {
108 $interaction = $this->
createInteraction($usr_id, $context_id, $context_parameters, $remaining_objects);
110 $this->
runTask($interaction, $usr_id);
runTask(\ILIAS\BackgroundTasks\Task $task, int $usr_id)
createInteraction(int $usr_id, string $context_id, array $context_parameters, $remaining_objects)
◆ runTask()
◆ $language
readonly ilLanguage ilMassMailTaskProcessor::$language |
|
private |
◆ $logger
readonly ilLogger ilMassMailTaskProcessor::$logger |
|
private |
◆ $object_json_service
◆ $task_factory
readonly TaskFactory ilMassMailTaskProcessor::$task_factory |
|
private |
◆ $task_manager
readonly TaskManager ilMassMailTaskProcessor::$task_manager |
|
private |
The documentation for this class was generated from the following file: