phpDocumentor

CustomerReader extends AbstractDataPaginator
in package
implements CustomerReaderInterface

Class CustomerReader

This class is used for reading customer data from the database

Tags
category

System

implements

CustomerReaderInterface

Interfaces, Classes and Traits

CustomerReaderInterface
Interface CustomerReaderInterface

Table of Contents

$customerAddressRepository  : CustomerAddressRepositoryInterface
Customer address repository.
$customerFactory  : AbstractCustomerFactory
Customer factory.
$db  : mixed
$isGuest  : bool
Is customer a guest?
$stringHelper  : StringHelperInterface
String helper.
__construct()  : mixed
Constructor of the class CustomerReader.
_translateOrderByStringIntoArrayOfSorter()  : array<string|int, mixed>
Translate an order by sql instruction into a array of Sorter
filterCustomers()  : array<string|int, mixed>
Filters customer records and returns an array with results.
findById()  : Customer|null
Finds a customer by the given ID.
findGuestByEmail()  : Customer|null
Finds a guest by email address.
findRegistreeByEmail()  : Customer|null
Finds a registree by email address.
getFilterCustomersCount()  : int
Filters customer records and returns the total count.
searchCustomers()  : array<string|int, mixed>
Filters customer records by a given CustomerSearchCondition object and returns an array with results.
_applyDefaultSorting()  : mixed
Applies the class default sorting
_applyPagination()  : $this|ProductListProvider
Applies a pagination (Limit and Offset) clause to the currently building query.
_applySorting()  : $this|ProductListProvider
Applies a sorting based on sorter param (if sorting is supplied) or apply default sorting.
_createCustomerByArray()  : Customer
Creates a customer based on the provided data.
_findByFilter()  : Customer|null
Helper method which searches for user data based on an applied filter.
_getFieldMap()  : mixed
return the child class Field Map array.
_parseOrderByString()  : array<string|int, mixed>
Parse an order by sql query into a array with fieldname and direction.
_translateToDatabaseField()  : mixed
Return the related database field of a given object(Entity) field.
_translateToJsonFieldName()  : string|false
Parse an order by sql query into a array with fieldname and direction.

Properties

Methods

__construct()

Constructor of the class CustomerReader.

public __construct(AbstractCustomerFactory $customerFactory, CustomerAddressRepositoryInterface $customerAddressRepository, CI_DB_query_builder $dbQueryBuilder) : mixed

CrossCuttingLoader dependencies:

  • StringHelper
Parameters
$customerFactory : AbstractCustomerFactory

Customer factory.

$customerAddressRepository : CustomerAddressRepositoryInterface

Customer address repository.

$dbQueryBuilder : CI_DB_query_builder

Query builder.

Return values
mixed

_translateOrderByStringIntoArrayOfSorter()

Translate an order by sql instruction into a array of Sorter

public _translateOrderByStringIntoArrayOfSorter([StringType|null $orderBy = null ]) : array<string|int, mixed>
Parameters
$orderBy : StringType|null = null

SQL instruction with fields to sort.

Return values
array<string|int, mixed>

of Sorter objects.

filterCustomers()

Filters customer records and returns an array with results.

public filterCustomers([array<string|int, mixed> $conditions = [] ][, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : array<string|int, mixed>

Example: $repository->filterCustomers('customers_id' => 1);

Parameters
$conditions : array<string|int, mixed> = []

Associative array containing the desired field and value.

$pager : Pager|null = null

(Optional) Pager object with pagination information

$sorters : array<string|int, mixed> = []

(Optional) array of Sorter objects with data sorting information

Return values
array<string|int, mixed>

Returns an array that contains customer objects.

getFilterCustomersCount()

Filters customer records and returns the total count.

public getFilterCustomersCount([array<string|int, mixed> $conditions = [] ]) : int

Example: $reader->filterCustomers( array('customers_id' => 1) );

Parameters
$conditions : array<string|int, mixed> = []

Associative array containing the desired field and value.

Return values
int

Returns the total customers count.

searchCustomers()

Filters customer records by a given CustomerSearchCondition object and returns an array with results.

public searchCustomers(CustomerSearchCondition $condition[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : array<string|int, mixed>
Parameters
$condition : CustomerSearchCondition

Conditions object for search.

$pager : Pager|null = null

(Optional) Pager object with pagination information

$sorters : array<string|int, mixed> = []

(Optional) array of Sorter objects with data sorting information

Return values
array<string|int, mixed>

Returns an array that contains customer objects.

_applyDefaultSorting()

Applies the class default sorting

protected _applyDefaultSorting() : mixed
Return values
mixed

_applyPagination()

Applies a pagination (Limit and Offset) clause to the currently building query.

protected _applyPagination([Pager|null $pager = null ]) : $this|ProductListProvider
Parameters
$pager : Pager|null = null

(Optional) Pager object with pagination information

Return values
$this|ProductListProvider

Same instance for chained method calls.

_applySorting()

Applies a sorting based on sorter param (if sorting is supplied) or apply default sorting.

protected _applySorting([array<string|int, mixed> $sorters = [] ]) : $this|ProductListProvider
Parameters
$sorters : array<string|int, mixed> = []

Array of Sorter objects.

Tags
throws
InvalidArgumentException

if some element of the $sorters array is not a instance of Sorter object

Return values
$this|ProductListProvider

Same instance for chained method calls.

_createCustomerByArray()

Creates a customer based on the provided data.

protected _createCustomerByArray(array<string|int, mixed> $customerDataArray) : Customer
Parameters
$customerDataArray : array<string|int, mixed>

Customer data.

Tags
todo

If date of birth is null in the database then: $customerDataArray['customers_dob'] = '0000-00-00 00:00:00' and then the getDateOfBirth() will return wrong results ($customer->getDateOfBirth() >> -0001-11-30 00:00:00).

Return values
Customer

$customer Created customer.

_findByFilter()

Helper method which searches for user data based on an applied filter.

protected _findByFilter(array<string|int, mixed> $filterArray) : Customer|null
Parameters
$filterArray : array<string|int, mixed>

Filters.

Return values
Customer|null

Customer or null if not found.

_getFieldMap()

return the child class Field Map array.

protected _getFieldMap() : mixed
Return values
mixed

_parseOrderByString()

Parse an order by sql query into a array with fieldname and direction.

protected _parseOrderByString([StringType|null $orderBy = null ]) : array<string|int, mixed>
Parameters
$orderBy : StringType|null = null

SQL order by String

Return values
array<string|int, mixed>

with sort information structured as ['field'=>'', 'direction'=>''].

_translateToDatabaseField()

Return the related database field of a given object(Entity) field.

protected _translateToDatabaseField(string $fieldName) : mixed
Parameters
$fieldName : string

Object Field name.

Tags
throws
InvalidArgumentException

if the provided field name is not a valid mapped field

Return values
mixed

_translateToJsonFieldName()

Parse an order by sql query into a array with fieldname and direction.

protected _translateToJsonFieldName(StringType $databaseFieldName) : string|false
Parameters
$databaseFieldName : StringType

the database field name. It can be supplied as table.fieldName or fieldName.

Return values
string|false

will return the field name or FALSE if the field doesn't exist.

Search results