@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | $function_output = app_content($request, $args); |
| 49 | 49 | if (!is_array( $function_output) ) { |
| 50 | 50 | $function_output = ["status" => 500, "error" => "Internal Server Error"]; |
| 51 | - } |
|
| 52 | - else { |
|
| 51 | + } else { |
|
| 53 | 52 | if (!isset($function_output['status'])) { |
| 54 | 53 | $function_output['status']=200; |
| 55 | 54 | } |
@@ -57,8 +56,7 @@ discard block |
||
| 57 | 56 | } |
| 58 | 57 | $response->getBody()->write(json_encode($function_output)); |
| 59 | 58 | $newResponse = $response->withHeader('Content-Type', 'application/json;charset=utf-8')->withHeader('X-Powered-By', "reformo/rslim")->withStatus($status); |
| 60 | - } |
|
| 61 | - else { |
|
| 59 | + } else { |
|
| 62 | 60 | if (!file_exists($this->config['base_dir'].$template)) { |
| 63 | 61 | throw new \Exception("<strong>Template file not found!</strong> " . $route . '/' . $action . " needs a template file at:" . $template ); |
| 64 | 62 | } |
@@ -88,15 +86,13 @@ discard block |
||
| 88 | 86 | if (!file_exists($this->config['base_dir'] . $widget_template)) { |
| 89 | 87 | if (is_string($widget_content)) { |
| 90 | 88 | return $widget_content; |
| 91 | - } |
|
| 92 | - else { |
|
| 89 | + } else { |
|
| 93 | 90 | throw new \Exception("<strong>Widget should return string:</strong> " . $widget_name . '/' . $widget_action . "!"); |
| 94 | 91 | } |
| 95 | 92 | } else { |
| 96 | 93 | return $this->twig->render($widget_template, $widget_content); |
| 97 | 94 | } |
| 98 | - } |
|
| 99 | - else { |
|
| 95 | + } else { |
|
| 100 | 96 | throw new \Exception("<strong>Widget function not found!</strong> " . $widget_name . '/' . $widget_action . "!"); |
| 101 | 97 | } |
| 102 | 98 | }, |
@@ -119,8 +115,7 @@ discard block |
||
| 119 | 115 | $newResponse->write($app_content); |
| 120 | 116 | } |
| 121 | 117 | return $newResponse; |
| 122 | - } |
|
| 123 | - else { |
|
| 118 | + } else { |
|
| 124 | 119 | return $this->not_found($request, $response, $return_type, 'Controller '. $route . '/' . $action." not found"); |
| 125 | 120 | } |
| 126 | 121 | } |
@@ -131,8 +126,7 @@ discard block |
||
| 131 | 126 | if ($return_type == 'json') { |
| 132 | 127 | $response->getBody()->write( json_encode(['status'=>404, 'message'=>$message])); |
| 133 | 128 | return $response->withHeader('Content-Type', 'application/json;charset=utf-8')->withHeader('X-Powered-By', "reformo/rslim")->withStatus(404); |
| 134 | - } |
|
| 135 | - else { |
|
| 129 | + } else { |
|
| 136 | 130 | return $response->withStatus(404) |
| 137 | 131 | ->withHeader('Content-Type', 'text/html')->withHeader('X-Powered-By', "reformo/rslim") |
| 138 | 132 | ->write($this->twig->render($not_found_template, ['message'=>$message])); |