public function detach($event, $callback)
    {
        if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) {
            return false;
        }

        $removed = false;
        $listeners = $this->eventListeners[$event];
        $newListeners = new ListenerQueue();

        $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
        foreach ($listeners as $item) {
            if ($item['data'] === $callback) {
                $removed = true;
                continue;
            }

            $newListeners->insert($item['data'], $item['priority']);
        }
        $listeners->setExtractFlags(ListenerQueue::EXTR_DATA);

        $this->eventListeners[$event] = $newListeners;

        return $removed;
    }
public function detach($event, $callback)
    {
        if (!isset($this->eventListeners[$event]) || $this->eventListeners[$event]->isEmpty()) {
            return false;
        }

        $removed = false;
        $listeners = $this->eventListeners[$event];
        $newListeners = new ListenerQueue();

        $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
        foreach ($listeners as $item) {
            if ($item['data'] === $callback) {
                $removed = true;
                continue;
            }

            $newListeners->insert($item['data'], $item['priority']);
        }
        $listeners->setExtractFlags(ListenerQueue::EXTR_DATA);

        $this->eventListeners[$event] = $newListeners;

        return $removed;
    }
public function detach ( $ event , $ callback ) { if ( ! isset ( $ this -> eventListeners [ $ event ] ) || $ this -> eventListeners [ $ event ] -> isEmpty ( ) ) { return false ; } $ removed = false ; $ listeners = $ this -> eventListeners [ $ event ] ; $ newListeners = new ListenerQueue ( ) ; $ listeners -> setExtractFlags ( ListenerQueue :: EXTR_BOTH ) ; foreach ( $ listeners as $ item ) { if ( $ item [ 'data' ] === $ callback ) { $ removed = true ; continue ; } $ newListeners -> insert ( $ item [ 'data' ] , $ item [ 'priority' ] ) ; } $ listeners -> setExtractFlags ( ListenerQueue :: EXTR_DATA ) ; $ this -> eventListeners [ $ event ] = $ newListeners ; return $ removed ; }
Detaches a listener from an event.

@param string   $event    the event to attach too
@param callable $callback a callable function

@return bool true on success false on failure
Detaches a listener from an event .