public function attach($event, $callback) {
        $events = is_array($event) ? $event : array($event);
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        foreach ($events as $event) {
            $eventObject = is_object($event) ? $event : new GenericEvent($event);
            if (!isset($listeners[$eventObject->getName()])) {
                $listeners[$eventObject->getName()] = array();
            }

            if (!in_array($callback, $listeners[$eventObject->getName()], true)) {
                $listeners[$eventObject->getName()][] = $callback;
            }
        }
        $this->setOption(self::OPTION_LISTENERS, $listeners);
    }
public function attach($event, $callback) {
        $events = is_array($event) ? $event : array($event);
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        foreach ($events as $event) {
            $eventObject = is_object($event) ? $event : new GenericEvent($event);
            if (!isset($listeners[$eventObject->getName()])) {
                $listeners[$eventObject->getName()] = array();
            }

            if (!in_array($callback, $listeners[$eventObject->getName()], true)) {
                $listeners[$eventObject->getName()][] = $callback;
            }
        }
        $this->setOption(self::OPTION_LISTENERS, $listeners);
    }
public function attach ( $ event , $ callback ) { $ events = is_array ( $ event ) ? $ event : array ( $ event ) ; $ listeners = $ this -> getOption ( self :: OPTION_LISTENERS ) ; foreach ( $ events as $ event ) { $ eventObject = is_object ( $ event ) ? $ event : new GenericEvent ( $ event ) ; if ( ! isset ( $ listeners [ $ eventObject -> getName ( ) ] ) ) { $ listeners [ $ eventObject -> getName ( ) ] = array ( ) ; } if ( ! in_array ( $ callback , $ listeners [ $ eventObject -> getName ( ) ] , true ) ) { $ listeners [ $ eventObject -> getName ( ) ] [ ] = $ callback ; } } $ this -> setOption ( self :: OPTION_LISTENERS , $ listeners ) ; }
Attach a Listener to one or multiple events

@param mixed $event either an Event object or a string
@param callable $callback
Attach a Listener to one or multiple events