CustomerAddressReader
extends AbstractDataPaginator
in package
implements
CustomerAddressReaderInterface
Class CustomerAddressReader
This class is used for reading customer address data from the database
Tags
Interfaces, Classes and Traits
- CustomerAddressReaderInterface
- Interface CustomerAddressReaderInterface
Table of Contents
- $countryService : CountryServiceInterface
- $customerFactory : AbstractCustomerFactory
- $db : mixed
- $stringHelper : StringHelperInterface
- __construct() : mixed
- Constructor for the class CustomerAddressReader
- _translateOrderByStringIntoArrayOfSorter() : array<string|int, mixed>
- Translate an order by sql instruction into a array of Sorter
- filterAddresses() : array<string|int, mixed>
- Filter existing addresses by keyword.
- findAddressesByCustomer() : array<string|int, mixed>
- This method will return an array of all customer's addresses
- findById() : CustomerAddress
- Method to find a customer address with a given ID if it exits else it will return null
- getAllAddresses() : array<string|int, mixed>
- Get all system addresses.
- getById() : CustomerAddress
- _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.
- _createCustomerAddressByArray() : CustomerAddress
- _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
$countryService
protected
CountryServiceInterface
$countryService
$customerFactory
protected
AbstractCustomerFactory
$customerFactory
$db
protected
mixed
$db
$stringHelper
protected
StringHelperInterface
$stringHelper
Methods
__construct()
Constructor for the class CustomerAddressReader
public
__construct(AbstractCustomerFactory $customerFactory, CountryServiceInterface $countryService, CI_DB_query_builder $dbQueryBuilder) : mixed
CrossCuttingLoader dependencies:
- StringHelper
Parameters
- $customerFactory : AbstractCustomerFactory
- $countryService : CountryServiceInterface
- $dbQueryBuilder : CI_DB_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.
filterAddresses()
Filter existing addresses by keyword.
public
filterAddresses(string $p_keyword[, Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : array<string|int, mixed>
This method is useful when creating a search mechanism for the registered addresses.
Parameters
- $p_keyword : string
-
The keyword to be used for filtering the records.
- $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 of CustomerAddress objects.
findAddressesByCustomer()
This method will return an array of all customer's addresses
public
findAddressesByCustomer(CustomerInterface $customer) : array<string|int, mixed>
Parameters
- $customer : CustomerInterface
Return values
array<string|int, mixed> —containing CustomerAddress objects
findById()
Method to find a customer address with a given ID if it exits else it will return null
public
findById(IdType $id) : CustomerAddress
Parameters
- $id : IdType
Return values
CustomerAddress —getAllAddresses()
Get all system addresses.
public
getAllAddresses([Pager|null $pager = null ][, array<string|int, mixed> $sorters = [] ]) : array<string|int, mixed>
Parameters
- $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> —of CustomerAddress
getById()
public
getById(IdType $id) : CustomerAddress
Parameters
- $id : IdType
Tags
Return values
CustomerAddress —_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
Return values
$this|ProductListProvider —Same instance for chained method calls.
_createCustomerAddressByArray()
protected
_createCustomerAddressByArray(array<string|int, mixed> $addressDataArray) : CustomerAddress
Parameters
- $addressDataArray : array<string|int, mixed>
Return values
CustomerAddress —_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
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.