_loaded[$name])) { return $this->_loaded[$name]; } $componentClass = $name . 'Component'; if (!class_exists($componentClass)) { if (!App::import('Component', $component)) { throw new MissingComponentFileException(Inflector::underscore($component) . '.php'); } if (!class_exists($componentClass)) { throw new MissingComponentFileException($component); } } $this->_loaded[$name] = new $componentClass($this, $settings); if ($enable === true) { $this->_enabled[] = $name; } return $this->_loaded[$name]; } /** * Name of the component to remove from the collection * * @param string $name Name of component to delete. * @return void */ public function unload($name) { list($plugin, $name) = pluginSplit($name); unset($this->_loaded[$name]); $this->_enabled = array_values(array_diff($this->_enabled, (array)$name)); } } /** * Exceptions used by the ComponentCollection. */ class MissingComponentFileException extends RuntimeException { } class MissingComponentClassException extends RuntimeException { }