summaryrefslogtreecommitdiff
path: root/includes/helper
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 /includes/helper
parent96f1d9fd541d0c5ef78151f8c69a89c41684b67a (diff)
Use symfony session
Diffstat (limited to 'includes/helper')
-rw-r--r--includes/helper/internationalization_helper.php11
-rw-r--r--includes/helper/message_helper.php21
2 files changed, 17 insertions, 15 deletions
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
index 83faabb0..131941e9 100644
--- a/includes/helper/internationalization_helper.php
+++ b/includes/helper/internationalization_helper.php
@@ -9,7 +9,7 @@ use Engelsystem\Http\Request;
*/
function locale()
{
- return $_SESSION['locale'];
+ return session()->get('locale');
}
/**
@@ -29,11 +29,12 @@ function gettext_init()
{
$locales = config('locales');
$request = request();
+ $session = session();
if ($request->has('set_locale') && isset($locales[$request->input('set_locale')])) {
- $_SESSION['locale'] = $request->input('set_locale');
- } elseif (!isset($_SESSION['locale'])) {
- $_SESSION['locale'] = config('default_locale');
+ $session->set('locale', $request->input('set_locale'));
+ } elseif (!$session->has('locale')) {
+ $session->set('locale', config('default_locale'));
}
gettext_locale();
@@ -50,7 +51,7 @@ function gettext_init()
function gettext_locale($locale = null)
{
if ($locale == null) {
- $locale = $_SESSION['locale'];
+ $locale = session()->get('locale');
}
putenv('LC_ALL=' . $locale);
diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php
index 1f429c27..7a42a7b7 100644
--- a/includes/helper/message_helper.php
+++ b/includes/helper/message_helper.php
@@ -7,12 +7,12 @@
*/
function msg()
{
- if (!isset($_SESSION['msg'])) {
- return '';
- }
- $msg = $_SESSION['msg'];
- $_SESSION['msg'] = '';
- return $msg;
+ $session = session();
+
+ $message = $session->get('msg', '');
+ $session->set('msg', '');
+
+ return $message;
}
/**
@@ -61,6 +61,8 @@ function success($msg, $immediately = false)
*/
function alert($class, $msg, $immediately = false)
{
+ $session = session();
+
if ($immediately) {
if ($msg == '') {
return '';
@@ -68,10 +70,9 @@ function alert($class, $msg, $immediately = false)
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
}
- if (!isset($_SESSION['msg'])) {
- $_SESSION['msg'] = '';
- }
- $_SESSION['msg'] .= alert($class, $msg, true);
+ $message = $session->get('msg', '');
+ $message .= alert($class, $msg, true);
+ $session->set('msg', $message);
return null;
}