From 2d1180f35caeaab90353b445e5720f7df61ff286 Mon Sep 17 00:00:00 2001 From: mdeweerd Date: Mon, 6 May 2013 09:56:15 +0300 Subject: [PATCH] Add ensureBehaviors() to detachBehavior*() Need to add ensureBehaviors() to detachBehavior*(). The intent may be to detach behaviors defined in behaviors(). In the original implementation, if these behaviors() are not yet attached, they can not selectively be detached. --- framework/base/Component.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/base/Component.php b/framework/base/Component.php index 80259e7..582cf03 100644 --- a/framework/base/Component.php +++ b/framework/base/Component.php @@ -496,6 +496,7 @@ class Component extends Object */ public function detachBehavior($name) { + $this->ensureBehaviors(); if (isset($this->_behaviors[$name])) { $behavior = $this->_behaviors[$name]; unset($this->_behaviors[$name]); @@ -511,6 +512,7 @@ class Component extends Object */ public function detachBehaviors() { + $this->ensureBehaviors(); if ($this->_behaviors !== null) { foreach ($this->_behaviors as $name => $behavior) { $this->detachBehavior($name);