12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php namespace System;
- class Route {
-
- public $key;
-
- public $callback;
-
- public $parameters;
-
- public function __construct($key, $callback, $parameters = array())
- {
- $this->key = $key;
- $this->callback = $callback;
- $this->parameters = $parameters;
- }
-
- public function call()
- {
- $response = null;
- if (is_callable($this->callback))
- {
- $response = call_user_func_array($this->callback, $this->parameters);
- }
- elseif (is_array($this->callback))
- {
- $response = isset($this->callback['before']) ? Route\Filter::call($this->callback['before'], array(), true) : null;
- if (is_null($response) and isset($this->callback['do']))
- {
- $response = call_user_func_array($this->callback['do'], $this->parameters);
- }
- }
- $response = Response::prepare($response);
- if (is_array($this->callback) and isset($this->callback['after']))
- {
- Route\Filter::call($this->callback['after'], array($response));
- }
- return $response;
- }
- }
|