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.
arrayEncoded EmailAttachment object.
encodeCollection(\EmailCollectionInterface $collection) : array
arrayReturns 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.
arrayEncoded 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.
arrayReturns the equivalent array.
parseAttachment(array $encodedAttachment) : \EmailAttachment
Attachment name is not a mandatory field so it might be empty as well.
arrayContains the "path" and "name" keys.
\EmailAttachmentReturns 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.
arrayJSON formatted email collection.
\EmailCollectionInterfaceReturns the parsed email collection object.
parseContact(array $encodedContact) : \EmailContact
Contact name is not a mandatory field so it might be empty as well.
arrayContains the "email_address", "contact_type" and "contact_name" keys.
\EmailContactReturns the parsed object.
parseEmail(array $encodedEmail) : \EmailInterface
arrayContains the email information.
\EmailInterfaceReturns the equivalent email object.
emailService : \EmailServiceInterface