mirror of
https://github.com/getgrav/grav.git
synced 2026-03-02 18:41:34 +01:00
Properly handle termination in twig redirect and if theme does not exist
This commit is contained in:
@@ -13,6 +13,7 @@ use Grav\Common\Config\Config;
|
||||
use Grav\Common\File\CompiledYamlFile;
|
||||
use Grav\Common\Data\Blueprints;
|
||||
use Grav\Common\Data\Data;
|
||||
use Grav\Framework\Psr7\Response;
|
||||
use RocketTheme\Toolbox\Event\EventDispatcher;
|
||||
use RocketTheme\Toolbox\Event\EventSubscriberInterface;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
@@ -214,7 +215,9 @@ class Themes extends Iterator
|
||||
}
|
||||
}
|
||||
} elseif (!$locator('theme://') && !defined('GRAV_CLI')) {
|
||||
exit("Theme '$name' does not exist, unable to display page.");
|
||||
$response = new Response(500, [], "Theme '$name' does not exist, unable to display page.");
|
||||
|
||||
$grav->exit($response);
|
||||
}
|
||||
|
||||
$this->config->set('theme', $config->get('themes.' . $name));
|
||||
|
||||
@@ -29,6 +29,7 @@ use Grav\Common\User\Interfaces\UserInterface;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Common\Yaml;
|
||||
use Grav\Common\Helpers\Base32;
|
||||
use Grav\Framework\Psr7\Response;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
@@ -1110,8 +1111,9 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
|
||||
*/
|
||||
public function redirectFunc($url, $statusCode = 303)
|
||||
{
|
||||
header('Location: ' . $url, true, $statusCode);
|
||||
exit();
|
||||
$response = new Response($statusCode, ['location' => $url]);
|
||||
|
||||
$this->grav->exit($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user