ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilMailValueObjectJsonService Class Reference
+ Collaboration diagram for ilMailValueObjectJsonService:

Public Member Functions

 convertToJson (array $mail_value_objects)
 
 convertFromJson (string $json)
 

Private Member Functions

 attachmentsFromJson (mixed $attachments)
 

Detailed Description

Definition at line 23 of file class.ilMailValueObjectJsonService.php.

Member Function Documentation

◆ attachmentsFromJson()

ilMailValueObjectJsonService::attachmentsFromJson ( mixed  $attachments)
private

Definition at line 74 of file class.ilMailValueObjectJsonService.php.

75 {
76 if (is_string($attachments)) {
77 return MailAttachments::fromBackgroundTask($attachments);
78 }
79
80 if (is_array($attachments)) {
81 return MailAttachments::fromLegacyFilenames($attachments);
82 }
83
84 return MailAttachments::empty();
85 }

Referenced by convertFromJson().

+ Here is the caller graph for this function:

◆ convertFromJson()

ilMailValueObjectJsonService::convertFromJson ( string  $json)
Returns
list<ilMailValueObject>

Definition at line 52 of file class.ilMailValueObjectJsonService.php.

52 : array
53 {
54 $result = [];
55 $array = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
56
57 foreach ($array as $object_values) {
58 $result[] = new ilMailValueObject(
59 $object_values['from'],
60 $object_values['recipients'],
61 $object_values['recipients_cc'],
62 $object_values['recipients_bcc'],
63 ilStr::strLen($object_values['subject']) > 255 ? ilStr::substr($object_values['subject'], 0, 255) : $object_values['subject'],
64 $object_values['body'],
65 $this->attachmentsFromJson($object_values['attachments'] ?? null),
66 $object_values['is_using_placholders'],
67 $object_values['should_save_in_sent_box']
68 );
69 }
70
71 return $result;
72 }
static strLen(string $a_string)
Definition: class.ilStr.php:60

References attachmentsFromJson(), and ilStr\strLen().

+ Here is the call graph for this function:

◆ convertToJson()

ilMailValueObjectJsonService::convertToJson ( array  $mail_value_objects)
Parameters
list<ilMailValueObject>$mail_value_objects

Definition at line 28 of file class.ilMailValueObjectJsonService.php.

28 : string
29 {
30 $records = [];
31 foreach ($mail_value_objects as $mail_value_object) {
32 $mail_data = [];
33 $mail_data['from'] = $mail_value_object->getFrom();
34 $mail_data['recipients'] = $mail_value_object->getRecipients();
35 $mail_data['recipients_cc'] = $mail_value_object->getRecipientsCC();
36 $mail_data['recipients_bcc'] = $mail_value_object->getRecipientsBCC();
37 $mail_data['attachments'] = $mail_value_object->getAttachments()->toBackgroundTask();
38 $mail_data['body'] = $mail_value_object->getBody();
39 $mail_data['subject'] = $mail_value_object->getSubject();
40 $mail_data['is_using_placholders'] = $mail_value_object->isUsingPlaceholders();
41 $mail_data['should_save_in_sent_box'] = $mail_value_object->shouldSaveInSentBox();
42
43 $records[] = $mail_data;
44 }
45
46 return json_encode($records, JSON_THROW_ON_ERROR);
47 }

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