summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-30 19:57:01 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-30 19:57:01 +0200
commit2bd127c011846aad69731d1d63535a3d4f100af0 (patch)
treec05736a9ab1daa00047a3092887f972f701609e4 /src
parent96f1d9fd541d0c5ef78151f8c69a89c41684b67a (diff)
Use symfony session
Diffstat (limited to 'src')
-rw-r--r--src/helpers.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/helpers.php b/src/helpers.php
index af0e802b..24f93f2c 100644
--- a/src/helpers.php
+++ b/src/helpers.php
@@ -5,6 +5,7 @@ use Engelsystem\Config\Config;
use Engelsystem\Http\Request;
use Engelsystem\Renderer\Renderer;
use Engelsystem\Routing\UrlGenerator;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* Get or set config values
@@ -43,6 +44,22 @@ function request($key = null, $default = null)
}
/**
+ * @param string $key
+ * @param mixed $default
+ * @return SessionInterface|mixed
+ */
+function session($key = null, $default = null)
+{
+ $session = request()->getSession();
+
+ if (is_null($key)) {
+ return $session;
+ }
+
+ return $session->get($key, $default);
+}
+
+/**
* @param string $template
* @param mixed[] $data
* @return Renderer|string