Skip to content

Commit e6e420f

Browse files
committed
🎨 update functional mode conditions
1 parent 9bd19ad commit e6e420f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/functions.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (!function_exists('session')) {
3+
if (!function_exists('session') && class_exists('Leaf\App')) {
44
/**
55
* Return session data/object or set session data
66
*
@@ -10,7 +10,11 @@
1010
function session($key = null, $value = null)
1111
{
1212
if (!$key && !$value) {
13-
return new \Leaf\Http\Session();
13+
if (!(\Leaf\Config::get("session.instance"))) {
14+
\Leaf\Config::set("session.instance", new \Leaf\Http\Session());
15+
}
16+
17+
return \Leaf\Config::get("session.instance");
1418
}
1519

1620
if (!$value && ($key && is_string($key))) {
@@ -25,7 +29,7 @@ function session($key = null, $value = null)
2529
}
2630
}
2731

28-
if (!function_exists('flash')) {
32+
if (!function_exists('flash') && class_exists('Leaf\App')) {
2933
/**
3034
* Return flash data/object or set flash data
3135
*
@@ -35,7 +39,11 @@ function session($key = null, $value = null)
3539
function flash($key = null, $value = null)
3640
{
3741
if (!$key && !$value) {
38-
return new \Leaf\Flash();
42+
if (!(\Leaf\Config::get("flash.instance"))) {
43+
\Leaf\Config::set("flash.instance", new \Leaf\Flash());
44+
}
45+
46+
return \Leaf\Config::get("flash.instance");
3947
}
4048

4149
if (!$value && is_string($key)) {

0 commit comments

Comments
 (0)