PHP 클래스 AuditableBehavior

Store info about user which created entry, and user which modified an entry at the proper table. Also use a table called 'logs' (or other configurated for that) to save created/edited action for continuous changes history. Code comments in brazilian portuguese. ----- Behavior que permite log automágico de ações executadas em uma aplicação com usuários autenticados. Armazena informações do usuário que criou um registro, e do usuário que alterou o registro no próprio registro. Ainda utiliza um modelo auxiliar Logger (ou outro configurado para isso) para registrar ações de inserção/edição e manter um histórico contínuo de alterações. PHP version > 5.3.1 Licensed under The MIT License Redistributions of files must retain the above copyright notice.
상속: extends ModelBehavior
파일 보기 프로젝트 열기: robwilkerson/cakephp-audit-log-plugin 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_modelOrder A copy of the model order to restore from
$_modelVirtualFields A copy of the model virtual fields to restore from
$_original array A copy of the object as it existed prior to the save. We're going to store this off, so we can calculate the deltas after save.
$_requestId string The requestId is a unique ID generated once per request to allow multiple record changes to be grouped by request

공개 메소드들

메소드 설명
afterDelete ( Model $Model ) : void Executed after a model is deleted.
afterSave ( Model $Model, boolean $created, array $options = [] ) : true Executed after a save operation completes.
beforeDelete ( Model $Model, boolean $cascade = true ) : true Executed before a delete operation.
beforeSave ( Model $Model, array $options = [] ) : true Executed before a save operation.
setup ( Model $Model, array $settings = [] ) : void Initiate behavior for the model using specified settings.

보호된 메소드들

메소드 설명
_getModelData ( Model $Model ) : array | false Get model data
_isAuditLogModel ( Model $Model ) : boolean Check if the given model is one of AuditLog ones
_requestId ( ) : null | string Get request ID
_restoreVirtualFields ( Model $Model ) : void Restore the virtual fields & order
_unsetVirtualFieldsTemporarily ( Model $Model ) : void Preserve and unset virtual fields and order as we don't need them and since they can cause SQL errors

메소드 상세

_getModelData() 보호된 메소드

Retrieves the entire set model data contained to the primary object and any/all HABTM associated data that has been configured with the behavior. Additionally, for the HABTM data, all we care about is the IDs, so the data will be reduced to an indexed array of those IDs.
protected _getModelData ( Model $Model ) : array | false
$Model Model The model that uses the behavior.
리턴 array | false The model data or false.

_isAuditLogModel() 보호된 메소드

Check if the given model is one of AuditLog ones
protected _isAuditLogModel ( Model $Model ) : boolean
$Model Model The model to check
리턴 boolean True if yes, else false.

_requestId() 보호된 메소드

Get request ID
protected _requestId ( ) : null | string
리턴 null | string The request ID.

_restoreVirtualFields() 보호된 메소드

Restore the virtual fields & order
protected _restoreVirtualFields ( Model $Model ) : void
$Model Model The model to restore the virtual fields for.
리턴 void

_unsetVirtualFieldsTemporarily() 보호된 메소드

Preserve and unset virtual fields and order as we don't need them and since they can cause SQL errors
protected _unsetVirtualFieldsTemporarily ( Model $Model ) : void
$Model Model The model to unset the virtual fields from.
리턴 void

afterDelete() 공개 메소드

Executed after a model is deleted.
public afterDelete ( Model $Model ) : void
$Model Model The model that is used for the delete operation.
리턴 void

afterSave() 공개 메소드

Executed after a save operation completes.
public afterSave ( Model $Model, boolean $created, array $options = [] ) : true
$Model Model The model that is used for the save operation.
$created boolean True, if the save operation was an insertion, false otherwise.
$options array The options data (unused).
리턴 true Always true.

beforeDelete() 공개 메소드

Executed before a delete operation.
public beforeDelete ( Model $Model, boolean $cascade = true ) : true
$Model Model The model using the behavior.
$cascade boolean Whether to cascade (unused).
리턴 true Always true.

beforeSave() 공개 메소드

Executed before a save operation.
public beforeSave ( Model $Model, array $options = [] ) : true
$Model Model The model using the behavior.
$options array The options data (unused).
리턴 true Always true.

setup() 공개 메소드

Available settings: - ignore array, optional An array of property names to be ignored when records are created in the deltas table. - habtm array, optional An array of models that have a HABTM relationship with the acting model and whose changes should be monitored with the model.
public setup ( Model $Model, array $settings = [] ) : void
$Model Model The model using the behavior.
$settings array The settings overrides.
리턴 void

프로퍼티 상세

$_modelOrder 보호되어 있는 프로퍼티

A copy of the model order to restore from
protected $_modelOrder

$_modelVirtualFields 보호되어 있는 프로퍼티

A copy of the model virtual fields to restore from
protected $_modelVirtualFields

$_original 보호되어 있는 프로퍼티

A copy of the object as it existed prior to the save. We're going to store this off, so we can calculate the deltas after save.
protected array $_original
리턴 array

$_requestId 보호되어 있는 정적으로 프로퍼티

The requestId is a unique ID generated once per request to allow multiple record changes to be grouped by request
protected static string $_requestId
리턴 string