Added $grav->close() method to properly terminate the request with a response

This commit is contained in:
Matias Griese
2019-08-12 17:11:39 +03:00
parent 7718dd7e98
commit f1909d80db
4 changed files with 14 additions and 5 deletions

View File

@@ -8,6 +8,7 @@
* Deprecated `FlexDirectory::update()` and `FlexDirectory::remove()`
* Added `FlexStorage::getMetaData()` to get updated object meta information for listed keys
* Added `Language::getPageExtensions()` to get full list of supported page language extensions
* Added `$grav->close()` method to properly terminate the request with a response
1. [](#improved)
* Better support for Symfony local server `symfony server:start`
* Make `Route` objects immutable
@@ -59,7 +60,6 @@
* Added Twig profiling for Clockwork debugger
* Updated Symfony Components to 4.3
* Added support for Twig 2.11 (compatible with Twig 1.40+)
* Added `$grav->exit()` method to properly terminate the request with a response
* Optimization: Initialize debugbar only after the configuration has been loaded
* Optimization: Combine some early Grav processors into a single one

View File

@@ -242,7 +242,7 @@ class Grav extends Container
*
* @param ResponseInterface $response
*/
public function exit(ResponseInterface $response): void
public function close(ResponseInterface $response): void
{
// Make sure nothing extra gets written to the response.
while (ob_get_level()) {
@@ -267,6 +267,15 @@ class Grav extends Container
exit();
}
/**
* @param ResponseInterface $response
* @deprecated 1.7 Do not use
*/
public function exit(ResponseInterface $response): void
{
$this->close($response);
}
/**
* Terminates Grav request and redirects browser to another location.
*
@@ -306,7 +315,7 @@ class Grav extends Container
$response = new Response($code, ['Location' => $url]);
$this->exit($response);
$this->close($response);
}
/**

View File

@@ -217,7 +217,7 @@ class Themes extends Iterator
} elseif (!$locator('theme://') && !defined('GRAV_CLI')) {
$response = new Response(500, [], "Theme '$name' does not exist, unable to display page.");
$grav->exit($response);
$grav->close($response);
}
$this->config->set('theme', $config->get('themes.' . $name));

View File

@@ -1115,7 +1115,7 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
{
$response = new Response($statusCode, ['location' => $url]);
$this->grav->exit($response);
$this->grav->close($response);
}
/**