Fuel\Event\Container::off PHP Method

off() public method

Removes one or more events.
public off ( string $event = null, mixed $handler = null, mixed $context = null ) : object
$event string event name
$handler mixed event handler
$context mixed closure context
return object $this
    public function off($event = null, $handler = null, $context = null)
    {
        // When there are no events to fire
        if ($event and !isset($this->listeners[$event]) or empty($this->listeners[$event])) {
            // Skip execution
            return $this;
        }
        // When an event name is given, only fetch that stack.
        $events = $event ? $this->listeners[$event] : $this->listeners;
        foreach ($events as $k => $e) {
            // If the event matches, delete it
            if ($e->is($event, $handler, $context)) {
                // Use the event param.
                if ($event) {
                    // Saves a function call ;-)
                    unset($this->listeners[$event][$k]);
                } else {
                    // Otherwise, retrieve the event name from the Event object.
                    unset($this->listeners[$e->event()][$k]);
                }
            }
        }
        return $this;
    }