PHP Trait yii2tech\balance\ManagerDataSerializeTrait

It may be useful using data storage with static data schema, like relational database. This trait supposed to be used inside descendant of Manager.
See also: Manager
See also: SerializerInterface
Since: 1.0
Author: Paul Klimov ([email protected])
Show file Open project: yii2tech/balance

Public Properties

Property Type Description
$dataAttribute name of the transaction entity attribute, which should be used to store serialized data.

Public Methods

Method Description
getSerializer ( ) : yii2tech\balance\SerializerInterface
setSerializer ( yii2tech\balance\SerializerInterface | array | string $serializer )

Protected Methods

Method Description
createSerializer ( string | array $config ) : yii2tech\balance\SerializerInterface Creates serializer from given configuration.
serializeAttributes ( array $attributes, array $allowedAttributes ) : array Processes attributes to be saved in persistent storage, serializing the ones not allowed for direct storage.
unserializeAttributes ( array $attributes ) : array Processes the raw entity attributes from the persistent storage, converting serialized data into actual attributes list.

Method Details

createSerializer() protected method

Creates serializer from given configuration.
protected createSerializer ( string | array $config ) : yii2tech\balance\SerializerInterface
$config string | array serializer configuration.
return yii2tech\balance\SerializerInterface serializer instance

getSerializer() public method

public getSerializer ( ) : yii2tech\balance\SerializerInterface
return yii2tech\balance\SerializerInterface serializer instance

serializeAttributes() protected method

Processes attributes to be saved in persistent storage, serializing the ones not allowed for direct storage.
protected serializeAttributes ( array $attributes, array $allowedAttributes ) : array
$attributes array raw attributes to be processed.
$allowedAttributes array list of attribute names, which are allowed to be saved in persistent stage.
return array actual attributes.

setSerializer() public method

public setSerializer ( yii2tech\balance\SerializerInterface | array | string $serializer )
$serializer yii2tech\balance\SerializerInterface | array | string serializer to be used

unserializeAttributes() protected method

Processes the raw entity attributes from the persistent storage, converting serialized data into actual attributes list.
protected unserializeAttributes ( array $attributes ) : array
$attributes array raw attribute values from persistent storage.
return array actual attribute values

Property Details

$dataAttribute public property

name of the transaction entity attribute, which should be used to store serialized data.
public $dataAttribute