diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers.php | 17 |
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 |