@@ -80,8 +80,8 @@ |
||
| 80 | 80 | protected $error_message; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * @var array |
|
| 84 | - */ |
|
| 83 | + * @var array |
|
| 84 | + */ |
|
| 85 | 85 | protected $parameters = []; |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -24,13 +24,13 @@ |
||
| 24 | 24 | protected $description = 'Hackable PHP REST framework'; |
| 25 | 25 | protected $version = '4.0-dev'; |
| 26 | 26 | protected $ascii = "\r\n ___ _ __ __ \r\n". |
| 27 | - " / _ \(_)__ ___ ___ _/ /_____/ / ___ ____\r\n". |
|
| 28 | - " / // / (_-</ _ \/ _ `/ __/ __/ _ \/ -_) __/\r\n". |
|
| 29 | - "/____/_/___/ .__/\_,_/\__/\__/_//_/\__/_/ \r\n". |
|
| 30 | - " /_/ \r\n"; |
|
| 27 | + " / _ \(_)__ ___ ___ _/ /_____/ / ___ ____\r\n". |
|
| 28 | + " / // / (_-</ _ \/ _ `/ __/ __/ _ \/ -_) __/\r\n". |
|
| 29 | + "/____/_/___/ .__/\_,_/\__/\__/_//_/\__/_/ \r\n". |
|
| 30 | + " /_/ \r\n"; |
|
| 31 | 31 | protected $template = "\n\n{ascii}\r\n". |
| 32 | - "---------------------------------------------\r\n". |
|
| 33 | - "{name} (ver {version})\r\n{description}\r\n"; |
|
| 32 | + "---------------------------------------------\r\n". |
|
| 33 | + "{name} (ver {version})\r\n{description}\r\n"; |
|
| 34 | 34 | protected $prefix = 'dispatcher-'; |
| 35 | 35 | |
| 36 | 36 | } |
@@ -21,50 +21,50 @@ |
||
| 21 | 21 | * THE SOFTWARE. |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | - class Redirect { |
|
| 24 | + class Redirect { |
|
| 25 | 25 | |
| 26 | - public static function compose( |
|
| 27 | - Request $request, |
|
| 28 | - Response $response, |
|
| 29 | - Route $route |
|
| 30 | - ) { |
|
| 26 | + public static function compose( |
|
| 27 | + Request $request, |
|
| 28 | + Response $response, |
|
| 29 | + Route $route |
|
| 30 | + ) { |
|
| 31 | 31 | |
| 32 | - $status = $response->getStatus(); |
|
| 33 | - $content = $response->getContent(); |
|
| 34 | - $headers = $response->getHeaders(); |
|
| 32 | + $status = $response->getStatus(); |
|
| 33 | + $content = $response->getContent(); |
|
| 34 | + $headers = $response->getHeaders(); |
|
| 35 | 35 | |
| 36 | - $code = $route->getRedirectCode(); |
|
| 36 | + $code = $route->getRedirectCode(); |
|
| 37 | 37 | |
| 38 | - $location = $route->getRedirectLocation(); |
|
| 39 | - $uri = empty($location) ? (string) $request->getUri() : $location; |
|
| 38 | + $location = $route->getRedirectLocation(); |
|
| 39 | + $uri = empty($location) ? (string) $request->getUri() : $location; |
|
| 40 | 40 | |
| 41 | - $message = $route->getRedirectMessage(); |
|
| 41 | + $message = $route->getRedirectMessage(); |
|
| 42 | 42 | |
| 43 | - if ( $route->getRedirectType() == Route::REDIRECT_REFRESH ) { |
|
| 43 | + if ( $route->getRedirectType() == Route::REDIRECT_REFRESH ) { |
|
| 44 | 44 | |
| 45 | - $output = empty($message) ? |
|
| 45 | + $output = empty($message) ? |
|
| 46 | 46 | "Please follow <a href=\"$location\">this link</a>" |
| 47 | 47 | : $message; |
| 48 | 48 | |
| 49 | - $status->set(200); |
|
| 50 | - $headers->set("Refresh", "0;url=$location"); |
|
| 51 | - $content->set($output); |
|
| 49 | + $status->set(200); |
|
| 50 | + $headers->set("Refresh", "0;url=$location"); |
|
| 51 | + $content->set($output); |
|
| 52 | 52 | |
| 53 | - } else { |
|
| 53 | + } else { |
|
| 54 | 54 | |
| 55 | - if ( !empty($code) ) { |
|
| 56 | - $status->set($code); |
|
| 57 | - } else if ( $request->getVersion() === 'HTTP/1.1' ) { |
|
| 58 | - $status->set( (string) $request->getMethod() !== 'GET' ? 303 : 307); |
|
| 59 | - } else { |
|
| 60 | - $status->set(302); |
|
| 61 | - } |
|
| 55 | + if ( !empty($code) ) { |
|
| 56 | + $status->set($code); |
|
| 57 | + } else if ( $request->getVersion() === 'HTTP/1.1' ) { |
|
| 58 | + $status->set( (string) $request->getMethod() !== 'GET' ? 303 : 307); |
|
| 59 | + } else { |
|
| 60 | + $status->set(302); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $content->set($message); |
|
| 64 | - $response->getLocation()->set($uri); |
|
| 63 | + $content->set($message); |
|
| 64 | + $response->getLocation()->set($uri); |
|
| 65 | 65 | |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - } |
|
| 70 | + } |
|
@@ -20,20 +20,20 @@ |
||
| 20 | 20 | * THE SOFTWARE. |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | - class Error { |
|
| 23 | + class Error { |
|
| 24 | 24 | |
| 25 | - public static function compose( |
|
| 26 | - Route $route |
|
| 27 | - ) { |
|
| 25 | + public static function compose( |
|
| 26 | + Route $route |
|
| 27 | + ) { |
|
| 28 | 28 | |
| 29 | - $code = $route->getErrorCode(); |
|
| 30 | - $message = $route->getErrorMessage(); |
|
| 29 | + $code = $route->getErrorCode(); |
|
| 30 | + $message = $route->getErrorMessage(); |
|
| 31 | 31 | |
| 32 | - $code = empty($code) ? 500 : $code; |
|
| 33 | - $message = empty($message) ? 'Internal error' : $message; |
|
| 32 | + $code = empty($code) ? 500 : $code; |
|
| 33 | + $message = empty($message) ? 'Internal error' : $message; |
|
| 34 | 34 | |
| 35 | - throw new DispatcherException($message, 0, null, $code); |
|
| 35 | + throw new DispatcherException($message, 0, null, $code); |
|
| 36 | 36 | |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|