Skip to content

Commit 7d536b3

Browse files
committed
fix: update functional mode
1 parent a40a8f3 commit 7d536b3

File tree

1 file changed

+13
-35
lines changed

1 file changed

+13
-35
lines changed

src/functions.php

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,33 @@
11
<?php
22

3-
if (!function_exists('session') && class_exists('Leaf\App')) {
3+
if (!function_exists('session') && class_exists('Leaf\Config')) {
44
/**
5-
* Return session data/object or set session data
5+
* Return session object
66
*
7-
* @param string|null $key — The session data to set/get
8-
* @param mixed $key — The data to set
7+
* @return \Leaf\Http\Session
98
*/
10-
function session($key = null, $value = null)
9+
function session()
1110
{
12-
if (!$key && !$value) {
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");
18-
}
19-
20-
if (!$value && ($key && is_string($key))) {
21-
return \Leaf\Http\Session::get($key);
22-
}
23-
24-
if (!$value && ($key && is_array($key))) {
25-
return \Leaf\Http\Session::set($key);
11+
if (!(\Leaf\Config::get('session.instance'))) {
12+
\Leaf\Config::set('session.instance', new \Leaf\Http\Session());
2613
}
2714

28-
return \Leaf\Http\Session::set($key, $value);
15+
return \Leaf\Config::get('session.instance');
2916
}
3017
}
3118

32-
if (!function_exists('flash') && class_exists('Leaf\App')) {
19+
if (!function_exists('flash') && class_exists('Leaf\Config')) {
3320
/**
3421
* Return flash data/object or set flash data
3522
*
36-
* @param string|null $key — The flash data to set/get
37-
* @param mixed $key — The data to set
23+
* @return \Leaf\Flash
3824
*/
39-
function flash($key = null, $value = null)
25+
function flash()
4026
{
41-
if (!$key && !$value) {
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");
47-
}
48-
49-
if (!$value && is_string($key)) {
50-
return \Leaf\Flash::display($key);
27+
if (!(\Leaf\Config::get('flash.instance'))) {
28+
\Leaf\Config::set('flash.instance', new \Leaf\Flash());
5129
}
5230

53-
return \Leaf\Flash::set($key, $value);
31+
return \Leaf\Config::get('flash.instance');
5432
}
5533
}

0 commit comments

Comments
 (0)