Event.php
function attachListener($listener, $name = null, $priority = 10)
    {
        if ($priority == null)
            $priority = 10;

        if ($this->_tmp__isEmiting)
            throw new \RuntimeException('Can`t Attach Listener While Emit Events.');

        if ( is_int($name) ) {
            ## listener without specified name
            $priority = $name;
            $name     = null;
        }

        if ($name === null) {
            ## achieve default name if given listener is class
            if (is_object($listener) && !$listener instanceof \Closure)
                $name = get_class($listener);
        }
        
        if ($name !== null) {
            ## store listener with name, listener is not anonymous!
            if (isset($this->_c_listeners[$name]))
                throw new \RuntimeException("Listener with same name ({$name}) not allowed.");

            $this->_c_listeners[$name] = $listener;
        }

        $this->_listenerQueue()->insert($listener, $priority);
        return $this;
    }
function attachListener($listener, $name = null, $priority = 10)
    {
        if ($priority == null)
            $priority = 10;

        if ($this->_tmp__isEmiting)
            throw new \RuntimeException('Can`t Attach Listener While Emit Events.');

        if ( is_int($name) ) {
            ## listener without specified name
            $priority = $name;
            $name     = null;
        }

        if ($name === null) {
            ## achieve default name if given listener is class
            if (is_object($listener) && !$listener instanceof \Closure)
                $name = get_class($listener);
        }
        
        if ($name !== null) {
            ## store listener with name, listener is not anonymous!
            if (isset($this->_c_listeners[$name]))
                throw new \RuntimeException("Listener with same name ({$name}) not allowed.");

            $this->_c_listeners[$name] = $listener;
        }

        $this->_listenerQueue()->insert($listener, $priority);
        return $this;
    }
function attachListener ( $ listener , $ name = null , $ priority = 10 ) { if ( $ priority == null ) $ priority = 10 ; if ( $ this -> _tmp__isEmiting ) throw new \ RuntimeException ( 'Can`t Attach Listener While Emit Events.' ) ; if ( is_int ( $ name ) ) { ## listener without specified name $ priority = $ name ; $ name = null ; } if ( $ name === null ) { ## achieve default name if given listener is class if ( is_object ( $ listener ) && ! $ listener instanceof \ Closure ) $ name = get_class ( $ listener ) ; } if ( $ name !== null ) { ## store listener with name, listener is not anonymous! if ( isset ( $ this -> _c_listeners [ $ name ] ) ) throw new \ RuntimeException ( "Listener with same name ({$name}) not allowed." ) ; $ this -> _c_listeners [ $ name ] = $ listener ; } $ this -> _listenerQueue ( ) -> insert ( $ listener , $ priority ) ; return $ this ; }
Attach Listener To This Events

[code:]
attachListener($listener, $priority)
attachListener($listener, $nameOverride, $priority)
[code]

- store attached listener so we can list theme back
- listener with same name ({$name}) not allowed
- can`t Attach Listener While Emit Events

@param callable    $listener
@param int |string $name      priority, null | name, priority
@param null|int    $priority            null |       priority

@throws \RuntimeException Listener exists
@return $this
Attach Listener To This Events