1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2
|
|
|
/** |
3
|
|
|
* class EE_Response |
4
|
|
|
* |
5
|
|
|
* Passes output, notices, and request termination status between EE_Middleware classes |
6
|
|
|
* |
7
|
|
|
* @package Event Espresso |
8
|
|
|
* @subpackage /core/ |
9
|
|
|
* @author Brent Christensen |
10
|
|
|
* |
11
|
|
|
* ------------------------------------------------------------------------ |
12
|
|
|
*/ |
13
|
|
|
class EE_Response { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @access protected |
17
|
|
|
* @type array $_notice |
18
|
|
|
*/ |
19
|
|
|
protected $_notice = array(); |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* rendered output to be returned to WP |
23
|
|
|
* @access protected |
24
|
|
|
* @type string |
25
|
|
|
*/ |
26
|
|
|
protected $_output = ''; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @access protected |
30
|
|
|
* @type bool |
31
|
|
|
*/ |
32
|
|
|
protected $request_terminated = false; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* class constructor |
38
|
|
|
* |
39
|
|
|
* @access public |
40
|
|
|
* @return \EE_Response |
|
|
|
|
41
|
|
|
*/ |
42
|
|
|
public function __construct() { |
43
|
|
|
$this->terminate_request( false ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* set_notice |
50
|
|
|
* |
51
|
|
|
* @access public |
52
|
|
|
* @param $key |
53
|
|
|
* @param $value |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
public function set_notice( $key, $value ) { |
57
|
|
|
$this->_notice[ $key ] = $value; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* get_notice |
64
|
|
|
* |
65
|
|
|
* @access public |
66
|
|
|
* @param $key |
67
|
|
|
* @return mixed |
68
|
|
|
*/ |
69
|
|
|
public function get_notice( $key ) { |
70
|
|
|
return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : NULL; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* get_notices |
77
|
|
|
* |
78
|
|
|
* @access public |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function get_notices() { |
82
|
|
|
return $this->_notice; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* add_output |
89
|
|
|
* |
90
|
|
|
* @access public |
91
|
|
|
* @param $string |
92
|
|
|
* @param bool $append |
93
|
|
|
*/ |
94
|
|
|
public function add_output( $string, $append = true ) { |
95
|
|
|
$this->_output = $append ? $this->_output . $string : $string . $this->_output; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* get_output |
102
|
|
|
* |
103
|
|
|
* @access public |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function get_output() { |
107
|
|
|
return $this->_output; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return boolean |
114
|
|
|
*/ |
115
|
|
|
public function request_terminated() { |
116
|
|
|
return $this->request_terminated; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param boolean $request_terminated |
123
|
|
|
*/ |
124
|
|
|
public function terminate_request( $request_terminated = true ) { |
125
|
|
|
$this->request_terminated = filter_var( $request_terminated, FILTER_VALIDATE_BOOLEAN ); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
|
129
|
|
|
} |
130
|
|
|
// End of file EE_Response.core.php |
131
|
|
|
// Location: /core/EE_Response.core.php |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.