Class EmailParser
Handles the Email entity object parsing and encoding so that PHP can pass email records to JavaScript and vice versa. What it actually does is convert an email record into an array that can be encoded into JSON and parsed from JavaScript.
category |
System |
---|---|
package |
Extensions |
subpackage |
Emails |
__construct(\EmailServiceInterface $emailService)
encodeAttachment(\EmailAttachmentInterface $attachment) : array
This conversions aims to help the JSON encoding of email contacts.
array
Encoded EmailAttachment object.
encodeCollection(\EmailCollectionInterface $collection) : array
array
Returns an array that can be encoded to JSON and returned back to the client.
encodeContact(\EmailContactInterface $contact) : array
This conversions aims to help the JSON encoding of email contacts.
array
Encoded EmailContact object.
encodeEmail(\EmailInterface $email) : array
The returned array can be then encoded into JSON and sent to the JavaScript code in the client's browser.
array
Returns the equivalent array.
parseAttachment(array $encodedAttachment) : \EmailAttachment
Attachment name is not a mandatory field so it might be empty as well.
array
Contains the "path" and "name" keys.
\EmailAttachment
Returns the parsed object.
parseCollection(array $encodedCollection) : \EmailCollectionInterface
When JavaScript makes AJAX requests to the server it will always sent a JSON formatted collection that contain email records. This collection will be parsed to an EmailCollection object in order to be used by methods inside the controller.
array
JSON formatted email collection.
\EmailCollectionInterface
Returns the parsed email collection object.
parseContact(array $encodedContact) : \EmailContact
Contact name is not a mandatory field so it might be empty as well.
array
Contains the "email_address", "contact_type" and "contact_name" keys.
\EmailContact
Returns the parsed object.
parseEmail(array $encodedEmail) : \EmailInterface
array
Contains the email information.
\EmailInterface
Returns the equivalent email object.
emailService : \EmailServiceInterface