Browse Source

Removed redundant code in detachBehaviors()

After ensureBehaviors() call $this->_behaviors is an array already.
And since detachBehavior() unsets elements in $this->_behaviors, $this->_behaviors turns out to be an empty array after all iterations.
tags/2.0.0-beta
Paul Kofmann 11 years ago
parent
commit
ee81915a1e
  1. 7
      framework/yii/base/Component.php

7
framework/yii/base/Component.php

@ -543,12 +543,9 @@ class Component extends Object
public function detachBehaviors() public function detachBehaviors()
{ {
$this->ensureBehaviors(); $this->ensureBehaviors();
if ($this->_behaviors !== null) { foreach ($this->_behaviors as $name => $behavior) {
foreach ($this->_behaviors as $name => $behavior) { $this->detachBehavior($name);
$this->detachBehavior($name);
}
} }
$this->_behaviors = [];
} }
/** /**

Loading…
Cancel
Save