|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\commands\notices; |
|
4
|
|
|
|
|
5
|
|
|
use EE_Error; |
|
6
|
|
|
|
|
7
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ConvertNoticesToEeErrors |
|
13
|
|
|
* Converts notifications in a CommandHandlerNotices into EE_Error notifications |
|
14
|
|
|
* |
|
15
|
|
|
* @package Event Espresso |
|
16
|
|
|
* @author Brent Christensen |
|
17
|
|
|
* @since $VID:$ |
|
18
|
|
|
*/ |
|
19
|
|
|
class ConvertNoticesToEeErrors extends ConvertNotices |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Converts CommandHandlerNotice objects into EE_Error notifications |
|
26
|
|
|
* |
|
27
|
|
|
* @throws EE_Error |
|
28
|
|
|
*/ |
|
29
|
|
|
public function process() |
|
30
|
|
|
{ |
|
31
|
|
|
// \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
32
|
|
|
if ($this->getNotices()->hasAttention()) { |
|
33
|
|
|
foreach ($this->getNotices()->getAttention() as $notice) { |
|
34
|
|
|
// \EEH_Debug_Tools::printr($notice->message(), $notice->type(), __FILE__, __LINE__); |
|
35
|
|
|
EE_Error::add_attention( |
|
36
|
|
|
$notice->message(), |
|
37
|
|
|
$notice->file(), |
|
38
|
|
|
$notice->func(), |
|
39
|
|
|
$notice->line() |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
if ($this->getNotices()->hasError()) { |
|
44
|
|
|
$error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
45
|
|
|
foreach ($this->getNotices()->getError() as $notice) { |
|
46
|
|
|
// \EEH_Debug_Tools::printr($notice->message(), $notice->type(), __FILE__, __LINE__); |
|
47
|
|
|
if ($this->getThrowExceptions()) { |
|
48
|
|
|
$error_string .= '<br />' . $notice->message(); |
|
49
|
|
|
} else { |
|
50
|
|
|
EE_Error::add_error( |
|
51
|
|
|
$notice->message(), |
|
52
|
|
|
$notice->file(), |
|
53
|
|
|
$notice->func(), |
|
54
|
|
|
$notice->line() |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
if ($this->getThrowExceptions()) { |
|
59
|
|
|
throw new EE_Error($error_string); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
if ($this->getNotices()->hasSuccess()) { |
|
63
|
|
|
foreach ($this->getNotices()->getSuccess() as $notice) { |
|
64
|
|
|
// \EEH_Debug_Tools::printr($notice->message(), $notice->type(), __FILE__, __LINE__); |
|
65
|
|
|
EE_Error::add_success( |
|
66
|
|
|
$notice->message(), |
|
67
|
|
|
$notice->file(), |
|
68
|
|
|
$notice->func(), |
|
69
|
|
|
$notice->line() |
|
70
|
|
|
); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|