\TrackableBehavior

Trackable Behavior

Populate created_by and updated_by fields from session data.

It customize for NetCommons mainly customization is for phpmd

Summary

Methods
Properties
Constants
setup()
beforeSave()
No public properties found
No constants found
_hasTrackableFields()
_setupBelongsTo()
$_defaults
N/A
__getUserId()
No private properties found
N/A

Properties

$_defaults

$_defaults : 

Default settings

Change values for NetCommons created_by to created_user,updated_by to modified_user

Type

Methods

setup()

setup(\Model  $model, array  $config = array()) : void

Setup

Parameters

\Model $model

instance of model

array $config

array of configuration settings.

beforeSave()

beforeSave(\Model  $model, array  $options = array()) : boolean

Fill the created_by and updated_by fields

Note: Since shells do not have Sessions, created_by/updated_by fields will not be populated. If a shell needs to populate these fields, you can simulate a logged in user by setting Trackable.Auth config:

Configure::write('Trackable.User', array('id' => 1));

Note that value stored in this variable overrides session data.

Parameters

\Model $model

instance of model

array $options

Options passed from Model::save().

Returns

boolean —

True if the operation should continue, false if it should abort

_hasTrackableFields()

_hasTrackableFields(\Model  $model) : boolean

Checks wether model has the required fields

Parameters

\Model $model

instance of model

Returns

boolean —

True if $model has the required fields

_setupBelongsTo()

_setupBelongsTo(\Model  $model) : void

Bind relationship on the fly

Parameters

\Model $model

instance of model

__getUserId()

__getUserId(\Model  $model) : string

Get userId

Parameters

\Model $model

instance of model

Returns

string —

login userId