ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMailValueObjectJsonService Class Reference
+ Collaboration diagram for ilMailValueObjectJsonService:

Public Member Functions

 convertToJson (array $mail_value_objects)
 
 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 50 of file class.ilMailValueObjectJsonService.php.

References ilStr\strLen().

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

◆ convertToJson()

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

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

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

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