Skip to content

Commit

Permalink
The event manager should be re-used.
Browse files Browse the repository at this point in the history
View::__construct() gets the controller's event manager,
only to override it the first time getEventManager() is called.

Don't overwrite the Controller's event manager as it allows plugins
to more easily hook into the view process.
  • Loading branch information
markstory committed May 15, 2012
1 parent 8103eae commit cbd6caf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Cake/View/View.php
Expand Up @@ -332,8 +332,10 @@ public function __construct(Controller $controller = null) {
* @return CakeEventManager * @return CakeEventManager
*/ */
public function getEventManager() { public function getEventManager() {
if (empty($this->_eventManager) || !$this->_eventManagerConfigured) { if (empty($this->_eventManager)) {
$this->_eventManager = new CakeEventManager(); $this->_eventManager = new CakeEventManager();
}
if (!$this->_eventManagerConfigured) {
$this->_eventManager->attach($this->Helpers); $this->_eventManager->attach($this->Helpers);
$this->_eventManagerConfigured = true; $this->_eventManagerConfigured = true;
} }
Expand Down

0 comments on commit cbd6caf

Please sign in to comment.