ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMassMailDeliveryJob Class Reference
+ Inheritance diagram for ilMassMailDeliveryJob:
+ Collaboration diagram for ilMassMailDeliveryJob:

Public Member Functions

 __construct ()
 ilMassMailDeliveryJob constructor. More...
 
 run (array $input, Observer $observer)
 
Parameters
More...
 
 getInputTypes ()
 
Returns
Type[] A list of types that are taken as input.
More...
 
 isStateless ()
 
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!
More...
 
 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
More...
 
 getOutputType ()
 
Returns
Type A single type.
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
mixed 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

 $dic
 
 $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
 $input = []
 
 $output
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMassMailDeliveryJob::__construct ( )

ilMassMailDeliveryJob constructor.

Parameters
\ILIAS\DI\Container | null$dic
ilMailValueObjectJsonService | null$mailJsonService

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

References $DIC.

32  {
33  global $DIC;
34  $this->dic = $DIC;
35 
36  $this->mailJsonService = new ilMailValueObjectJsonService();
37  }
global $DIC
Definition: goto.php:24

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 111 of file class.ilMassMailDeliveryJob.php.

112  {
113  return 42; // The answer to life, universe and the rest
114  }

◆ 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.

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 ( )

Returns
Type A single type.

Implements ILIAS\BackgroundTasks\Task.

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

120  {
121  return new SingleType(BooleanValue::class);
122  }

◆ 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 103 of file class.ilMassMailDeliveryJob.php.

104  {
105  return true;
106  }

◆ run()

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

Parameters

Exceptions

Implements ILIAS\BackgroundTasks\Task\Job.

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

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$output.

44  {
45  $mailValueObjects = $this->mailJsonService->convertFromJson((string) $input[1]->getValue());
46 
47  foreach ($mailValueObjects as $mailValueObject) {
48  $mail = new ilMail((int) $input[0]->getValue());
49 
50  $mail->setSaveInSentbox((bool) $mailValueObject->shouldSaveInSentBox());
51  $contextId = $input[2]->getValue();
52  $mail = $mail
53  ->withContextId((string) $contextId)
54  ->withContextParameters((array) unserialize($input[3]->getValue()));
55 
56  $recipients = (string) $mailValueObject->getRecipients();
57  $recipientsCC = (string) $mailValueObject->getRecipientsCC();
58  $recipientsBCC = (string) $mailValueObject->getRecipientsBCC();
59 
60  $this->dic->logger()->mail()->info(
61  sprintf(
62  'Mail delivery to recipients: "%s" CC: "%s" BCC: "%s" From sender: "%s"',
63  $recipients,
64  $recipientsCC,
65  $recipientsBCC,
66  $mailValueObject->getFrom()
67  )
68  );
69 
70  $mail->sendMail(
71  $recipients,
72  $recipientsCC,
73  $recipientsBCC,
74  (string) $mailValueObject->getSubject(),
75  (string) $mailValueObject->getBody(),
76  (array) $mailValueObject->getAttachments(),
77  (bool) $mailValueObject->isUsingPlaceholders()
78  );
79  }
80 
81  $output = new BooleanValue();
82  $output->setValue(true);
83 
84  return $output;
85  }

Field Documentation

◆ $dic

ilMassMailDeliveryJob::$dic
private

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

◆ $mailJsonService

ilMassMailDeliveryJob::$mailJsonService
private

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


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