CategoryAddonValueStorage
extends AbstractAddonValueStorage
in package
Class CategoryAddonValueStorage
This class extends AbstractAddonValueStorage and handles the association of key-value pairs inside the CategoryAddonValueStorage to the columns and tables inside the database. All addon values except these you have registered in the Method '_getExternalFieldsArray' will be stored in the 'addon_values_storage' table associated with the AddonValueContainerId (category ID).
Tags
Table of Contents
- $db : CI_DB_query_builder
- $externalFields : array<string|int, mixed>
- __construct() : mixed
- AbstractAddonValueStorage Constructor
- deleteValuesByContainerId() : AbstractAddonValueStorage
- Remove addon values by the given source id.
- getValuesByContainerId() : KeyValueCollection
- Get the addon values by the given container ID.
- setValues() : AbstractAddonValueStorage
- Sets addon values to the database.
- _getContainerType() : string
- Get the container class type.
- _getExternalFieldsArray() : array<string|int, mixed>
- This method is for registering the addon values which are not stored inside the 'addon_values_storage' table.
- _getExternalValuesByContainerId() : array<string|int, mixed>
- Selects the fields specified in the external fields array $this->externalFields by the given container ID and returns the associative array which will be merged with the associative array with values from the addon_values_storage table.
- _setExternalValues() : mixed
- Updates the fields specified in the external fields array $this->externalFields with the corresponding values from the provided KeyValueCollection and removes the elements from the collection before the called method writes into the addon_values_storage table.
Properties
$db
protected
CI_DB_query_builder
$db
$externalFields
protected
array<string|int, mixed>
$externalFields
= []
Methods
__construct()
AbstractAddonValueStorage Constructor
public
__construct(CI_DB_query_builder $db) : mixed
Parameters
- $db : CI_DB_query_builder
Return values
mixed —deleteValuesByContainerId()
Remove addon values by the given source id.
public
deleteValuesByContainerId(IdType $containerId) : AbstractAddonValueStorage
Parameters
- $containerId : IdType
-
Id of expected source.
Return values
AbstractAddonValueStorage —Returns the class instance.
getValuesByContainerId()
Get the addon values by the given container ID.
public
getValuesByContainerId(IdType $containerId) : KeyValueCollection
Parameters
- $containerId : IdType
-
Container database ID.
Return values
KeyValueCollection —setValues()
Sets addon values to the database.
public
setValues(IdType $containerId, KeyValueCollection $values) : AbstractAddonValueStorage
Parameters
- $containerId : IdType
-
Container database ID.
- $values : KeyValueCollection
-
KeyValueCollection which should set.
Return values
AbstractAddonValueStorage —Returns the class instance.
_getContainerType()
Get the container class type.
protected
_getContainerType() : string
Return values
string —_getExternalFieldsArray()
This method is for registering the addon values which are not stored inside the 'addon_values_storage' table.
protected
_getExternalFieldsArray() : array<string|int, mixed>
The returning array must be multidimensional and contains a set of database tables with corresponding primary keys and the fields which are not stored in the addon_values_storage table.
Example: $externalFields = array();
// Icon height and width. $externalFields['categories']['primary_key'] = 'categories_id'; $externalFields['categories']['fields'] = array( 'categories_icon_w' => 'iconWidth', 'categories_icon_h' => 'iconHeight' );
// Other categories related data $externalFields['table_name']['primary_key'] = 'categories_id'; $externalFields['table_name']['fields'] = array( 'column_name1' => 'addonValueKey1', 'column_name2' => 'addonValueKey2', );
return $externalFields;
Return values
array<string|int, mixed> —_getExternalValuesByContainerId()
Selects the fields specified in the external fields array $this->externalFields by the given container ID and returns the associative array which will be merged with the associative array with values from the addon_values_storage table.
protected
_getExternalValuesByContainerId(IdType $containerId) : array<string|int, mixed>
Parameters
- $containerId : IdType
Return values
array<string|int, mixed> —Associative array of
_setExternalValues()
Updates the fields specified in the external fields array $this->externalFields with the corresponding values from the provided KeyValueCollection and removes the elements from the collection before the called method writes into the addon_values_storage table.
protected
_setExternalValues(IdType $containerId, KeyValueCollection $values) : mixed
Parameters
- $containerId : IdType
- $values : KeyValueCollection