Class JSONEmbeddedModelFieldsBehavior
Behavior class for more advanced JSON storage in fields, using CModel children in protected/models/embedded for validation, input widget rendering, etc.
Supports multiple distinct stored structures of JSON (and also, with
encryption), distinguished by a separate attribute in the model (specified by
JSONEmbeddedModelFieldsBehavior::$templateAttr
), and each field embedded within the JSON has its own
special options (i.e. default values, specific input widgets, etc) defined in
the model classes used.
- CComponent
- CBehavior implements IBehavior
- CModelBehavior
- CActiveRecordBehavior
- TransformedFieldStorageBehavior
- EncryptedFieldsBehavior
- JSONEmbeddedModelFieldsBehavior
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/components/JSONEmbeddedModelFieldsBehavior.php
public
|
|
public
|
#
attributeModel( type $name, mixed $attributes = null )
Returns the model object for the named attribute |
public
|
#
beforeValidate( CModelEvent $event )
Performs validation on the embedded models, and instantiates/sets attributes of the embedded model if necessary. |
public
|
#
beforeSave( type $event )
Sets the encryption flag such that it accurately reflects the status of data going into the database. |
public
|
#
instantiateField( string $name )
Loads the embedded model into the owner's attribute and returns it |
public
|
#
instantiateFields( )
Instantiates all fields. This method must be called if the active record model is new. |
public
type
|
#
packAttribute( type $name )
JSON-encodes (and optionally encrypts) the model's attributes for storage. |
public
|
#
unpackAttribute( string $name, boolean $new = false )
Restores the model. It will also instantiate the embedded model if it hasn't
already been instantiated and "cache" it in |
setup(),
setupUnsafe()
|
afterFind(),
afterSave(),
packAll(),
unpackAll()
|
afterDelete(),
beforeCount(),
beforeDelete(),
beforeFind(),
events()
|
afterConstruct(),
afterValidate()
|
detach(),
getEnabled(),
getOwner(),
setEnabled()
|
__call(),
__get(),
__isset(),
__set(),
__unset(),
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
protected
boolean
|
$hasOptions | false |
#
In this case, the structure of the embedded object will be defined in the model classes, so there's no need to define the fields in the declaration of transformAttr. |
public
type
|
$attrModels | array() |
#
An array storing attribute models. Eliminates the need to re-instantiate during unpacking. |
public
boolean
|
$checkObject | false |
#
If true, throws an exception if no object has been instantiated. |
public
type
|
$encryptedFlagAttr | false |
#
Attribute of the model class indicating whether the attribute(s) is/are encrypted. if set to false, encryption will be completely ignored. |
public
array
|
$fixedModelFields | array() |
#
An array of field name keys to model name values defining fields which will always use the same embedded model type. |
public
string|array
|
$templateAttr |
|
#
Specifies the name(s) of the attribute(s) of the model implementing this behavior to be used for determining the model class corresponding to the embedded model. |
$encrypt,
$encryption
|
$transformAttributes
|
$owner
|
$enabled
|