Zaphpa_Router::invoke_callback PHP Method

invoke_callback() protected method

Main reason this is a separate function is: in case library users want to change invokation logic, without having to copy/paste rest of the logic in the route() function.
protected invoke_callback ( $callback, $params )
    protected function invoke_callback($callback, $params)
    {
        $req = new Zaphpa_Request();
        $req->params = $params;
        $res = new Zaphpa_Response($req);
        /* Call preprocessors on each middleware impl */
        foreach (self::$middleware as $m) {
            if ($m->shouldRun('preroute')) {
                /* the preroute handled the request and doesn't want the main
                 * code to run.. e.g. if the preroute decided the session wasn't
                 * set and wants to issue a 401, or forward using a 302.
                 */
                if ($m->preroute($req, $res) === FALSE) {
                    return;
                    // nope! don't do anything else.
                }
                // continue as usual.
            }
        }
        return call_user_func($callback, $req, $res);
    }