1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\notices; |
4
|
|
|
|
5
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class NoticesContainer |
11
|
|
|
* Container for holding multiple Notice objects until they can be processed |
12
|
|
|
* |
13
|
|
|
* @package Event Espresso |
14
|
|
|
* @author Brent Christensen |
15
|
|
|
* @since $VID:$ |
16
|
|
|
*/ |
17
|
|
|
class NoticesContainer implements NoticesContainerInterface |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var NoticeInterface[] $attention |
23
|
|
|
*/ |
24
|
|
|
private $attention = array(); |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var NoticeInterface[] $error |
29
|
|
|
*/ |
30
|
|
|
private $error = array(); |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var NoticeInterface[] $success |
35
|
|
|
*/ |
36
|
|
|
private $success = array(); |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $notice |
42
|
|
|
* @param string $file |
43
|
|
|
* @param string $func |
44
|
|
|
* @param string $line |
45
|
|
|
*/ |
46
|
|
|
public function addAttention($notice, $file = '', $func = '', $line = '') |
47
|
|
|
{ |
48
|
|
|
$this->attention[] = new Notice(Notice::ATTENTION, $notice, $file, $func, $line); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $notice |
55
|
|
|
* @param string $file |
56
|
|
|
* @param string $func |
57
|
|
|
* @param string $line |
58
|
|
|
*/ |
59
|
|
|
public function addError($notice, $file, $func, $line) |
60
|
|
|
{ |
61
|
|
|
$this->error[] = new Notice(Notice::ERROR, $notice, $file, $func, $line); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param string $notice |
68
|
|
|
* @param string $file |
69
|
|
|
* @param string $func |
70
|
|
|
* @param string $line |
71
|
|
|
*/ |
72
|
|
|
public function addSuccess($notice, $file = '', $func = '', $line = '') |
73
|
|
|
{ |
74
|
|
|
$this->success[] = new Notice(Notice::SUCCESS, $notice, $file, $func, $line); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return boolean |
81
|
|
|
*/ |
82
|
|
|
public function hasAttention() |
83
|
|
|
{ |
84
|
|
|
return ! empty($this->attention); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return boolean |
91
|
|
|
*/ |
92
|
|
|
public function hasError() |
93
|
|
|
{ |
94
|
|
|
return ! empty($this->error); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return boolean |
101
|
|
|
*/ |
102
|
|
|
public function hasSuccess() |
103
|
|
|
{ |
104
|
|
|
return ! empty($this->success); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return int |
111
|
|
|
*/ |
112
|
|
|
public function countAttention() |
113
|
|
|
{ |
114
|
|
|
return count($this->attention); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return int |
121
|
|
|
*/ |
122
|
|
|
public function countError() |
123
|
|
|
{ |
124
|
|
|
return count($this->error); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return int |
131
|
|
|
*/ |
132
|
|
|
public function countSuccess() |
133
|
|
|
{ |
134
|
|
|
return count($this->success); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return NoticeInterface[] |
141
|
|
|
*/ |
142
|
|
|
public function getAttention() |
143
|
|
|
{ |
144
|
|
|
return $this->attention; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return NoticeInterface[] |
151
|
|
|
*/ |
152
|
|
|
public function getError() |
153
|
|
|
{ |
154
|
|
|
return $this->error; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return NoticeInterface[] |
161
|
|
|
*/ |
162
|
|
|
public function getSuccess() |
163
|
|
|
{ |
164
|
|
|
return $this->success; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
|
168
|
|
|
} |
169
|
|
|
|