diff options
Diffstat (limited to 'src/helpers.php')
-rw-r--r-- | src/helpers.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/helpers.php b/src/helpers.php index 339936e3..50c5c837 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -4,6 +4,7 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Http\Request; +use Engelsystem\Http\Response; use Engelsystem\Renderer\Renderer; use Engelsystem\Routing\UrlGeneratorInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; @@ -12,7 +13,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; * Get the global app instance * * @param string $id - * @return mixed + * @return mixed|Application */ function app($instance_id = null) { @@ -81,6 +82,27 @@ function request($key = null, $default = null) } /** + * @param string $content + * @param int $status + * @param array $headers + * @return Response + */ +function response($content = '', $status = 200, $headers = []) +{ + /** @var Response $response */ + $response = app('psr7.response'); + $response = $response + ->withContent($content) + ->withStatus($status); + + foreach ($headers as $key => $value) { + $response = $response->withAddedHeader($key, $value); + } + + return $response; +} + +/** * @param string $key * @param mixed $default * @return SessionInterface|mixed |