Skip to content

Commit

Permalink
🎨 update functional mode conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Jan 22, 2022
1 parent 9bd19ad commit e6e420f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!function_exists('session')) {
if (!function_exists('session') && class_exists('Leaf\App')) {
/**
* Return session data/object or set session data
*
Expand All @@ -10,7 +10,11 @@
function session($key = null, $value = null)
{
if (!$key && !$value) {
return new \Leaf\Http\Session();
if (!(\Leaf\Config::get("session.instance"))) {
\Leaf\Config::set("session.instance", new \Leaf\Http\Session());
}

return \Leaf\Config::get("session.instance");
}

if (!$value && ($key && is_string($key))) {
Expand All @@ -25,7 +29,7 @@ function session($key = null, $value = null)
}
}

if (!function_exists('flash')) {
if (!function_exists('flash') && class_exists('Leaf\App')) {
/**
* Return flash data/object or set flash data
*
Expand All @@ -35,7 +39,11 @@ function session($key = null, $value = null)
function flash($key = null, $value = null)
{
if (!$key && !$value) {
return new \Leaf\Flash();
if (!(\Leaf\Config::get("flash.instance"))) {
\Leaf\Config::set("flash.instance", new \Leaf\Flash());
}

return \Leaf\Config::get("flash.instance");
}

if (!$value && is_string($key)) {
Expand Down

0 comments on commit e6e420f

Please sign in to comment.