EmailReader

Implements \EmailReaderInterface

Class EmailReader

Reads email records from the database. This class provides a customizable interface for reading operations so that it is possible to build different variations in the EmailRepository class (e.g. "getPending", "findById", "getAll").

category

System

package

Email

subpackage

Repository

Methods

Class Constructor

__construct(\CI_DB_query_builder $db, \EmailFactoryInterface $factory) 

Arguments

$db

\CI_DB_query_builder

Will be used for database operations.

$factory

\EmailFactoryInterface

Will be used for the creation of returned objects.

Creates an email object out of an array.

_createEmailByArray(array $emailDataArray) : \Email

This method expects the following values to be present in the array: 'email_id', 'subject', 'content', 'is_pending', 'contacts', 'attachments'. It uses the EmailFactory for creating email objects.

Throws
\UnexpectedValueException

If the 'creation_date' of the email is empty.

Arguments

$emailDataArray

array

Contains the database record information.

Response

\Email

Returns an object that represents the database record.

Apply filter rules to email records.

_filter(string $p_keyword) 

This method will set the SQL filters depending the provided keyword so that one can "get" the filtered records.

Throws
\InvalidArgumentException

If the $keyword argument is not a string.

Arguments

$p_keyword

string

Filtering keyword to be applied in the query.

Apply LIMIT clause to query.

_limit(array $rule) 

Example: $this->_limit( array( 'limit' => 10, 'offset' => 0 ) );

link

http://www.codeigniter.com/userguide3/database/query_builder.html#limiting-or-counting-results

Arguments

$rule

array

Must be an array that contains 'limit' and 'offset' values.

Apply ORDER BY clause to query.

_order(array $rule) 

Example: $this->_order( array( 'email_id' => 'desc' ) );

link

http://www.codeigniter.com/userguide3/database/query_builder.html#ordering-results

Arguments

$rule

array

Contains column, direction arrays for ordering results.

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.

Get email records filtered by conditions.

get(array $conditions = array(), array $limit = array(), array $order = array()) : \EmailCollection

Example: $reader->get(array('email_id' => $customerId), 10, array( array('email_id', 'asc') ));

Arguments

$conditions

array

(optional) Contains conditions with column => value pairs.

$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.

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

getRecordCount(string $p_filterKeyword = '') : integer

This method will quickly return the record count of the "emails" table. It must be used when we just need the number and not the data, because the "get" or "find" methods need more time to load and parse the records.

Throws
\InvalidArgumentException

If the provided argument is not a string.

Arguments

$p_filterKeyword

string

(optional) If provided the records will be filtered.

Response

integer

Returns the row number of the email table.

htmlentitiesWrapper

htmlentitiesWrapper( $string,  $flags = false,  $encoding = '',  $doubleEncode = true) 
inherited

Arguments

$string

$flags

$encoding

$doubleEncode

htmlEntityDecodeWrapper

htmlEntityDecodeWrapper( $string,  $flags = false,  $encoding = '') 
inherited

Arguments

$string

$flags

$encoding

Properties

Query builder.

db : \CI_DB_query_builder
var

Type(s)

\CI_DB_query_builder

E-Mail factory.

factory : \EmailFactory
var

Type(s)

\EmailFactory