|
| __construct (TaskManager $taskManager=null, TaskFactory $taskFactory=null, ilLanguage $language=null, ilLogger $logger=null, Container $dic=null, ilMailValueObjectJsonService $objectJsonService=null, string $anonymousUserId=ANONYMOUS_USER_ID) |
|
| run (array $mailValueObjects, int $userId, string $contextId, array $contextParameters, int $mailsPerTask=100) |
|
◆ __construct()
◆ createInteraction()
ilMassMailTaskProcessor::createInteraction |
( |
int |
$userId, |
|
|
string |
$contextId, |
|
|
array |
$contextParameters, |
|
|
|
$remainingObjects |
|
) |
| |
|
private |
- Parameters
-
int | $userId | |
string | $contextId | |
array | $contextParameters | |
| $remainingObjects | |
- Returns
Definition at line 174 of file class.ilMassMailTaskProcessor.php.
Referenced by run().
180 $jsonString = $this->objectJsonService->convertToJson($remainingObjects);
182 $task = $this->taskFactory->createTask(\ilMassMailDeliveryJob::class, [
184 (
string) $jsonString,
186 (
string) serialize($contextParameters),
191 $parameters = [$task, (int) $userId];
193 $interaction = $this->taskFactory->createTask(
194 \ilMailDeliveryJobUserInteraction::class,
◆ run()
ilMassMailTaskProcessor::run |
( |
array |
$mailValueObjects, |
|
|
int |
$userId, |
|
|
string |
$contextId, |
|
|
array |
$contextParameters, |
|
|
int |
$mailsPerTask = 100 |
|
) |
| |
- Parameters
-
| ilMailValueObject[] | $mailValueObjects - One MailValueObject = One Task |
int | $userId | - User ID of the user who executes the background task |
string | $contextId | - context ID of the Background task |
array | $contextParameters | - context parameters for the background tasks |
int | $mailsPerTask | - Defines how many mails will be added before a background task is executed |
- Exceptions
-
Definition at line 103 of file class.ilMassMailTaskProcessor.php.
References createInteraction(), and runTask().
110 $objectsServiceSize =
sizeof($mailValueObjects);
112 if ($objectsServiceSize <= 0) {
113 throw new ilException(
'First parameter must contain at least 1 array element');
116 if ($mailsPerTask <= 0) {
117 throw new ilException(sprintf(
'The mails per task MUST be a positive integer, "%s" given', $mailsPerTask));
120 foreach ($mailValueObjects as $mailValueObject) {
122 throw new ilException(
'Array MUST contain ilMailValueObjects ONLY');
129 $remainingObjects = array();
130 foreach ($mailValueObjects as $mailValueObject) {
133 $remainingObjects[] = $mailValueObject;
134 if ($taskCounter === $mailsPerTask) {
135 $interaction = $this->
createInteraction($userId, $contextId, $contextParameters, $remainingObjects);
137 $this->
runTask($interaction, $userId);
140 $remainingObjects = array();
144 if (array() !== $remainingObjects) {
145 $interaction = $this->
createInteraction($userId, $contextId, $contextParameters, $remainingObjects);
147 $this->
runTask($interaction, $userId);
createInteraction(int $userId, string $contextId, array $contextParameters, $remainingObjects)
runTask(\ILIAS\BackgroundTasks\Task $task, int $userId)
◆ runTask()
- Parameters
-
\ILIAS\BackgroundTasks\Task | $task | |
int | $userId | |
Definition at line 155 of file class.ilMassMailTaskProcessor.php.
References language().
Referenced by run().
158 $bucket->setUserId($userId);
160 $bucket->setTask($task);
161 $bucket->setTitle($this->
language->txt(
'mail_bg_task_title'));
163 $this->logger->info(
'Delegated delivery to background task');
164 $this->taskManager->run($bucket);
◆ $anonymousUserId
ilMassMailTaskProcessor::$anonymousUserId |
|
private |
◆ $language
ilMassMailTaskProcessor::$language |
|
private |
◆ $logger
ilMassMailTaskProcessor::$logger |
|
private |
◆ $objectJsonService
ilMassMailTaskProcessor::$objectJsonService |
|
private |
◆ $taskFactory
ilMassMailTaskProcessor::$taskFactory |
|
private |
◆ $taskManager
ilMassMailTaskProcessor::$taskManager |
|
private |
The documentation for this class was generated from the following file: