components)) { return; } $components = ComponentCollection::normalizeObjectArray($Controller->components); foreach ($components as $name => $properties) { $Controller->{$name} = $this->load($properties['class'], $properties['settings']); } } /** * Loads/constructs a component. Will return the instance in the registry if it already exists. * * @param string $component Component name to load * @param array $settings Settings for the component. * @param boolean $enable Whether or not this component should be enabled by default * @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(), $enable = true) { list($plugin, $name) = pluginSplit($component); if (isset($this->_loaded[$name])) { return $this->_loaded[$name]; } $componentClass = $name . 'Component'; if (!class_exists($componentClass)) { if (!App::import('Component', $component)) { throw new MissingComponentFileException(array( 'file' => Inflector::underscore($component) . '.php', 'class' => $componentClass )); } if (!class_exists($componentClass)) { throw new MissingComponentFileException(array( 'file' => Inflector::underscore($component) . '.php', 'class' => $componentClass )); } } $this->_loaded[$name] = new $componentClass($this, $settings); if ($enable === true) { $this->_enabled[] = $name; } return $this->_loaded[$name]; } }