summaryrefslogtreecommitdiff
path: root/src/helpers.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-03 22:43:19 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-03 22:55:54 +0200
commit36dafdb68acbde2fe42ce36ef50f497c8c06411f (patch)
tree1e420597ae72c979361bf29b66ae7e27c73cf431 /src/helpers.php
parent9f1ee0c6c6497d43fb275491ec53fda420f64b81 (diff)
parentb0e7bc0df2eb4975223582089c7a928903e8cd14 (diff)
Merge remote-tracking branch 'MyIgel/rebuild-psr7'
Diffstat (limited to 'src/helpers.php')
-rw-r--r--src/helpers.php24
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