ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMailDeliveryJob.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10
16{
20 public function run(array $input, Observer $observer)
21 {
22 global $DIC;
23
24 $arguments = array_map(function ($value) {
25 return $value->getValue();
26 }, $input);
27
28 $DIC->logger()->mail()->info('Mail delivery background task executed');
29
30 $DIC->logger()->mail()->debug(sprintf(
31 'Input: %s',
32 json_encode(array_slice($arguments, 0, 5), JSON_PRETTY_PRINT)
33 ));
34
35 $mail = new ilMail((int) $input[0]->getValue());
36 $mail->setSaveInSentbox((bool) $input[8]->getValue());
37 $mail = $mail
38 ->withContextId((string) $input[9]->getValue())
39 ->withContextParameters((array) unserialize($input[10]->getValue()));
40
41 $mail->sendMail(
42 (string) $input[1]->getValue(), // To
43 (string) $input[2]->getValue(), // Cc
44 (string) $input[3]->getValue(), // Bcc
45 (string) $input[4]->getValue(), // Subject
46 (string) $input[5]->getValue(), // Message
47 (array) unserialize($input[6]->getValue()), // Attachments
48 (bool) $input[7]->getValue() // Use Placeholders
49 );
50
51 $DIC->logger()->mail()->info('Mail delivery background task finished');
52
53 $output = new BooleanValue();
54 $output->setValue(true);
55
56 return $output;
57 }
58
62 public function getInputTypes()
63 {
64 return [
65 new SingleType(IntegerValue::class), // 0. User Id
66 new SingleType(StringValue::class), // 1. To
67 new SingleType(StringValue::class), // 2. CC
68 new SingleType(StringValue::class), // 3. BCC
69 new SingleType(StringValue::class), // 4. Subject
70 new SingleType(StringValue::class), // 5. Message
71 new SingleType(StringValue::class), // 6. Attachments
72 new SingleType(BooleanValue::class), // 7. Use placeholders
73 new SingleType(BooleanValue::class), // 8. Save in sentbox
74 new SingleType(StringValue::class), // 9. Context Id
75 new SingleType(StringValue::class), // 10. Context Parameters
76 ];
77 }
78
82 public function isStateless()
83 {
84 return true;
85 }
86
91 {
92 return 30;
93 }
94
98 public function getOutputType()
99 {
100 return new SingleType(BooleanValue::class);
101 }
102}
An exception for terminatinating execution or to throw for unit testing.
Class ilMailDeliveryJob.
getOutputType()
Type A single type.
getInputTypes()
Type[] A list of types that are taken as input.
run(array $input, Observer $observer)
Value The returned Value must be of the type hinted by getOutputType.
isStateless()
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cache...
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
$DIC
Definition: xapitoken.php:46