PHP 클래스 yii2tech\balance\Manager

또한 보기: ManagerInterface
부터: 1.0
저자: Paul Klimov ([email protected])
상속: extends yii\base\Component, implements yii2tech\balance\ManagerInterface
파일 보기 프로젝트 열기: yii2tech/balance 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$accountBalanceAttribute name of the account entity attribute, which should store current balance value.
$accountLinkAttribute name of the transaction entity attribute, which should be used to link transaction entity with account entity (store associated account ID).
$amountAttribute name of the transaction entity attribute, which should store amount.
$autoCreateAccount whether to automatically create requested account, if it does not yet exist.
$dateAttribute name of the transaction entity attribute, which should store date.
$dateAttributeValue value which should be used for new transaction date composition. This can be plain value, object like [[\yii\db\Expression]] or a PHP callback, which returns it. If not set PHP time() function will be used.
$extraAccountLinkAttribute name of the transaction entity attribute, which should store additional affected account ID. This attribute will be filled only at transfer() method execution and will store ID of the account transferred from or to, depending on the context. If not set, no information about the extra account context will be saved. Note: absence of this field will affect logic of some methods like Manager::revert.

공개 메소드들

메소드 설명
decrease ( $account, $amount, $data = [] )
increase ( $account, $amount, $data = [] )
revert ( $transactionId, $data = [] )
transfer ( $from, $to, $amount, $data = [] )

보호된 메소드들

메소드 설명
afterCreateTransaction ( mixed $transactionId, mixed $accountId, array $data ) : array This method is invoked after transaction has been created.
beforeCreateTransaction ( mixed $accountId, array $data ) : array This method is invoked before creating transaction.
createAccount ( array $attributes ) : mixed Creates new account with given attributes.
createTransaction ( array $attributes ) : mixed Writes transaction data into persistent storage.
fetchAccountId ( mixed $idOrFilter ) : mixed
findAccountId ( array $attributes ) : mixed | null Finds account ID matching given filter attributes.
findTransaction ( mixed $id ) : array | null Finds transaction data by ID.
getDateAttributeValue ( ) : mixed Returns actual now date value for the transaction.
incrementAccountBalance ( mixed $accountId, integer | float $amount ) Increases current account balance value.

메소드 상세

afterCreateTransaction() 보호된 메소드

This method is invoked after transaction has been created.
protected afterCreateTransaction ( mixed $transactionId, mixed $accountId, array $data ) : array
$transactionId mixed transaction ID.
$accountId mixed account ID.
$data array transaction data.
리턴 array adjusted transaction data.

beforeCreateTransaction() 보호된 메소드

This method is invoked before creating transaction.
protected beforeCreateTransaction ( mixed $accountId, array $data ) : array
$accountId mixed account ID.
$data array transaction data.
리턴 array adjusted transaction data.

createAccount() 추상적인 보호된 메소드

Creates new account with given attributes.
abstract protected createAccount ( array $attributes ) : mixed
$attributes array account attributes in format: attribute => value
리턴 mixed created account ID.

createTransaction() 추상적인 보호된 메소드

Writes transaction data into persistent storage.
abstract protected createTransaction ( array $attributes ) : mixed
$attributes array attributes associated with transaction in format: attribute => value
리턴 mixed new transaction ID.

decrease() 공개 메소드

public decrease ( $account, $amount, $data = [] )

fetchAccountId() 보호된 메소드

protected fetchAccountId ( mixed $idOrFilter ) : mixed
$idOrFilter mixed account ID or filter condition.
리턴 mixed account ID.

findAccountId() 추상적인 보호된 메소드

Finds account ID matching given filter attributes.
abstract protected findAccountId ( array $attributes ) : mixed | null
$attributes array filter attributes.
리턴 mixed | null account ID, `null` - if not found.

findTransaction() 추상적인 보호된 메소드

Finds transaction data by ID.
abstract protected findTransaction ( mixed $id ) : array | null
$id mixed transaction ID.
리턴 array | null transaction data, `null` - if not found.

getDateAttributeValue() 보호된 메소드

Returns actual now date value for the transaction.
protected getDateAttributeValue ( ) : mixed
리턴 mixed date attribute value.

increase() 공개 메소드

public increase ( $account, $amount, $data = [] )

incrementAccountBalance() 추상적인 보호된 메소드

Increases current account balance value.
abstract protected incrementAccountBalance ( mixed $accountId, integer | float $amount )
$accountId mixed account ID.
$amount integer | float amount to be added to the current balance.

revert() 공개 메소드

public revert ( $transactionId, $data = [] )

transfer() 공개 메소드

public transfer ( $from, $to, $amount, $data = [] )

프로퍼티 상세

$accountBalanceAttribute 공개적으로 프로퍼티

name of the account entity attribute, which should store current balance value.
public $accountBalanceAttribute

$accountLinkAttribute 공개적으로 프로퍼티

name of the transaction entity attribute, which should be used to link transaction entity with account entity (store associated account ID).
public $accountLinkAttribute

$amountAttribute 공개적으로 프로퍼티

name of the transaction entity attribute, which should store amount.
public $amountAttribute

$autoCreateAccount 공개적으로 프로퍼티

whether to automatically create requested account, if it does not yet exist.
public $autoCreateAccount

$dateAttribute 공개적으로 프로퍼티

name of the transaction entity attribute, which should store date.
public $dateAttribute

$dateAttributeValue 공개적으로 프로퍼티

value which should be used for new transaction date composition. This can be plain value, object like [[\yii\db\Expression]] or a PHP callback, which returns it. If not set PHP time() function will be used.
public $dateAttributeValue

$extraAccountLinkAttribute 공개적으로 프로퍼티

name of the transaction entity attribute, which should store additional affected account ID. This attribute will be filled only at transfer() method execution and will store ID of the account transferred from or to, depending on the context. If not set, no information about the extra account context will be saved. Note: absence of this field will affect logic of some methods like Manager::revert.
public $extraAccountLinkAttribute