Skip to content
Permalink
Browse files

Remove default implementations for helper callbacks.

Removing the empty methods removes *many* event listeners as most
helpers don't implment these callbacks. Now that callbacks are only
registered/listened to as needed this should greatly reduce the number
of event listeners used in the view layer.
  • Loading branch information...
markstory committed Jul 3, 2013
1 parent d51dd4b commit acf6949083889b623c5534a08bf3ea99ce7a115f
Showing with 18 additions and 71 deletions.
  1. +17 −70 lib/Cake/View/Helper.php
  2. +1 −1 lib/Cake/View/View.php
@@ -30,6 +30,23 @@
* Abstract base class for all other Helpers in CakePHP.
* Provides common methods and features.
*
*
* ## Callback methods
*
* Helpers support a number of callback methods. These callbacks allow you to hook into
* the various view lifecycle events and either modify existing view content or perform
* other application specific logic. The events are not implemented by this base class, as
* implementing a callback method subscribes a helper to the related event. The callback methods
* are as follows:
*
* - `beforeRender(Event $event, $viewFile)` - beforeRender is called before the view file is rendered.
* - `afterRender(Event $event, $viewFile)` - afterRender is called after the view file is rendered
* but before the layout has been rendered.
* - beforeLayout(Event $event, $layoutFile)` - beforeLayout is called before the layout is rendered.
* - `afterLayout(Event $event, $layoutFile)` - afterLayout is called after the layout has rendered.
* - `beforeRenderFile(Event $event, $viewFile)` - Called before any view fragment is rendered.
* - `afterRenderFile(Event $event, $viewFile, $content)` - Called after any view fragment is rendered.
*
* @package Cake.View
*/
class Helper extends Object implements EventListener {
@@ -794,76 +811,6 @@ public function output($str) {
return $str;
}
/**
* Before render callback. beforeRender is called before the view file is rendered.
*
* Overridden in subclasses.
*
* @param string $viewFile The view file that is going to be rendered
* @return void
*/
public function beforeRender($viewFile) {
}
/**
* After render callback. afterRender is called after the view file is rendered
* but before the layout has been rendered.
*
* Overridden in subclasses.
*
* @param string $viewFile The view file that was rendered.
* @return void
*/
public function afterRender($viewFile) {
}
/**
* Before layout callback. beforeLayout is called before the layout is rendered.
*
* Overridden in subclasses.
*
* @param string $layoutFile The layout about to be rendered.
* @return void
*/
public function beforeLayout($layoutFile) {
}
/**
* After layout callback. afterLayout is called after the layout has rendered.
*
* Overridden in subclasses.
*
* @param string $layoutFile The layout file that was rendered.
* @return void
*/
public function afterLayout($layoutFile) {
}
/**
* Before render file callback.
* Called before any view fragment is rendered.
*
* Overridden in subclasses.
*
* @param string $viewFile The file about to be rendered.
* @return void
*/
public function beforeRenderFile($viewfile) {
}
/**
* After render file callback.
* Called after any view fragment is rendered.
*
* Overridden in subclasses.
*
* @param string $viewFile The file just be rendered.
* @param string $content The content that was rendered.
* @return void
*/
public function afterRenderFile($viewfile, $content) {
}
/**
* Get the View callbacks this helper is interested in.
*
@@ -823,7 +823,7 @@ public function __isset($name) {
* @return void
*/
public function loadHelpers() {
$helpers = HelperCollection::normalizeObjectArray($this->helpers);
$helpers = ObjectCollection::normalizeObjectArray($this->helpers);
foreach ($helpers as $properties) {
list(, $class) = pluginSplit($properties['class']);
$this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);

0 comments on commit acf6949

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