Browse Source

refactored Component::off().

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
0ee120f5f9
  1. 9
      framework/yii/base/Component.php

9
framework/yii/base/Component.php

@ -406,9 +406,12 @@ class Component extends Object
public function off($name, $handler = null) public function off($name, $handler = null)
{ {
$this->ensureBehaviors(); $this->ensureBehaviors();
if (isset($this->_events[$name])) { if (empty($this->_events[$name])) {
return false;
}
if ($handler === null) { if ($handler === null) {
$this->_events[$name] = []; unset($this->_events[$name]);
return true;
} else { } else {
$removed = false; $removed = false;
foreach ($this->_events[$name] as $i => $event) { foreach ($this->_events[$name] as $i => $event) {
@ -423,8 +426,6 @@ class Component extends Object
return $removed; return $removed;
} }
} }
return false;
}
/** /**
* Triggers an event. * Triggers an event.

Loading…
Cancel
Save