ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMailValueObjectJsonService Class Reference
+ Collaboration diagram for ilMailValueObjectJsonService:

Public Member Functions

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

Detailed Description

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

Member Function Documentation

◆ convertFromJson()

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

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

References ilStr\strLen().

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

◆ convertToJson()

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

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

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

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