Components collection is used as a registry for loaded components and handles loading and constructing component class objects.
ComponentCollection implements CakeEventListener $_Controller protected Returns the implemented events that will get routed to the trigger function in order to dispatch them separately on each component
Initializes all the Components for a controller. Attaches a reference of each component to the Controller.
Loads/constructs a component. Will return the instance in the registry if it already exists. You can use $settings['enabled'] = false to disable callbacks on a component when loading it. Callbacks default to on. Disabled component methods work as normal, only callbacks are disabled.
getController( )
Get the controller associated with the collection.
ControllerimplementedEvents( )
Returns the implemented events that will get routed to the trigger function in order to dispatch them separately on each component
CakeEventListener::implementedEvents() init( Controller $Controller )
Initializes all the Components for a controller. Attaches a reference of each component to the Controller.
Controller $Controller load( string $component , array $settings array() )
Loads/constructs a component. Will return the instance in the registry if it already exists. You can use $settings['enabled'] = false to disable callbacks on a component when loading it. Callbacks default to on. Disabled component methods work as normal, only callbacks are disabled.
You can alias your component as an existing component by setting the 'className' key, i.e.,
public $components = array(
'Email' => array(
'className' => 'AliasedEmail'
);
); All calls to the Email component would use AliasedEmail instead.
$component $settings optional array() ComponentMissingComponentExceptionsetController( Controller $Controller )
Set the controller associated with the collection.
Controller $Controller __get( string $name )
Provide public read access to the loaded objects
$name __isset( string $name )
Provide isset access to _loaded
$name attached( string $name null )
Gets the list of attached objects, or, whether the given object is attached
$name optional null Optional. The name of the object to check the status of. If omitted, returns an array of currently-attached objects
If $name is specified, returns the boolean status of the corresponding object. Otherwise, returns an array of all attached objects.
disable( 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 Optional. The name of the object to check the status of. If omitted, returns an array of currently-enabled object
If $name is specified, returns the boolean status of the corresponding object. Otherwise, returns an array of all enabled objects.
loaded( string $name null )
Gets the list of loaded objects, or, whether the given object is loaded
$name optional null Optional. The name of the object to check the status of. If omitted, returns an array of currently-loaded objects
If $name is specified, returns the boolean status of the corresponding object. Otherwise, returns an array of all loaded objects.
normalizeObjectArray( array $objects )
Normalizes an object array, creates an array that makes lazy loading easier
$objects prioritize( )
Prioritize list of enabled object
set( string $name null , CakeObject $object null )
Adds or overwrites an instantiated object to the collection
$name optional null CakeObject $object optional null setPriority( string|array $name , integer|null $priority null )
Set priority for an object or array of objects
$name CamelCased name of the object(s) to enable (string or array) If string the second param $priority is used else it should be an associative array with keys as object names and values as priorities to set.
$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 Method to fire on all the objects. Its assumed all the objects implement the method you are calling. If an instance of CakeEvent is provided, then then Event name will parsed to get the callback name. This is done by getting the last word after any dot in the event name (eg. Model.afterSave event will trigger the afterSave callback)
$params optional array() $options optional array() CakeExceptionunload( string $name )
Name of the object to remove from the collection
$name protected Controller
The controller that this collection was initialized with.
null
© 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.
https://api.cakephp.org/2.9/class-ComponentCollection.html