diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-11 15:05:55 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-14 00:17:19 +0200 |
commit | f3f05f6cc4bef3338dbfb6eb340da4fb1c5ba1e1 (patch) | |
tree | 88f9767bfb40a68776d4f458ac60c6edfd02e286 /src/helpers.php | |
parent | 20c03a155d2017101a098cefa602116a4a331d71 (diff) |
Make Engelsystem\Http\Response PSR-7 compatible
Diffstat (limited to 'src/helpers.php')
-rw-r--r-- | src/helpers.php | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/helpers.php b/src/helpers.php index 2a90dcde..01fb10bd 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -4,11 +4,10 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Http\Request; +use Engelsystem\Http\Response; use Engelsystem\Renderer\Renderer; use Engelsystem\Routing\UrlGenerator; -use Psr\Http\Message\ResponseInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Zend\Diactoros\Stream; /** * Get the global app instance @@ -86,21 +85,16 @@ function request($key = null, $default = null) * @param string $content * @param int $status * @param array $headers - * @return ResponseInterface + * @return Response */ function response($content = '', $status = 200, $headers = []) { - /** @var ResponseInterface $response */ + /** @var Response $response */ $response = app('psr7.response'); - - /** @var Stream $stream */ - $stream = app()->make(Stream::class, ['stream' => 'php://memory', 'mode' => 'wb+']); - $stream->write($content); - $stream->rewind(); - $response = $response - ->withBody($stream) + ->withContent($content) ->withStatus($status); + foreach ($headers as $key => $value) { $response = $response->withAddedHeader($key, $value); } |