Commit 0ee120f5 by Qiang Xue

refactored Component::off().

parent 06a91d62
......@@ -406,9 +406,12 @@ class Component extends Object
public function off($name, $handler = null)
{
$this->ensureBehaviors();
if (isset($this->_events[$name])) {
if (empty($this->_events[$name])) {
return false;
}
if ($handler === null) {
$this->_events[$name] = [];
unset($this->_events[$name]);
return true;
} else {
$removed = false;
foreach ($this->_events[$name] as $i => $event) {
......@@ -423,8 +426,6 @@ class Component extends Object
return $removed;
}
}
return false;
}
/**
* Triggers an event.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment