_Collection = $collection; $this->settings = $settings; $this->_set($settings); if (!empty($this->components)) { $this->_componentMap = ComponentCollection::normalizeObjectArray($this->components); } } /** * Magic method for lazy loading $components. * * @param string $name Name of component to get. * @return mixed A Component object or null. */ public function __get($name) { if (isset($this->_componentMap[$name]) && !isset($this->{$name})) { $settings = array('enabled' => false) + (array)$this->_componentMap[$name]['settings']; $this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings); } if (isset($this->{$name})) { return $this->{$name}; } } /** * Called before the Controller::beforeFilter(). * * @param Controller $controller Controller with components to initialize * @return void * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize */ public function initialize(Controller $controller) { } /** * Called after the Controller::beforeFilter() and before the controller action * * @param Controller $controller Controller with components to startup * @return void * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup */ public function startup(Controller $controller) { } /** * Called before the Controller::beforeRender(), and before * the view class is loaded, and before Controller::render() * * @param Controller $controller Controller with components to beforeRender * @return void * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender */ public function beforeRender(Controller $controller) { } /** * Called after Controller::render() and before the output is printed to the browser. * * @param Controller $controller Controller with components to shutdown * @return void * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown */ public function shutdown(Controller $controller) { } /** * Called before Controller::redirect(). Allows you to replace the URL that will * be redirected to with a new URL. The return of this method can either be an array or a string. * * If the return is an array and contains a 'url' key. You may also supply the following: * * - `status` The status code for the redirect * - `exit` Whether or not the redirect should exit. * * If your response is a string or an array that does not contain a 'url' key it will * be used as the new URL to redirect to. * * @param Controller $controller Controller with components to beforeRedirect * @param string|array $url Either the string or URL array that is being redirected to. * @param int $status The status code of the redirect * @param bool $exit Will the script exit. * @return array|void Either an array or null. * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRedirect */ public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) { } }