1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Nip\Container\Container; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @param $name |
7
|
|
|
* @return mixed|null |
8
|
|
|
*/ |
9
|
|
|
function flash_get($name) |
10
|
|
|
{ |
11
|
1 |
|
return flashData()->get($name); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @param $name |
16
|
|
|
* @param $value |
17
|
|
|
*/ |
18
|
|
|
function flash_add($name, $value) |
19
|
|
|
{ |
20
|
|
|
flashData()->add($name, $value); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return \Nip\FlashData\FlashData |
25
|
|
|
*/ |
26
|
|
|
function flashData() |
27
|
|
|
{ |
28
|
1 |
|
if (function_exists('app')) { |
29
|
1 |
|
$container = app(); |
30
|
|
|
} else { |
31
|
|
|
$container = Container::getInstance(); |
32
|
|
|
} |
33
|
1 |
|
if ($container->has('flash.data') === false) { |
34
|
|
|
throw new Exception("Flash Provider not registered"); |
35
|
|
|
} |
36
|
1 |
|
return $container->get('flash.data'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $name |
41
|
|
|
* @param $message |
42
|
|
|
*/ |
43
|
|
|
function flash_success($name, $message) |
44
|
|
|
{ |
45
|
|
|
flashMessages()->add($name, 'success', $message); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param $name |
50
|
|
|
* @param $message |
51
|
|
|
*/ |
52
|
|
|
function flash_error($name, $message) |
53
|
|
|
{ |
54
|
|
|
flashMessages()->add($name, 'error', $message); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param $name |
59
|
|
|
* @param $message |
60
|
|
|
*/ |
61
|
|
|
function flash_info($name, $message) |
62
|
|
|
{ |
63
|
|
|
flashMessages()->add($name, 'info', $message); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return \Nip\FlashData\FlashMessages |
68
|
|
|
*/ |
69
|
|
|
function flashMessages() |
70
|
|
|
{ |
71
|
|
|
if (function_exists('app')) { |
72
|
|
|
$container = app(); |
73
|
|
|
} else { |
74
|
|
|
$container = Container::getInstance(); |
75
|
|
|
} |
76
|
|
|
if ($container->has('flash.data') === false) { |
77
|
|
|
throw new Exception("Flash Provider not registered"); |
78
|
|
|
} |
79
|
|
|
return $container->get('flash.messages'); |
80
|
|
|
} |
81
|
|
|
|