public static function rest_path($uri=false, $SERVER_SCRIPT_NAME=false /* unit test only */) {
        global $CFG;
        $retval = self::parse_rest_path($uri, $SERVER_SCRIPT_NAME);
        if ( ! is_array($retval) ) return false;
        $retobj = new \stdClass();
        if ( $retval[0] == '/' ) {
            $retobj->parent = '';
        } else {
            $retobj->parent = $retval[0];
        }
        $retobj->base_url = self::get_base_url($CFG->wwwroot);
        $retobj->controller = $retval[1];
        $retobj->extra = $retval[2];
        $pieces = explode('/', $retval[2]);
        $retobj->action = false;
        $retobj->parameters = array();
        if ( count($pieces) > 0 && strlen($pieces[0]) ) {
            $retobj->action = array_shift($pieces);
            $retobj->parameters = $pieces;
        }
        $retobj->current = $retobj->parent;
        $retobj->full = $retobj->parent;
        if ( strlen($retobj->controller) > 0 ) {
             $retobj->current .= '/' . $retobj->controller;
             $retobj->full .= '/' . $retobj->controller;
        }
        if ( strlen($retobj->extra) > 0 ) {
             $retobj->full .= '/' . $retobj->extra;
        }

        return $retobj;
    }