1 | <?php |
||
43 | abstract class RequestAbstract |
||
44 | { |
||
45 | const OS_LINUX = 'linux'; |
||
46 | const OS_WINDOWS = 'windows'; |
||
47 | const OS_UNKNOWN = 'unknown'; |
||
48 | |||
49 | /** |
||
50 | * @access protected |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $route; |
||
54 | |||
55 | /** |
||
56 | * @access protected |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $params = array(); |
||
60 | |||
61 | /** |
||
62 | * @access protected |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $routeParams = array(); |
||
66 | |||
67 | /** |
||
68 | * @access protected |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $base; |
||
72 | |||
73 | /** |
||
74 | * @access protected |
||
75 | * @var string |
||
76 | */ |
||
77 | protected $locale; |
||
78 | |||
79 | /** |
||
80 | * @access protected |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $operatingSystem; |
||
84 | |||
85 | /** |
||
86 | * @access protected |
||
87 | * @var array |
||
88 | */ |
||
89 | protected $data = array(); |
||
90 | |||
91 | /** |
||
92 | * Constructs the object |
||
93 | * |
||
94 | * @access public |
||
95 | * @param string $route |
||
96 | * @param array params |
||
97 | * @param string $base |
||
98 | * @param string $locale |
||
99 | * @param string $operatingSystem |
||
100 | * @param array $data |
||
101 | */ |
||
102 | 48 | public function __construct($route, $params, $base, $locale, $operatingSystem, $data = array()) |
|
121 | |||
122 | /** |
||
123 | * Returns the route of the request. |
||
124 | * |
||
125 | * @access public |
||
126 | * @return string |
||
127 | */ |
||
128 | 1 | public function getRoute() |
|
132 | |||
133 | /** |
||
134 | * Sets the route of the request |
||
135 | * |
||
136 | * @access public |
||
137 | * @param string $route |
||
138 | */ |
||
139 | 2 | public function setRoute($route) |
|
143 | |||
144 | /** |
||
145 | * Returns true if the given param key exists. |
||
146 | * |
||
147 | * @access public |
||
148 | * @param string $key |
||
149 | * @return string |
||
150 | */ |
||
151 | 2 | public function hasParam($key) |
|
155 | |||
156 | /** |
||
157 | * Returns the value for the given param key. If the |
||
158 | * key does not exists the function will return false. |
||
159 | * |
||
160 | * @access public |
||
161 | * @param string $key |
||
162 | * @return mixed |
||
163 | */ |
||
164 | 2 | public function getParam($key) |
|
172 | |||
173 | /** |
||
174 | * Returns all params of the request |
||
175 | * |
||
176 | * @access public |
||
177 | * @return array |
||
178 | */ |
||
179 | 1 | public function getParams() |
|
183 | |||
184 | /** |
||
185 | * Adds an parameter which is detected in the route. |
||
186 | * |
||
187 | * @access public |
||
188 | * @param mixed $param |
||
189 | * @param string $key |
||
190 | */ |
||
191 | 1 | public function addRouteParam($param, $key = '') |
|
199 | |||
200 | /** |
||
201 | * Sets the array of route params for the request |
||
202 | * |
||
203 | * @access public |
||
204 | * @param array $params |
||
205 | * @return boolean |
||
206 | */ |
||
207 | 3 | public function setRouteParams($params) |
|
217 | |||
218 | /** |
||
219 | * Returns the route param for the given index. |
||
220 | * |
||
221 | * @access public |
||
222 | * @param integer|string $key |
||
223 | * @return false|mixed |
||
224 | */ |
||
225 | 3 | public function getRouteParam($key) |
|
233 | |||
234 | /** |
||
235 | * Returns the delimitier, which is used to split the route |
||
236 | * into parts. |
||
237 | * |
||
238 | * @access public |
||
239 | * @return string |
||
240 | */ |
||
241 | abstract public function getRouteDelimiter(); |
||
242 | |||
243 | /** |
||
244 | * Returns the correct url for the given url part |
||
245 | * |
||
246 | * @access public |
||
247 | * @param string $routePart |
||
248 | * @return string |
||
249 | */ |
||
250 | 2 | public function getFullRoute($routePart = '') |
|
268 | |||
269 | /** |
||
270 | * Returns the locale of the request |
||
271 | * |
||
272 | * @access public |
||
273 | * @return string |
||
274 | */ |
||
275 | 1 | public function getLocale() |
|
279 | |||
280 | /** |
||
281 | * Returns the operating system of the machine |
||
282 | * |
||
283 | * @access public |
||
284 | * @return string |
||
285 | */ |
||
286 | public function getOperatingSystem() |
||
290 | } |
||
291 |