Skip to content
Permalink
Browse files

Remove the default Component callbacks.

This will help make the callbacks more efficient, and reduce the number
of no-op callbacks  It also means that there is no need to call parent
anymore when simply extending Component.
  • Loading branch information...
markstory committed Jul 14, 2013
1 parent b35ff7e commit 599e26050eff31fda1d41ce191a53e07c3593894
Showing with 17 additions and 73 deletions.
  1. +17 −73 lib/Cake/Controller/Component.php
@@ -29,12 +29,24 @@
* Components can provide several callbacks that are fired at various stages of the request
* cycle. The available callbacks are:
*
* - `initialize()` - Fired before the controller's beforeFilter method.
* - `startup()` - Fired after the controller's beforeFilter method.
* - `beforeRender()` - Fired before the view + layout are rendered.
* - `shutdown()` - Fired after the action is complete and the view has been rendered.
* - `initialize()` - Called before the controller's beforeFilter method.
* - `startup()` - Called after the controller's beforeFilter method,
* and before the controller action is called.
* - `beforeRender()` - Called before the Controller beforeRender, and
* before the view class is loaded.
* - `shutdown()` - Called after the action is complete and the view has been rendered.
* but before Controller::afterFilter().
* - `beforeRedirect()` - Fired before a redirect() is done.
* - `beforeRedirect()` - Called before Controller::redirect(), and
* before a redirect() is done. 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.
*
* Each callback has a slightly different signature:
*
@@ -109,74 +121,6 @@ public function __get($name) {
}
}
/**
* Called before the Controller::beforeFilter().
*
* @param Event $event An Event instance
* @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(Event $event, Controller $controller) {
}
/**
* Called after the Controller::beforeFilter() and before the controller action
*
* @param Event $event An Event instance
* @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(Event $event, Controller $controller) {
}
/**
* Called before the Controller::beforeRender(), and before
* the view class is loaded, and before Controller::render()
*
* @param Event $event An Event instance
* @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(Event $event, Controller $controller) {
}
/**
* Called after Controller::render() and before the output is printed to the browser.
*
* @param Event $event An Event instance
* @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(Event $event, 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 Event $event An Event instance
* @param Controller $controller Controller with components to beforeRedirect
* @param string|array $url Either the string or URL array that is being redirected to.
* @param integer $status The status code of the redirect
* @param boolean $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(Event $event, Controller $controller, $url, $status = null, $exit = true) {
}
/**
* Get the Controller callbacks this Component is interested in.
*

0 comments on commit 599e260

Please sign in to comment.
You can’t perform that action at this time.