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. 3
      framework/yii/base/Component.php

3
framework/yii/base/Component.php

@ -543,13 +543,10 @@ class Component extends Object
public function detachBehaviors()
{
$this->ensureBehaviors();
if ($this->_behaviors !== null) {
foreach ($this->_behaviors as $name => $behavior) {
$this->detachBehavior($name);
}
}
$this->_behaviors = [];
}
/**
* Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.

Loading…
Cancel
Save