Model behavior collection class.
Defines the Behavior interface, and contains common model interaction functionality.
BehaviorCollection implements CakeEventListener attach( string $behavior , array $config array() )
Backwards compatible alias for load()
$behavior $config optional array() detach( string $name )
Backwards compatible alias for unload()
$name dispatchMethod( Model $model , string $method , array $params array() , boolean $strict false )
Dispatches a behavior method. Will call either normal methods or mapped methods.
If a method is not handled by the BehaviorCollection, and $strict is false, a special return of array('unhandled') will be returned to signal the method was not found.
Model $model $method $params optional array() $strict optional false arrayhasMethod( string $method , boolean $callback false )
Check to see if a behavior in this collection implements the provided method. Will also check mappedMethods.
$method $callback optional false mixedimplementedEvents( )
Returns the implemented events that will get routed to the trigger function in order to dispatch them separately on each behavior
arrayCakeEventListener::implementedEvents() init( string $modelName , array $behaviors array() )
Attaches a model object and loads a list of behaviors
$modelName $behaviors optional array() load( string $behavior , array $config array() )
Loads a behavior into the collection. You can use use $config['enabled'] = false to load a behavior with callbacks disabled. By default callbacks are enabled. Disable behaviors can still be used as normal.
You can alias your behavior as an existing behavior by setting the 'className' key, i.e.,
public $actsAs = array( 'Tree' => array( 'className' => 'AliasedTree' ); );
All calls to the Tree behavior would use AliasedTree instead.
$behavior $config optional array() booleanMissingBehaviorExceptionmethods( )
Gets the method list for attached behaviors, i.e. all public, non-callback methods. This does not include mappedMethods.
arrayunload( string $name )
Detaches a behavior from a model
$name ObjectCollection::unload() __get( string $name )
Provide public read access to the loaded objects
$name mixed__isset( string $name )
Provide isset access to _loaded
$name booleanattached( string $name null )
Gets the list of attached objects, or, whether the given object is attached
$name optional null mixeddisable( string|array $name )
Disables callbacks on an object or array of objects. Public object methods are still callable as normal.
$name enable( string|array $name , boolean $prioritize true )
Enables callbacks on an object or array of objects
$name $prioritize optional true enabled( string $name null )
Gets the list of currently-enabled objects, or, the current status of a single objects
$name optional null mixedloaded( string $name null )
Gets the list of loaded objects, or, whether the given object is loaded
$name optional null mixednormalizeObjectArray( array $objects )
Normalizes an object array, creates an array that makes lazy loading easier
$objects arrayprioritize( )
Prioritize list of enabled object
arrayset( string $name null , Object $object null )
Adds or overwrites an instantiated object to the collection
$name optional null Object $object optional null arraysetPriority( string|array $name , integer|null $priority null )
Set priority for an object or array of objects
$name $priority optional null trigger( string|CakeEvent $callback , array $params array() , array $options array() )
Trigger a callback method on every object in the collection. Used to trigger methods on objects in the collection. Will fire the methods in the order they were attached.
breakOn Set to the value or values you want the callback propagation to stop on. Can either be a scalar value, or an array of values to break on. Defaults to false.break Set to true to enabled breaking. When a trigger is broken, the last returned value will be returned. If used in combination with collectReturn the collected results will be returned. Defaults to false.collectReturn Set to true to collect the return of each object into an array. This array of return values will be returned from the trigger() call. Defaults to false.modParams Allows each object the callback gets called on to modify the parameters to the next object. Setting modParams to an integer value will allow you to modify the parameter with that index. Any non-null value will modify the parameter index indicated. Defaults to false.CakeEvent $callback Model.afterSave event will trigger the afterSave callback)$params optional array() $options optional array() mixedCakeException
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-BehaviorCollection.html