Inherit ApiResponse from Response

This commit is contained in:
Philipp
2021-11-21 21:52:36 +01:00
parent 561aba18e3
commit 537b74f307
46 changed files with 326 additions and 277 deletions

View File

@@ -371,6 +371,24 @@ class Page implements ArrayAccess
$this->footerScripts[] = trim($url, '/');
}
/**
* Directly exit with the current response (include setting all headers)
*
* @param IRespondToRequests $response
*/
public function exit(IRespondToRequests $response)
{
foreach ($response->getHeaders() as $key => $header) {
if (empty($key)) {
header($header);
} else {
header("$key: $header");
}
}
echo $response->getContent();
}
/**
* Executes the creation of the current page and prints it to the screen
*
@@ -434,13 +452,11 @@ class Page implements ArrayAccess
$this->page['nav'] = Nav::build($app);
}
foreach ($response->getHeaders() as $key => $values) {
if (is_array($values)) {
foreach ($values as $value) {
header($key, $value);
}
foreach ($response->getHeaders() as $key => $header) {
if (empty($key)) {
header($header);
} else {
header($key, $values);
header("$key: $header");
}
}