public function on($method, $listener)
    {
        if (!array_key_exists($method, $this->_listeners)) {
            $this->_listeners[$method] = [];
        }

        array_push($this->_listeners[$method], $listener);
    }
public function on($method, $listener)
    {
        if (!array_key_exists($method, $this->_listeners)) {
            $this->_listeners[$method] = [];
        }

        array_push($this->_listeners[$method], $listener);
    }
public function on ( $ method , $ listener ) { if ( ! array_key_exists ( $ method , $ this -> _listeners ) ) { $ this -> _listeners [ $ method ] = [ ] ; } array_push ( $ this -> _listeners [ $ method ] , $ listener ) ; }
Adds a request listener.

Example:

$c = new HttpController();
$c->on("PUT", function () {
echo "Processing PUT request\n";
});
$c->processRequest();

@param string   $method   Method name (GET, POST, PUT, etc...)
@param callable $listener Request listener

@return void
Adds a request listener .