EmailRepository

Implements \EmailRepositoryInterface

Class EmailRepository

Handles the database operations that concern the email records of the database. It provides a layer for more complicated methods that use the writer, reader and deleter.

category

System

package

Email

subpackage

Repository

Methods

Class Constructor

__construct(\EmailWriterInterface $writer, \EmailReaderInterface $reader, \EmailDeleterInterface $deleter) 

Arguments

$writer

\EmailWriterInterface

Used for database writing operations.

$reader

\EmailReaderInterface

Used for database reading operations.

$deleter

\EmailDeleterInterface

Used for database deleting operations.

Removes all information of an email record from the database.

delete(\EmailInterface $email) 

This method will remove ALL the email information, from the tables that contain information about the specified email.

Arguments

$email

\EmailInterface

Contains the email information.

Removes all emails from the data base that have the given email address as sender or recipient.

deleteEmailsByEmailAddress(\CustomerEmail $email) 

Arguments

$email

\CustomerEmail

E-Mail address.

Deletes all emails that have creation date below the give date.

deleteOldEmailsByDate(\DateTime $date) 

Arguments

$date

\DateTime

Filter email records with provided keyword string.

filter(string $p_keyword, array $limit = array(), array $order = array()) : \EmailCollection

Arguments

$p_keyword

string

String to be used for filtering the email records.

$limit

array

(optional) Array that contains LIMIT and OFFSET value e.g. array( 'limit' => 10, 'offset' => 5 )

$order

array

(optional) Contains arrays with column, direction pairs e.g. array( 'column' => 'direction' )

Response

\EmailCollection

Returns a collection containing the email records.

Find email by ID

findById(\IdType $id) : \EmailInterface|null

This method will try to find the email record that matches provided ID and will return NULL on when the record does not exist.

Arguments

$id

\IdType

Email record id to be found.

Response

\EmailInterface|null

Returns email object or null on failure.

Returns all email records from the database.

getAll() : \EmailCollection

Response

\EmailCollection

Returns all email objects.

Returns an email record by ID.

getById(\IdType $id) : \EmailInterface
Throws
\UnexpectedValueException

If record does not exist.

Arguments

$id

\IdType

Database ID of the record to be returned.

Response

\EmailInterface

Returns the email object that matches the ID.

Gets all emails from the data base that have the given email address as sender or recipient.

getEmailsByEmailAddress(\CustomerEmail $email) : \EmailCollection

Arguments

$email

\CustomerEmail

E-Mail address.

Response

\EmailCollection

Returns a collection of pending emails.

getPending() : \EmailCollection

Response

\EmailCollection

Returns the pending email objects.

Get the current count of the email records in the database.

getRecordCount(string $p_filterKeyword = '') : integer

Arguments

$p_filterKeyword

string

(optional) If provided the records will be filtered.

Response

integer

Returns the row number of the email table.

Returns a collection of sent emails.

getSent() : \EmailCollection

Response

\EmailCollection

Returns the sent email objects.

Writes an email record into the database.

write(\EmailInterface $email) 

Arguments

$email

\EmailInterface

Contains the email information.

Properties

E-Mail writer.

writer : \EmailWriterInterface
var

Type(s)

\EmailWriterInterface

E-Mail reader.

reader : \EmailReaderInterface
var

Type(s)

\EmailReaderInterface

E-Mail deleter.

deleter : \EmailDeleterInterface