Framework:sb Request

From Surebert wiki

Contents

Overview

sb_Requests are a modeled abstraction of the request from the user, either via browser or command line.

In order to model a request we use sb_Request which has the following properties. Every view has a $this->request property which is an sb_Request instance.

The Gateway itself also has a Gateway::$request static property which represents the main request. By having the request be a model we can abstract it and run requests from the Framework:command line to simulate and test client visits, and to create command line script with the same framework.

Properties

$this->url

The entires path requested with args e.g. /user/load/tony

$this->path

Only the view path minus args e.g. /user/load

$this->agent

The HTTP_USER_AGENT of the client or 'command line' if from the command line

$this->path_array

the path split as an array

$this->args

array of the args split at the ViewClass::$input_args_delimiter property

$this->get

an array derived from $_GET vars but passed through the Gateway and ViewClass's filter functions

$this->post

an array from $_POST vars but passed through the Gateway and ViewClass's filter functions

$this->data

an array of data from POST, PUT, DELETE requests

$this->cookie

an array from $_COOKIE vars but passed through the Gateway and ViewClass's filter functions

$this->files

an array from $_FILES but passed through the Gateway and ViewClass's filter functions

Example Request

This example request dump would be for http://yoursite.com/blog/read/5?sort=desc

text code

BlogController Object
(
    [title] => yoursite.roswellpark.org
    [input_args_delimiter:protected] => /
    [included] => 
    [request] => sb_Request Object
        (
            [path] => /blog/read
            [request] => /blog/read/5
            [path_array] => Array
                (
                    [0] => blog
                    [1] => read
                )
 
            [args] => Array
                (
                    [0] => 5
                )
 
            [get] => Array
                (
                    [sort] => desc
                )
 
            [post] => Array
                (
                )
 
            [data] => Array
                (
                )
 
            [cookie] => Array
                (
                    [rticketi] => 3a6d26d75bdfda97b5cb7b90d91eb0a4
                )
 
            [files] => Array
                (
                )
 
            [method] => GET
        )
 
    [args:protected] => Array
        (
            [0] => 5
        )
 
)