phpDocumentor Swift
[ class tree: Swift ] [ index: Swift ] [ all elements ]

Class: SwiftRouter

Source Location: /classes/SwiftRouter.php

Class SwiftRouter

Class Overview
Method Summary
SwiftRouter   __construct()   Creates a new SwiftRouter object
string   dispatch()   Finds and returns the first route that matches the request uri.
Array   getAllParams()   Get the params that were matched after dispatching the last URL.
array   getAllRequestVars()   Get and return an array of all request variables.
string|null   getParam()   Get a param that was matched after dispatching the last URL.
string|null   getPath()   Get the path in the request URI at the given level.
integer   getPathCount()   Get the path count in the request URI.
array   getPaths()   Get the paths array created from the Request URI during init.
string   getRequestMethod()   Get the method used for the request.
string   getRequestUri()   Get the request URI.
string|null   getRequestVar()   Get a script var with the given name.
array   getRoutes()   Get the entire routes array.
boolean   isGetRequest()   Returns true if the request used a GET method.
boolean   isPostRequest()   Returns true if the request used a POST method.
string   setRoute()   Add a route with the given pattern and callback function

[ Top ]
Methods
Constructor __construct  [line 55]

  SwiftRouter __construct( )

Creates a new SwiftRouter object


API Tags:
Return:  The new SwiftRouter object
Access:  public


[ Top ]
dispatch  [line 71]

  string dispatch( )

Finds and returns the first route that matches the request uri.


API Tags:
Return:  The callback function for the matching route. Returns null when no match is found.
Access:  public


[ Top ]
getAllParams  [line 198]

  Array getAllParams( )

Get the params that were matched after dispatching the last URL.


API Tags:
Return:  Array of params.
Access:  public


[ Top ]
getAllRequestVars  [line 177]

  array getAllRequestVars( )

Get and return an array of all request variables.


API Tags:
Return:  Array of script vars.
Access:  public


[ Top ]
getParam  [line 207]

  string|null getParam( string $key  )

Get a param that was matched after dispatching the last URL.

Parameters:
string   $key:  The key of the param.

API Tags:
Return:  Value of the given param or null if does not exist.
Access:  public


[ Top ]
getPath  [line 133]

  string|null getPath( integer $num  )

Get the path in the request URI at the given level.

Parameters:
integer   $num:  Level of path to retrive from request URI.

API Tags:
Return:  The path string or null if does not exist.
Access:  public


[ Top ]
getPathCount  [line 153]

  integer getPathCount( )

Get the path count in the request URI.


API Tags:
Return:  Number of paths.
Access:  public


[ Top ]
getPaths  [line 145]

  array getPaths( )

Get the paths array created from the Request URI during init.


API Tags:
Return:  Array of all paths from request URI.
Access:  public


[ Top ]
getRequestMethod  [line 169]

  string getRequestMethod( )

Get the method used for the request.


API Tags:
Return:  Name of method. (GET|POST|PUT|DELETE)
Access:  public


[ Top ]
getRequestUri  [line 161]

  string getRequestUri( )

Get the request URI.


API Tags:
Return:  The request URI string.
Access:  public


[ Top ]
getRequestVar  [line 186]

  string|null getRequestVar( string $key  )

Get a script var with the given name.

Parameters:
string   $key:  The key of the request variable.

API Tags:
Return:  Value of the given var or null if does not exist.
Access:  public


[ Top ]
getRoutes  [line 112]

  array getRoutes( )

Get the entire routes array.


API Tags:
Return:  All routes for the Router object.
Access:  public


[ Top ]
isGetRequest  [line 100]

  boolean isGetRequest( )

Returns true if the request used a GET method.


API Tags:
Return:  True if GET method used, false otherwise.
Access:  public


[ Top ]
isPostRequest  [line 88]

  boolean isPostRequest( )

Returns true if the request used a POST method.


API Tags:
Return:  True if POST method used, false otherwise.
Access:  public


[ Top ]
setRoute  [line 124]

  string setRoute( $pattern, string $callback, string $path  )

Add a route with the given pattern and callback function

Parameters:
string   $path:  Pattern to match against the request URI. The pattern may be a regular expression. Each match via preg_match() will be stored as a param.
string   $callback:  Callback function to call on a match.
   $pattern: 

API Tags:
Return:  The given route for this path.
Access:  public


[ Top ]

Documentation generated on Tue, 08 Oct 2013 05:37:16 +0200 by phpDocumentor 1.4.4