off() public method

This method is the opposite of Component::on.
See also: on()
public off ( string $name, callable $handler = null ) : boolean
$name string event name
$handler callable the event handler to be removed. If it is null, all handlers attached to the named event will be removed.
return boolean if a handler is found and detached
Example #1
0
 public function off($name, $handler = null)
 {
     if ($handler === null) {
         unset($this->_handlers[$name]);
         return parent::off($name, $handler);
     } else {
         $removed = false;
         foreach ($this->_handlers[$name] as $i => $value) {
             if ($value === $handler) {
                 $removed = parent::off($name, [$this, $i]) || $removed;
                 unset($this->_handlers[$name][$i]);
             }
         }
         return $removed;
     }
 }
Example #2
0
 /**
  * Unbind event
  * @param Component $class
  * @param string $event
  */
 public function unbind(Component $class, $event)
 {
     $class->off($event);
 }