Class EmailParser
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.
Methods summary
public
|
|
public
EmailCollectionInterface
|
#
parseCollection( array $encodedCollection )
Parse a JSON formatted email collection.
Parse a JSON formatted email collection.
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.
Parameters
- $encodedCollection
- JSON formatted email collection.
Returns
|
public
EmailInterface
|
#
parseEmail( array $encodedEmail )
Parse array that contains the email information sent by the JavaScript files.
Parse array that contains the email information sent by the JavaScript files.
Parameters
- $encodedEmail
- Contains the email information.
Returns
|
public
EmailContact
|
#
parseContact( array $encodedContact )
Parse the contact data and return an EmailContact object.
Parse the contact data and return an EmailContact object.
Contact name is not a mandatory field so it might be empty as well.
Parameters
- $encodedContact
- Contains the "email_address", "contact_type" and "contact_name" keys.
Returns
|
public
EmailAttachment
|
#
parseAttachment( array $encodedAttachment )
Parse the contact data and return an EmailAttachment object.
Parse the contact data and return an EmailAttachment object.
Attachment name is not a mandatory field so it might be empty as well.
Parameters
- $encodedAttachment
- Contains the "path" and "name" keys.
Returns
|
public
array
|
#
encodeCollection( EmailCollectionInterface $collection )
Encode EmailCollection object to an array that can be later encoded into JSON string.
Encode EmailCollection object to an array that can be later encoded into JSON string.
Parameters
- $collection
- Contains the email objects to be encoded.
Returns
array Returns an array that can be encoded to JSON and returned back to the client.
|
public
array
|
#
encodeEmail( EmailInterface $email )
Encode Email object that contains the email information to an array.
Encode Email object that contains the email information to an array.
The returned array can be then encoded into JSON and sent to the JavaScript code
in the client's browser.
Parameters
- $email
- Contains the email information.
Returns
array Returns the equivalent array.
|
public
array
|
#
encodeContact( EmailContactInterface $contact )
Convert an EmailContact object to an array.
Convert an EmailContact object to an array.
This conversions aims to help the JSON encoding of email contacts.
Parameters
- $contact
- Contains the contact information.
Returns
array Encoded EmailContact object.
|
public
array
|
#
encodeAttachment( EmailAttachmentInterface $attachment )
Convert an EmailAttachment object to an array.
Convert an EmailAttachment object to an array.
This conversions aims to help the JSON encoding of email contacts.
Parameters
- $attachment
- Contains the attachment information.
Returns
array Encoded EmailAttachment object.
|