PHP Class bedezign\yii2\audit\AuditTrailBehavior

Inheritance: extends yii\base\Behavior
Mostra file Open project: bedezign/yii2-audit Class Usage Examples

Public Properties

Property Type Description
$active boolean Is the behavior is active or not
$allowed array Array with fields to save You don't need to configure both allowed and ignored
$dateFormat string Date format to use in stamp - set to "Y-m-d H:i:s" for datetime or "U" for timestamp
$ignored array Array with fields to ignore You don't need to configure both allowed and ignored
$ignoredClasses array Array with classes to ignore
$override array Array with fields you want to override before saving the row into audit_trail table

Public Methods

Method Description
afterDelete ( )
afterFind ( )
afterInsert ( )
afterUpdate ( )
audit ( $action )
events ( )
getOldAttributes ( ) : array
setOldAttributes ( $value )

Protected Methods

Method Description
auditAttributes ( string $action )
cleanAttributes ( $attributes ) : mixed Clean attributes of fields that are not allowed or ignored.
cleanAttributesAllowed ( $attributes ) : mixed Unset attributes which are not allowed
cleanAttributesIgnored ( $attributes ) : mixed Unset attributes which are ignored
cleanAttributesOverride ( $attributes ) : mixed attributes which need to get override with a new value
getAuditEntryId ( ) : AuditEntry | null | static
getNormalizedPk ( ) : string
getUserId ( ) : integer | null | string
saveAuditTrail ( $action, $newAttributes, $oldAttributes, $entry_id, $user_id, $model, $model_id, $created ) Save the audit trails for a create or update action
saveAuditTrailDelete ( ) Save the audit trails for a delete action

Private Methods

Method Description
getNewOverrideValues ( string $searchFieldValue, string $queryParams ) : mixed

Method Details

afterDelete() public method

public afterDelete ( )

afterFind() public method

public afterFind ( )

afterInsert() public method

public afterInsert ( )

afterUpdate() public method

public afterUpdate ( )

audit() public method

public audit ( $action )
$action

auditAttributes() protected method

protected auditAttributes ( string $action )
$action string

cleanAttributes() protected method

Clean attributes of fields that are not allowed or ignored.
protected cleanAttributes ( $attributes ) : mixed
$attributes
return mixed

cleanAttributesAllowed() protected method

Unset attributes which are not allowed
protected cleanAttributesAllowed ( $attributes ) : mixed
$attributes
return mixed

cleanAttributesIgnored() protected method

Unset attributes which are ignored
protected cleanAttributesIgnored ( $attributes ) : mixed
$attributes
return mixed

cleanAttributesOverride() protected method

attributes which need to get override with a new value
protected cleanAttributesOverride ( $attributes ) : mixed
$attributes
return mixed

events() public method

public events ( )

getAuditEntryId() protected method

protected getAuditEntryId ( ) : AuditEntry | null | static
return bedezign\yii2\audit\models\AuditEntry | null | static

getNormalizedPk() protected method

protected getNormalizedPk ( ) : string
return string

getOldAttributes() public method

public getOldAttributes ( ) : array
return array

getUserId() protected method

protected getUserId ( ) : integer | null | string
return integer | null | string

saveAuditTrail() protected method

Save the audit trails for a create or update action
protected saveAuditTrail ( $action, $newAttributes, $oldAttributes, $entry_id, $user_id, $model, $model_id, $created )
$action
$newAttributes
$oldAttributes
$entry_id
$user_id
$model
$model_id
$created

saveAuditTrailDelete() protected method

Save the audit trails for a delete action
protected saveAuditTrailDelete ( )

setOldAttributes() public method

public setOldAttributes ( $value )
$value

Property Details

$active public_oe property

Is the behavior is active or not
public bool $active
return boolean

$allowed public_oe property

Array with fields to save You don't need to configure both allowed and ignored
public array $allowed
return array

$dateFormat public_oe property

Date format to use in stamp - set to "Y-m-d H:i:s" for datetime or "U" for timestamp
public string $dateFormat
return string

$ignored public_oe property

Array with fields to ignore You don't need to configure both allowed and ignored
public array $ignored
return array

$ignoredClasses public_oe property

Array with classes to ignore
public array $ignoredClasses
return array

$override public_oe property

Array with fields you want to override before saving the row into audit_trail table
public array $override
return array