ContainableBehavior Class Reference

Inheritance diagram for ContainableBehavior:

ModelBehavior Object

List of all members.


Public Member Functions

 beforeFind (&$Model, $query)
 contain (&$Model)
 containments (&$Model, $contain, $containments=array(), $throwErrors=null)
 containmentsMap ($containments)
 fieldDependencies (&$Model, $map, $fields=array())
 resetBindings (&$Model)
 setup (&$Model, $settings=array())

Public Attributes

 $runtime = array()
 $types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany')

Detailed Description

Definition at line 36 of file containable.php.


Member Function Documentation

ContainableBehavior::beforeFind ( &$  Model,
query 
)

Runs before a find() operation. Used to allow 'contain' setting as part of the find call, like this:

Model->find('all', array('contain' => array('Model1', 'Model2')));

Model->find('all', array('contain' => array( 'Model1' => array('Model11', 'Model12'), 'Model2', 'Model3' => array( 'Model31' => 'Model311', 'Model32', 'Model33' => array('Model331', 'Model332') )));

Parameters:
object $Model Model using the behavior
array $query Query parameters as set by cake public

Reimplemented from ModelBehavior.

Definition at line 94 of file containable.php.

References contain(), containments(), containmentsMap(), and fieldDependencies().

ContainableBehavior::contain ( &$  Model  ) 

Unbinds all relations from a model except the specified ones. Calling this function without parameters unbinds all related models.

Parameters:
object $Model Model on which binding restriction is being applied public

Definition at line 206 of file containable.php.

References am().

Referenced by beforeFind().

ContainableBehavior::containments ( &$  Model,
contain,
containments = array(),
throwErrors = null 
)

Process containments for model.

Parameters:
object $Model Model on which binding restriction is being applied
array $contain Parameters to use for restricting this model
array $containments Current set of containments
bool $throwErrors Wether unexisting bindings show throw errors
Returns:
array Containments public

Definition at line 243 of file containable.php.

References a(), Set::merge(), and order.

Referenced by beforeFind().

ContainableBehavior::containmentsMap ( containments  ) 

Build the map of containments

Parameters:
array $containments Containments
Returns:
array Built containments public

Definition at line 391 of file containable.php.

Referenced by beforeFind().

ContainableBehavior::fieldDependencies ( &$  Model,
map,
fields = array() 
)

Calculate needed fields to fetch the required bindings for the given model.

Parameters:
object $Model Model
array $map Map of relations for given model
mixed $fields If array, fields to initially load, if false use $Model as primary model
Returns:
array Fields public

Definition at line 346 of file containable.php.

Referenced by beforeFind().

ContainableBehavior::resetBindings ( &$  Model  ) 

Permanently restore the original binding settings of given model, useful for restoring the bindings after using 'reset' => false as part of the contain call.

Parameters:
object $Model Model on which to reset bindings public

Definition at line 219 of file containable.php.

ContainableBehavior::setup ( &$  Model,
settings = array() 
)

Initiate behavior for the model using specified settings. Available settings:

  • recursive: (boolean, optional) set to true to allow containable to automatically determine the recursiveness level needed to fetch specified models, and set the model recursiveness to this level. setting it to false disables this feature. DEFAULTS TO: true

  • notices: (boolean, optional) issues E_NOTICES for bindings referenced in a containable call that are not valid. DEFAULTS TO: true

  • autoFields: (boolean, optional) auto-add needed fields to fetch requested bindings. DEFAULTS TO: true

Parameters:
object $Model Model using the behavior
array $settings Settings to override for model. public

Reimplemented from ModelBehavior.

Definition at line 69 of file containable.php.

References ModelBehavior::$settings, and ife().


Member Data Documentation

ContainableBehavior::$runtime = array()

Definition at line 50 of file containable.php.

ContainableBehavior::$types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany')

Definition at line 43 of file containable.php.


The documentation for this class was generated from the following file: