Add the Emitter class for the Response object...because it's separate now

This commit is contained in:
Timothy Warren 2018-10-05 13:03:33 -04:00
parent 723c7dadef
commit 2f8c05ac67
2 changed files with 7 additions and 16 deletions

View File

@ -24,7 +24,8 @@
"ext-json": "*",
"psr/http-message": "~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": {
"aura/session": "^2.1.0",

View File

@ -16,7 +16,8 @@
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\View as BaseView;
@ -38,24 +39,13 @@ class HttpView extends BaseView {
*
* @param string $url
* @param int $code
* @param array $headers
* @throws \InvalidArgumentException
* @return void
*/
public function redirect(string $url, int $code): void
public function redirect(string $url, int $code = 302, array $headers = []): void
{
ob_start();
$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();
$this->response = new Response\RedirectResponse($url, $code, $headers);
}
/**