1 | <?php |
||
33 | class Messenger |
||
34 | { |
||
35 | /** |
||
36 | * Default message levels |
||
37 | */ |
||
38 | const LVL_SUCCESS = 'success'; |
||
39 | const LVL_INFO = 'info'; |
||
40 | const LVL_WARNING = 'warning'; |
||
41 | |||
42 | /** |
||
43 | * Session Segment |
||
44 | * |
||
45 | * @var Segment |
||
46 | * |
||
47 | * @access protected |
||
48 | */ |
||
49 | protected $segment; |
||
50 | |||
51 | /** |
||
52 | * Create a flash messenger |
||
53 | * |
||
54 | * @param Segment $segment session storage |
||
55 | * |
||
56 | * @access public |
||
57 | */ |
||
58 | 7 | public function __construct(Segment $segment) |
|
62 | |||
63 | /** |
||
64 | * Add a message |
||
65 | * |
||
66 | * @param string $message Message text |
||
67 | * @param string $level Message level |
||
68 | * |
||
69 | * @return $this |
||
70 | * |
||
71 | * @access public |
||
72 | */ |
||
73 | 5 | public function add($message, $level = self::LVL_INFO) |
|
86 | |||
87 | /** |
||
88 | * Get current messages |
||
89 | * |
||
90 | * @return array |
||
91 | * |
||
92 | * @access public |
||
93 | */ |
||
94 | 1 | public function getMessages() |
|
98 | |||
99 | /** |
||
100 | * Set a success message |
||
101 | * |
||
102 | * @param string $message Message text |
||
103 | * |
||
104 | * @return $this |
||
105 | * |
||
106 | * @access public |
||
107 | */ |
||
108 | 1 | public function success($message) |
|
112 | |||
113 | /** |
||
114 | * Set an info message |
||
115 | * |
||
116 | * @param string $message Message text |
||
117 | * |
||
118 | * @return $this |
||
119 | * |
||
120 | * @access public |
||
121 | */ |
||
122 | 1 | public function info($message) |
|
126 | |||
127 | /** |
||
128 | * Set a warning message |
||
129 | * |
||
130 | * @param string $message Message text |
||
131 | * |
||
132 | * @return $this |
||
133 | * |
||
134 | * @access public |
||
135 | */ |
||
136 | 1 | public function warning($message) |
|
140 | } |
||
141 |