Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hoa\Router\Generic Class Reference
Inheritance diagram for Hoa\Router\Generic:

Public Member Functions

 addRule ($id, Array $methods, $pattern, $call=null, $able=null, Array $variables=[])
 
 addPrivateRule ($id, Array $methods, $pattern, $call=null, $able=null, Array $variables=[])
 
 __call ($name, $arguments)
 
 removeRule ($id)
 
 ruleExists ($id)
 
 getRules ()
 
 getRule ($id)
 
getTheRule ()
 
- Public Member Functions inherited from Hoa\Router\Router
 route ()
 
 unroute ($id, Array $variables=[])
 
 getMethod ()
 
 isAsynchronous ()
 

Protected Member Functions

 _addRule ($visibility, $id, Array $methods, $pattern, $call, $able, Array $variables)
 

Protected Attributes

 $_rules = []
 
 $_rule = null
 

Static Protected Attributes

static $_methods = []
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Router\Router
const VISIBILITY_PUBLIC = 0
 
const VISIBILITY_PRIVATE = 1
 
const RULE_VISIBILITY = 0
 
const RULE_ID = 1
 
const RULE_METHODS = 2
 
const RULE_PATTERN = 3
 
const RULE_CALL = 4
 
const RULE_ABLE = 5
 
const RULE_VARIABLES = 6
 

Detailed Description

Class .

Generic router.

Definition at line 47 of file Generic.php.

Member Function Documentation

Hoa\Router\Generic::__call (   $name,
  $arguments 
)

Helper for adding rules. Methods are concatenated by _. If prefixed by _, it's a private rule. In addition, the keyword “any” takes place for all methods. Examples: get(…) : addRule(…, array('get'), …); get_post(…) : addRule(…, array('get', 'post'), …); post_get(…) : same that above; _get(…) : addPrivateRule(…, array('get'), …); any(…) : addRule(…, array(<all methods>), …); head_delete(…): addRule(…, array('head', 'delete'), …).

Parameters
string$namePlease, see API documentation.
array$argumentsArguments for add*Rule() methods.
Returns
Exceptions

Definition at line 174 of file Generic.php.

175  {
176  if ('_' === $name[0]) {
177  $name = substr($name, 1);
178  $method = 'addPrivateRule';
179  } else {
180  $method = 'addRule';
181  }
182 
183  if ('any' === $name) {
184  array_unshift($arguments, static::$_methods);
185  } else {
186  array_unshift($arguments, explode('_', $name));
187  }
188 
189  $handle = $arguments[0];
190  $arguments[0] = $arguments[1];
191  $arguments[1] = $handle;
192 
193  return call_user_func_array([$this, $method], $arguments);
194  }
Hoa\Router\Generic::_addRule (   $visibility,
  $id,
Array  $methods,
  $pattern,
  $call,
  $able,
Array  $variables 
)
abstractprotected

Fallback for add*Rule() methods.

Parameters
int$visibilityVisibility (please, see Router::VISIBILITY_* constants).
string$idID.
array$methodsHTTP methods allowed by the rule.
string$patternPattern (on-subdomain-request).
mixed$callCall (first part).
mixed$ableAble (second part).
array$variablesVariables (default or additional values).
Returns
Exceptions

Here is the caller graph for this function:

Hoa\Router\Generic::addPrivateRule (   $id,
Array  $methods,
  $pattern,
  $call = null,
  $able = null,
Array  $variables = [] 
)

Add a private rule.

Parameters
string$idID.
array$methodsHTTP methods allowed by the rule.
string$patternPattern (on-subdomain-request).
mixed$callCall (first part).
mixed$ableAble (second part).
array$variablesVariables (default or additional values).
Returns
Exceptions

Implements Hoa\Router\Router.

Definition at line 139 of file Generic.php.

145  {
146  return $this->_addRule(
148  $id,
149  $methods,
150  $pattern,
151  $call,
152  $able,
153  $variables
154  );
155  }
const VISIBILITY_PRIVATE
Definition: Router.php:63
_addRule($visibility, $id, Array $methods, $pattern, $call, $able, Array $variables)

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Router\Generic::addRule (   $id,
Array  $methods,
  $pattern,
  $call = null,
  $able = null,
Array  $variables = [] 
)

Add a public rule.

Parameters
string$idID.
array$methodsHTTP methods allowed by the rule.
string$patternPattern (on-subdomain-request).
mixed$callCall (first part).
mixed$ableAble (second part).
array$variablesVariables (default or additional values).
Returns
Exceptions

Implements Hoa\Router\Router.

Definition at line 108 of file Generic.php.

115  {
116  return $this->_addRule(
118  $id,
119  $methods,
120  $pattern,
121  $call,
122  $able,
123  $variables
124  );
125  }
const VISIBILITY_PUBLIC
Definition: Router.php:56
_addRule($visibility, $id, Array $methods, $pattern, $call, $able, Array $variables)

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Router\Generic::getRule (   $id)

Get a specific rule.

Parameters
string$idID.
Returns
array
Exceptions

Definition at line 237 of file Generic.php.

238  {
239  if (false === $this->ruleExists($id)) {
240  throw new Exception('Rule %s does not exist.', 0, $id);
241  }
242 
243  return $this->_rules[$id];
244  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Router\Generic::getRules ( )

Get all rules.

Returns
array

Definition at line 225 of file Generic.php.

226  {
227  return $this->_rules;
228  }

Here is the caller graph for this function:

& Hoa\Router\Generic::getTheRule ( )

Get the selected rule after routing.

Returns
array

Implements Hoa\Router\Router.

Definition at line 251 of file Generic.php.

252  {
253  return $this->_rule;
254  }
Hoa\Router\Generic::removeRule (   $id)

Remove a rule.

Parameters
string$idID.
Returns
void

Implements Hoa\Router\Router.

Definition at line 202 of file Generic.php.

203  {
204  unset($this->_rules[$id]);
205 
206  return;
207  }
Hoa\Router\Generic::ruleExists (   $id)

Check whether a rule exists.

Parameters
string$idID.
Returns
bool

Implements Hoa\Router\Router.

Definition at line 215 of file Generic.php.

216  {
217  return isset($this->_rules[$id]);
218  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Router\Generic::$_methods = []
staticprotected

Definition at line 68 of file Generic.php.

Hoa\Router\Generic::$_rule = null
protected

Definition at line 61 of file Generic.php.

Hoa\Router\Generic::$_rules = []
protected

Definition at line 54 of file Generic.php.


The documentation for this class was generated from the following file: