PHP Class yii2tech\balance\ManagerActiveRecord

This manager allows usage of any storage, which have ActiveRecord interface implemented, such as relational DB, MongoDB, Redis etc. However, it may lack efficiency comparing to the dedicated managers like ManagerDb or ManagerMongoDb. Configuration example: php return [ 'components' => [ 'balanceManager' => [ 'class' => 'yii2tech\balance\ManagerActiveRecord', 'accountClass' => 'app\models\BalanceAccount', 'transactionClass' => 'app\models\BalanceTransaction', 'accountBalanceAttribute' => 'balance', 'extraAccountLinkAttribute' => 'extraAccountId', 'dataAttribute' => 'data', ], ], ... ];
See also: Manager
Since: 1.0
Author: Paul Klimov ([email protected])
Inheritance: extends ManagerDbTransaction, use trait ManagerDataSerializeTrait
Mostrar archivo Open project: yii2tech/balance

Public Properties

Property Type Description
$accountClass name of the ActiveRecord class, which should store account records.
$transactionClass name of the ActiveRecord class, which should store transaction records.

Public Methods

Method Description
calculateBalance ( $account )

Protected Methods

Method Description
createAccount ( $attributes )
createDbTransaction ( )
createTransaction ( $attributes )
findAccountId ( $attributes )
findTransaction ( $id )
incrementAccountBalance ( $accountId, $amount )

Method Details

calculateBalance() public method

public calculateBalance ( $account )

createAccount() protected method

protected createAccount ( $attributes )

createDbTransaction() protected method

protected createDbTransaction ( )

createTransaction() protected method

protected createTransaction ( $attributes )

findAccountId() protected method

protected findAccountId ( $attributes )

findTransaction() protected method

protected findTransaction ( $id )

incrementAccountBalance() protected method

protected incrementAccountBalance ( $accountId, $amount )

Property Details

$accountClass public_oe property

name of the ActiveRecord class, which should store account records.
public $accountClass

$transactionClass public_oe property

name of the ActiveRecord class, which should store transaction records.
public $transactionClass