components)) { return; } $this->_Controller = $Controller; $components = ComponentCollection::normalizeObjectArray($Controller->components); foreach ($components as $name => $properties) { $Controller->{$name} = $this->load($properties['class'], $properties['settings']); } } /** * Get the controller associated with the collection. * * @return Controller. */ public function getController() { return $this->_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. * * @param string $component Component name to load * @param array $settings Settings for the component. * @return Component A component object, Either the existing loaded component or a new one. * @throws MissingComponentFileException, MissingComponentClassException when the component could not be found */ public function load($component, $settings = array()) { list($plugin, $name) = pluginSplit($component); if (isset($this->_loaded[$name])) { return $this->_loaded[$name]; } $componentClass = $name . 'Component'; App::uses($componentClass, 'Controller/Component'); if (!class_exists($componentClass)) { if (!class_exists($componentClass)) { throw new MissingComponentFileException(array( 'file' => Inflector::underscore($component) . '.php', 'class' => $componentClass )); } } $this->_loaded[$name] = new $componentClass($this, $settings); $enable = isset($settings['enabled']) ? $settings['enabled'] : true; if ($enable === true) { $this->_enabled[] = $name; } return $this->_loaded[$name]; } }