ILIAS  release_8 Revision v8.24
ilMailValueObjectJsonService Class Reference
+ Collaboration diagram for ilMailValueObjectJsonService:

Public Member Functions

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

Detailed Description

Member Function Documentation

◆ convertFromJson()

ilMailValueObjectJsonService::convertFromJson ( string  $json)
Returns
ilMailValueObject[]

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

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

References ilStr\strLen().

+ Here is the call graph for this function:

◆ convertToJson()

ilMailValueObjectJsonService::convertToJson ( array  $mailValueObjects)
Parameters
ilMailValueObject[]$mailValueObjects

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

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

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