Add the Emitter class for the Response object...because it's separate now
This commit is contained in:
parent
723c7dadef
commit
2f8c05ac67
@ -24,7 +24,8 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"psr/http-message": "~1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"zendframework/zend-diactoros": "^2.0.0"
|
"zendframework/zend-diactoros": "^2.0.0",
|
||||||
|
"zendframework/zend-httphandlerrunner": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"aura/session": "^2.1.0",
|
"aura/session": "^2.1.0",
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
namespace Aviat\Ion\View;
|
namespace Aviat\Ion\View;
|
||||||
|
|
||||||
use Zend\Diactoros\Response\SapiEmitter;
|
use Zend\Diactoros\Response;
|
||||||
|
use Zend\HttpHandlerRunner\Emitter\SapiEmitter;
|
||||||
|
|
||||||
use Aviat\Ion\Exception\DoubleRenderException;
|
use Aviat\Ion\Exception\DoubleRenderException;
|
||||||
use Aviat\Ion\View as BaseView;
|
use Aviat\Ion\View as BaseView;
|
||||||
@ -38,24 +39,13 @@ class HttpView extends BaseView {
|
|||||||
*
|
*
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param int $code
|
* @param int $code
|
||||||
|
* @param array $headers
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function redirect(string $url, int $code): void
|
public function redirect(string $url, int $code = 302, array $headers = []): void
|
||||||
{
|
{
|
||||||
ob_start();
|
$this->response = new Response\RedirectResponse($url, $code, $headers);
|
||||||
$this->setStatusCode($code);
|
|
||||||
$message = $this->response->getReasonPhrase();
|
|
||||||
$this->response = $this->response->withHeader('Location', $url);
|
|
||||||
|
|
||||||
if (PHP_SAPI !== 'cli')
|
|
||||||
{
|
|
||||||
header("HTTP/1.1 ${code} ${message}");
|
|
||||||
header("Location: {$url}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->hasRendered = TRUE;
|
|
||||||
ob_end_clean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user