1 | <?php |
||
15 | abstract class AbstractRequestHandler extends AbstractHandler |
||
16 | { |
||
17 | /** |
||
18 | * Returns true if the handler determines it should handle this request and false otherwise. |
||
19 | * @param string $path The URL path for the request. |
||
20 | * @param array $query The query parameters. |
||
21 | * @param array $post The post data. |
||
22 | * @param string $verb The HTTP verb used in the request. |
||
23 | * @return boolean Returns true if this handler will handle the request and false otherwise. |
||
24 | */ |
||
25 | abstract public function isAppropriate($path, $query, $post, $verb); |
||
26 | |||
27 | /** |
||
28 | * Returns a request object extracted from the request details (path, query, etc). The method |
||
29 | * isAppropriate() must have returned true, otherwise this method should return null. |
||
30 | * @return \Vectorface\SnappyRouter\Request\HttpRequest|null Returns a |
||
31 | * Request object or null if this handler is not appropriate. |
||
32 | */ |
||
33 | abstract public function getRequest(); |
||
34 | |||
35 | /** |
||
36 | * Provides the handler with an opportunity to perform any last minute |
||
37 | * error handling logic. The returned value will be serialized by the |
||
38 | * handler's encoder. |
||
39 | * @param Exception $e The exception that was thrown. |
||
40 | * @return mixed Returns a serializable value that will be encoded and returned |
||
41 | * to the client. |
||
42 | */ |
||
43 | 1 | public function handleException(Exception $e) |
|
52 | |||
53 | /** |
||
54 | * Returns whether a handler should function in a CLI environment. |
||
55 | * @return bool Returns true if the handler should function in a CLI |
||
56 | * environment and false otherwise. |
||
57 | */ |
||
58 | 6 | public function isCliHandler() |
|
62 | } |
||
63 |