|
1 | 1 | <?php |
2 | 2 |
|
3 | | -if (!function_exists('session') && class_exists('Leaf\App')) { |
| 3 | +if (!function_exists('session') && class_exists('Leaf\Config')) { |
4 | 4 | /** |
5 | | - * Return session data/object or set session data |
| 5 | + * Return session object |
6 | 6 | * |
7 | | - * @param string|null $key — The session data to set/get |
8 | | - * @param mixed $key — The data to set |
| 7 | + * @return \Leaf\Http\Session |
9 | 8 | */ |
10 | | - function session($key = null, $value = null) |
| 9 | + function session() |
11 | 10 | { |
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()); |
26 | 13 | } |
27 | 14 |
|
28 | | - return \Leaf\Http\Session::set($key, $value); |
| 15 | + return \Leaf\Config::get('session.instance'); |
29 | 16 | } |
30 | 17 | } |
31 | 18 |
|
32 | | -if (!function_exists('flash') && class_exists('Leaf\App')) { |
| 19 | +if (!function_exists('flash') && class_exists('Leaf\Config')) { |
33 | 20 | /** |
34 | 21 | * Return flash data/object or set flash data |
35 | 22 | * |
36 | | - * @param string|null $key — The flash data to set/get |
37 | | - * @param mixed $key — The data to set |
| 23 | + * @return \Leaf\Flash |
38 | 24 | */ |
39 | | - function flash($key = null, $value = null) |
| 25 | + function flash() |
40 | 26 | { |
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()); |
51 | 29 | } |
52 | 30 |
|
53 | | - return \Leaf\Flash::set($key, $value); |
| 31 | + return \Leaf\Config::get('flash.instance'); |
54 | 32 | } |
55 | 33 | } |
0 commit comments