ILIAS  release_8 Revision v8.23
ilMassMailDeliveryJob Class Reference
+ Inheritance diagram for ilMassMailDeliveryJob:
+ Collaboration diagram for ilMassMailDeliveryJob:

Public Member Functions

 __construct ()
 
 run (array $input, Observer $observer)
 
 getInputTypes ()
 
 isStateless ()
 
 getExpectedTimeOfTaskInSeconds ()
 
 getOutputType ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
array returns the input array
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 

Private Attributes

ILIAS DI Container $dic
 
ilMailValueObjectJsonService $mailJsonService
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
ILIAS BackgroundTasks Value $output
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMassMailDeliveryJob::__construct ( )

Definition at line 38 of file class.ilMassMailDeliveryJob.php.

References $DIC.

39  {
40  global $DIC;
41  $this->dic = $DIC;
42 
43  $this->mailJsonService = new ilMailValueObjectJsonService();
44  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ getExpectedTimeOfTaskInSeconds()

ilMassMailDeliveryJob::getExpectedTimeOfTaskInSeconds ( )
Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 105 of file class.ilMassMailDeliveryJob.php.

105  : int
106  {
107  return 42; // The answer to life, universe and the rest
108  }

◆ getInputTypes()

ilMassMailDeliveryJob::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 90 of file class.ilMassMailDeliveryJob.php.

90  : array
91  {
92  return [
93  new SingleType(IntegerValue::class), // User Id
94  new SingleType(StringValue::class), // JSON encoded array of ilMailValueObject
95  new SingleType(StringValue::class), // Context Id
96  new SingleType(StringValue::class), // Context Parameters
97  ];
98  }

◆ getOutputType()

ilMassMailDeliveryJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 110 of file class.ilMassMailDeliveryJob.php.

110  : Type
111  {
112  return new SingleType(BooleanValue::class);
113  }

◆ isStateless()

ilMassMailDeliveryJob::isStateless ( )
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 100 of file class.ilMassMailDeliveryJob.php.

100  : bool
101  {
102  return true;
103  }

◆ run()

ilMassMailDeliveryJob::run ( array  $input,
Observer  $observer 
)
Parameters

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 46 of file class.ilMassMailDeliveryJob.php.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output, and ILIAS\UI\Implementation\Component\Input\getValue().

46  : Value
47  {
48  $mailValueObjects = $this->mailJsonService->convertFromJson((string) $input[1]->getValue());
49 
50  foreach ($mailValueObjects as $mailValueObject) {
51  $mail = new ilMail((int) $input[0]->getValue());
52 
53  $mail->setSaveInSentbox($mailValueObject->shouldSaveInSentBox());
54  $contextId = $input[2]->getValue();
55  $mail = $mail
56  ->withContextId((string) $contextId)
57  ->withContextParameters((array) unserialize($input[3]->getValue(), ['allowed_classes' => false]));
58 
59  $recipients = $mailValueObject->getRecipients();
60  $recipientsCC = $mailValueObject->getRecipientsCC();
61  $recipientsBCC = $mailValueObject->getRecipientsBCC();
62 
63  $this->dic->logger()->mail()->info(
64  sprintf(
65  'Mail delivery to recipients: "%s" CC: "%s" BCC: "%s" From sender: "%s"',
66  $recipients,
67  $recipientsCC,
68  $recipientsBCC,
69  $mailValueObject->getFrom()
70  )
71  );
72 
73  $mail->sendMail(
74  $recipients,
75  $recipientsCC,
76  $recipientsBCC,
77  $mailValueObject->getSubject(),
78  $mailValueObject->getBody(),
79  $mailValueObject->getAttachments(),
80  $mailValueObject->isUsingPlaceholders()
81  );
82  }
83 
84  $output = new BooleanValue();
85  $output->setValue(true);
86 
87  return $output;
88  }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47
+ Here is the call graph for this function:

Field Documentation

◆ $dic

ILIAS DI Container ilMassMailDeliveryJob::$dic
private

Definition at line 35 of file class.ilMassMailDeliveryJob.php.

◆ $mailJsonService

ilMailValueObjectJsonService ilMassMailDeliveryJob::$mailJsonService
private

Definition at line 36 of file class.ilMassMailDeliveryJob.php.


The documentation for this class was generated from the following file: