|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\notices; |
|
4
|
|
|
|
|
5
|
|
|
use DomainException; |
|
6
|
|
|
|
|
7
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ConvertNoticesToAdminNotices |
|
13
|
|
|
* Converts notifications in a NoticesContainer into AdminNotice notifications |
|
14
|
|
|
* |
|
15
|
|
|
* @package EventEspresso\core\services\notices |
|
16
|
|
|
* @author Brent Christensen |
|
17
|
|
|
* @since $VID:$ |
|
18
|
|
|
*/ |
|
19
|
|
|
class ConvertNoticesToAdminNotices extends NoticeConverter |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Converts Notice objects into AdminNotice notifications |
|
24
|
|
|
* |
|
25
|
|
|
* @param NoticesContainerInterface $notices |
|
26
|
|
|
* @throws DomainException |
|
27
|
|
|
*/ |
|
28
|
|
|
public function process(NoticesContainerInterface $notices) |
|
29
|
|
|
{ |
|
30
|
|
|
if ($notices->hasAttention()) { |
|
31
|
|
|
foreach ($notices->getAttention() as $notice) { |
|
32
|
|
|
new AdminNotice($notice); |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
if ($notices->hasError()) { |
|
36
|
|
|
$error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
37
|
|
|
foreach ($notices->getError() as $notice) { |
|
38
|
|
|
if ($this->getThrowExceptions()) { |
|
39
|
|
|
$error_string .= '<br />' . $notice->message(); |
|
40
|
|
|
} else { |
|
41
|
|
|
new AdminNotice($notice); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
if ($this->getThrowExceptions()) { |
|
45
|
|
|
throw new DomainException($error_string); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
if ($notices->hasSuccess()) { |
|
49
|
|
|
foreach ($notices->getSuccess() as $notice) { |
|
50
|
|
|
new AdminNotice($notice); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
if ($notices->hasInformation()) { |
|
54
|
|
|
foreach ($notices->getInformation() as $notice) { |
|
55
|
|
|
new AdminNotice($notice); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
$this->clearNotices(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
// Location: ConvertNoticesToAdminNotices.php |
|
63
|
|
|
|