@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
8 | 8 | |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -23,50 +23,50 @@ discard block |
||
23 | 23 | class CreateRegistrationCommandHandler extends CommandHandler |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var CreateRegistrationService $registration_service |
|
28 | - */ |
|
29 | - private $registration_service; |
|
26 | + /** |
|
27 | + * @var CreateRegistrationService $registration_service |
|
28 | + */ |
|
29 | + private $registration_service; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Command constructor |
|
35 | - * |
|
36 | - * @param CreateRegistrationService $registration_service |
|
37 | - */ |
|
38 | - public function __construct(CreateRegistrationService $registration_service) |
|
39 | - { |
|
40 | - $this->registration_service = $registration_service; |
|
41 | - } |
|
33 | + /** |
|
34 | + * Command constructor |
|
35 | + * |
|
36 | + * @param CreateRegistrationService $registration_service |
|
37 | + */ |
|
38 | + public function __construct(CreateRegistrationService $registration_service) |
|
39 | + { |
|
40 | + $this->registration_service = $registration_service; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @param CommandInterface $command |
|
47 | - * @return mixed |
|
48 | - * @throws \OutOfRangeException |
|
49 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
50 | - * @throws \EE_Error |
|
51 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
52 | - */ |
|
53 | - public function handle(CommandInterface $command) |
|
54 | - { |
|
55 | - /** @var CreateRegistrationCommand $command */ |
|
56 | - if ( ! $command instanceof CreateRegistrationCommand) { |
|
57 | - throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand'); |
|
58 | - } |
|
59 | - // now create a new registration for the ticket |
|
60 | - return $this->registration_service->create( |
|
61 | - $command->ticket()->get_related_event(), |
|
62 | - $command->transaction(), |
|
63 | - $command->ticket(), |
|
64 | - $command->ticketLineItem(), |
|
65 | - $command->regCount(), |
|
66 | - $command->regGroupSize(), |
|
67 | - $command->regStatus() |
|
68 | - ); |
|
69 | - } |
|
45 | + /** |
|
46 | + * @param CommandInterface $command |
|
47 | + * @return mixed |
|
48 | + * @throws \OutOfRangeException |
|
49 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
50 | + * @throws \EE_Error |
|
51 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
52 | + */ |
|
53 | + public function handle(CommandInterface $command) |
|
54 | + { |
|
55 | + /** @var CreateRegistrationCommand $command */ |
|
56 | + if ( ! $command instanceof CreateRegistrationCommand) { |
|
57 | + throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand'); |
|
58 | + } |
|
59 | + // now create a new registration for the ticket |
|
60 | + return $this->registration_service->create( |
|
61 | + $command->ticket()->get_related_event(), |
|
62 | + $command->transaction(), |
|
63 | + $command->ticket(), |
|
64 | + $command->ticketLineItem(), |
|
65 | + $command->regCount(), |
|
66 | + $command->regGroupSize(), |
|
67 | + $command->regStatus() |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | 72 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,672 +16,672 @@ discard block |
||
16 | 16 | abstract class EE_SPCO_Reg_Step |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * $_completed - TRUE if this step has fully completed it's duties |
|
21 | - * |
|
22 | - * @access protected |
|
23 | - * @type bool $_completed |
|
24 | - */ |
|
25 | - protected $_completed = false; |
|
26 | - |
|
27 | - /** |
|
28 | - * $_is_current_step - TRUE if this is the current step |
|
29 | - * |
|
30 | - * @access protected |
|
31 | - * @type bool $_is_current_step |
|
32 | - */ |
|
33 | - protected $_is_current_step = false; |
|
34 | - |
|
35 | - /** |
|
36 | - * $_order - when the reg step should be run relative to other steps |
|
37 | - * |
|
38 | - * @access protected |
|
39 | - * @type int $_template |
|
40 | - */ |
|
41 | - protected $_order = 0; |
|
42 | - |
|
43 | - /** |
|
44 | - * $_slug - URL param for this step |
|
45 | - * |
|
46 | - * @access protected |
|
47 | - * @type string $_slug |
|
48 | - */ |
|
49 | - protected $_slug; |
|
50 | - |
|
51 | - /** |
|
52 | - * $_name - Step Name - translatable string |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @type string $_slug |
|
56 | - */ |
|
57 | - protected $_name; |
|
58 | - |
|
59 | - /** |
|
60 | - * $_submit_button_text - translatable string that appears on this step's submit button |
|
61 | - * |
|
62 | - * @access protected |
|
63 | - * @type string $_slug |
|
64 | - */ |
|
65 | - protected $_submit_button_text; |
|
66 | - |
|
67 | - /** |
|
68 | - * $_template - template name |
|
69 | - * |
|
70 | - * @access protected |
|
71 | - * @type string $_template |
|
72 | - */ |
|
73 | - protected $_template; |
|
74 | - |
|
75 | - /** |
|
76 | - * $_reg_form_name - the form input name and id attribute |
|
77 | - * |
|
78 | - * @access protected |
|
79 | - * @var string $_reg_form_name |
|
80 | - */ |
|
81 | - protected $_reg_form_name; |
|
82 | - |
|
83 | - /** |
|
84 | - * $_success_message - text to display upon successful form submission |
|
85 | - * |
|
86 | - * @access private |
|
87 | - * @var string $_success_message |
|
88 | - */ |
|
89 | - protected $_success_message; |
|
90 | - |
|
91 | - /** |
|
92 | - * $_instructions - a brief description of how to complete the reg step. |
|
93 | - * Usually displayed in conjunction with the previous step's success message. |
|
94 | - * |
|
95 | - * @access private |
|
96 | - * @var string $_instructions |
|
97 | - */ |
|
98 | - protected $_instructions; |
|
99 | - |
|
100 | - /** |
|
101 | - * $_valid_data - the normalized and validated data for this step |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @var array $_valid_data |
|
105 | - */ |
|
106 | - protected $_valid_data = array(); |
|
107 | - |
|
108 | - /** |
|
109 | - * $reg_form - the registration form for this step |
|
110 | - * |
|
111 | - * @access public |
|
112 | - * @var EE_Form_Section_Proper $reg_form |
|
113 | - */ |
|
114 | - public $reg_form; |
|
115 | - |
|
116 | - /** |
|
117 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
118 | - * |
|
119 | - * @access public |
|
120 | - * @var EE_Checkout $checkout |
|
121 | - */ |
|
122 | - public $checkout; |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - abstract public function translate_js_strings(); |
|
130 | - |
|
131 | - |
|
19 | + /** |
|
20 | + * $_completed - TRUE if this step has fully completed it's duties |
|
21 | + * |
|
22 | + * @access protected |
|
23 | + * @type bool $_completed |
|
24 | + */ |
|
25 | + protected $_completed = false; |
|
26 | + |
|
27 | + /** |
|
28 | + * $_is_current_step - TRUE if this is the current step |
|
29 | + * |
|
30 | + * @access protected |
|
31 | + * @type bool $_is_current_step |
|
32 | + */ |
|
33 | + protected $_is_current_step = false; |
|
34 | + |
|
35 | + /** |
|
36 | + * $_order - when the reg step should be run relative to other steps |
|
37 | + * |
|
38 | + * @access protected |
|
39 | + * @type int $_template |
|
40 | + */ |
|
41 | + protected $_order = 0; |
|
42 | + |
|
43 | + /** |
|
44 | + * $_slug - URL param for this step |
|
45 | + * |
|
46 | + * @access protected |
|
47 | + * @type string $_slug |
|
48 | + */ |
|
49 | + protected $_slug; |
|
50 | + |
|
51 | + /** |
|
52 | + * $_name - Step Name - translatable string |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @type string $_slug |
|
56 | + */ |
|
57 | + protected $_name; |
|
58 | + |
|
59 | + /** |
|
60 | + * $_submit_button_text - translatable string that appears on this step's submit button |
|
61 | + * |
|
62 | + * @access protected |
|
63 | + * @type string $_slug |
|
64 | + */ |
|
65 | + protected $_submit_button_text; |
|
66 | + |
|
67 | + /** |
|
68 | + * $_template - template name |
|
69 | + * |
|
70 | + * @access protected |
|
71 | + * @type string $_template |
|
72 | + */ |
|
73 | + protected $_template; |
|
74 | + |
|
75 | + /** |
|
76 | + * $_reg_form_name - the form input name and id attribute |
|
77 | + * |
|
78 | + * @access protected |
|
79 | + * @var string $_reg_form_name |
|
80 | + */ |
|
81 | + protected $_reg_form_name; |
|
82 | + |
|
83 | + /** |
|
84 | + * $_success_message - text to display upon successful form submission |
|
85 | + * |
|
86 | + * @access private |
|
87 | + * @var string $_success_message |
|
88 | + */ |
|
89 | + protected $_success_message; |
|
90 | + |
|
91 | + /** |
|
92 | + * $_instructions - a brief description of how to complete the reg step. |
|
93 | + * Usually displayed in conjunction with the previous step's success message. |
|
94 | + * |
|
95 | + * @access private |
|
96 | + * @var string $_instructions |
|
97 | + */ |
|
98 | + protected $_instructions; |
|
99 | + |
|
100 | + /** |
|
101 | + * $_valid_data - the normalized and validated data for this step |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @var array $_valid_data |
|
105 | + */ |
|
106 | + protected $_valid_data = array(); |
|
107 | + |
|
108 | + /** |
|
109 | + * $reg_form - the registration form for this step |
|
110 | + * |
|
111 | + * @access public |
|
112 | + * @var EE_Form_Section_Proper $reg_form |
|
113 | + */ |
|
114 | + public $reg_form; |
|
115 | + |
|
116 | + /** |
|
117 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
118 | + * |
|
119 | + * @access public |
|
120 | + * @var EE_Checkout $checkout |
|
121 | + */ |
|
122 | + public $checkout; |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + abstract public function translate_js_strings(); |
|
130 | + |
|
131 | + |
|
132 | 132 | |
133 | - /** |
|
134 | - * @return void |
|
135 | - */ |
|
136 | - abstract public function enqueue_styles_and_scripts(); |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return boolean |
|
142 | - */ |
|
143 | - abstract public function initialize_reg_step(); |
|
144 | - |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - abstract public function generate_reg_form(); |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @return boolean |
|
156 | - */ |
|
157 | - abstract public function process_reg_step(); |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @return boolean |
|
163 | - */ |
|
164 | - abstract public function update_reg_step(); |
|
165 | - |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * @return boolean |
|
170 | - */ |
|
171 | - public function completed() |
|
172 | - { |
|
173 | - return $this->_completed; |
|
174 | - } |
|
133 | + /** |
|
134 | + * @return void |
|
135 | + */ |
|
136 | + abstract public function enqueue_styles_and_scripts(); |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return boolean |
|
142 | + */ |
|
143 | + abstract public function initialize_reg_step(); |
|
144 | + |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + abstract public function generate_reg_form(); |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @return boolean |
|
156 | + */ |
|
157 | + abstract public function process_reg_step(); |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @return boolean |
|
163 | + */ |
|
164 | + abstract public function update_reg_step(); |
|
165 | + |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * @return boolean |
|
170 | + */ |
|
171 | + public function completed() |
|
172 | + { |
|
173 | + return $this->_completed; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * set_completed - toggles $_completed to TRUE |
|
180 | - */ |
|
181 | - public function set_completed() |
|
182 | - { |
|
183 | - // DEBUG LOG |
|
184 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
185 | - $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this); |
|
186 | - } |
|
178 | + /** |
|
179 | + * set_completed - toggles $_completed to TRUE |
|
180 | + */ |
|
181 | + public function set_completed() |
|
182 | + { |
|
183 | + // DEBUG LOG |
|
184 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
185 | + $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * set_completed - toggles $_completed to FALSE |
|
192 | - */ |
|
193 | - public function set_not_completed() |
|
194 | - { |
|
195 | - $this->_completed = false; |
|
196 | - } |
|
190 | + /** |
|
191 | + * set_completed - toggles $_completed to FALSE |
|
192 | + */ |
|
193 | + public function set_not_completed() |
|
194 | + { |
|
195 | + $this->_completed = false; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public function name() |
|
204 | - { |
|
205 | - return $this->_name; |
|
206 | - } |
|
200 | + /** |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public function name() |
|
204 | + { |
|
205 | + return $this->_name; |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - /** |
|
211 | - * @return string |
|
212 | - */ |
|
213 | - public function slug() |
|
214 | - { |
|
215 | - return $this->_slug; |
|
216 | - } |
|
210 | + /** |
|
211 | + * @return string |
|
212 | + */ |
|
213 | + public function slug() |
|
214 | + { |
|
215 | + return $this->_slug; |
|
216 | + } |
|
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * submit_button_text |
|
222 | - * the text that appears on the reg step form submit button |
|
223 | - * |
|
224 | - * @return string |
|
225 | - */ |
|
226 | - public function submit_button_text() |
|
227 | - { |
|
228 | - return $this->_submit_button_text; |
|
229 | - } |
|
220 | + /** |
|
221 | + * submit_button_text |
|
222 | + * the text that appears on the reg step form submit button |
|
223 | + * |
|
224 | + * @return string |
|
225 | + */ |
|
226 | + public function submit_button_text() |
|
227 | + { |
|
228 | + return $this->_submit_button_text; |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * set_submit_button_text |
|
235 | - * sets the text that appears on the reg step form submit button |
|
236 | - * |
|
237 | - * @param string $submit_button_text |
|
238 | - */ |
|
239 | - public function set_submit_button_text($submit_button_text = '') |
|
240 | - { |
|
241 | - if (! empty($submit_button_text)) { |
|
242 | - $this->_submit_button_text = $submit_button_text; |
|
243 | - } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
244 | - if ($this->checkout->revisit) { |
|
245 | - $this->_submit_button_text = sprintf( |
|
246 | - __('Update %s', 'event_espresso'), |
|
247 | - $this->checkout->current_step->name() |
|
248 | - ); |
|
249 | - } else { |
|
250 | - $this->_submit_button_text = sprintf( |
|
251 | - __('Proceed to %s', 'event_espresso'), |
|
252 | - $this->checkout->next_step->name() |
|
253 | - ); |
|
254 | - } |
|
255 | - } |
|
256 | - // filters the submit button text |
|
257 | - $this->_submit_button_text = apply_filters( |
|
258 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
259 | - $this->_submit_button_text, |
|
260 | - $this->checkout |
|
261 | - ); |
|
262 | - } |
|
233 | + /** |
|
234 | + * set_submit_button_text |
|
235 | + * sets the text that appears on the reg step form submit button |
|
236 | + * |
|
237 | + * @param string $submit_button_text |
|
238 | + */ |
|
239 | + public function set_submit_button_text($submit_button_text = '') |
|
240 | + { |
|
241 | + if (! empty($submit_button_text)) { |
|
242 | + $this->_submit_button_text = $submit_button_text; |
|
243 | + } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
244 | + if ($this->checkout->revisit) { |
|
245 | + $this->_submit_button_text = sprintf( |
|
246 | + __('Update %s', 'event_espresso'), |
|
247 | + $this->checkout->current_step->name() |
|
248 | + ); |
|
249 | + } else { |
|
250 | + $this->_submit_button_text = sprintf( |
|
251 | + __('Proceed to %s', 'event_espresso'), |
|
252 | + $this->checkout->next_step->name() |
|
253 | + ); |
|
254 | + } |
|
255 | + } |
|
256 | + // filters the submit button text |
|
257 | + $this->_submit_button_text = apply_filters( |
|
258 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
259 | + $this->_submit_button_text, |
|
260 | + $this->checkout |
|
261 | + ); |
|
262 | + } |
|
263 | 263 | |
264 | 264 | |
265 | 265 | |
266 | - /** |
|
267 | - * @param boolean $is_current_step |
|
268 | - */ |
|
269 | - public function set_is_current_step($is_current_step) |
|
270 | - { |
|
271 | - $this->_is_current_step = $is_current_step; |
|
272 | - } |
|
266 | + /** |
|
267 | + * @param boolean $is_current_step |
|
268 | + */ |
|
269 | + public function set_is_current_step($is_current_step) |
|
270 | + { |
|
271 | + $this->_is_current_step = $is_current_step; |
|
272 | + } |
|
273 | 273 | |
274 | 274 | |
275 | 275 | |
276 | - /** |
|
277 | - * @return boolean |
|
278 | - */ |
|
279 | - public function is_current_step() |
|
280 | - { |
|
281 | - return $this->_is_current_step; |
|
282 | - } |
|
276 | + /** |
|
277 | + * @return boolean |
|
278 | + */ |
|
279 | + public function is_current_step() |
|
280 | + { |
|
281 | + return $this->_is_current_step; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | |
286 | - /** |
|
287 | - * @return boolean |
|
288 | - */ |
|
289 | - public function is_final_step() |
|
290 | - { |
|
291 | - return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false; |
|
292 | - } |
|
286 | + /** |
|
287 | + * @return boolean |
|
288 | + */ |
|
289 | + public function is_final_step() |
|
290 | + { |
|
291 | + return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false; |
|
292 | + } |
|
293 | 293 | |
294 | 294 | |
295 | 295 | |
296 | - /** |
|
297 | - * @param int $order |
|
298 | - */ |
|
299 | - public function set_order($order) |
|
300 | - { |
|
301 | - $this->_order = $order; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
296 | + /** |
|
297 | + * @param int $order |
|
298 | + */ |
|
299 | + public function set_order($order) |
|
300 | + { |
|
301 | + $this->_order = $order; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | 305 | |
306 | - /** |
|
307 | - * @return int |
|
308 | - */ |
|
309 | - public function order() |
|
310 | - { |
|
311 | - return $this->_order; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @return string |
|
318 | - */ |
|
319 | - public function template() |
|
320 | - { |
|
321 | - return $this->_template; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function success_message() |
|
330 | - { |
|
331 | - return $this->_success_message; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * _set_success_message |
|
338 | - * |
|
339 | - * @param string $success_message |
|
340 | - */ |
|
341 | - protected function _set_success_message($success_message) |
|
342 | - { |
|
343 | - $this->_success_message = $success_message; |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * _reset_success_message |
|
350 | - * |
|
351 | - * @return void |
|
352 | - */ |
|
353 | - protected function _reset_success_message() |
|
354 | - { |
|
355 | - $this->_success_message = ''; |
|
356 | - } |
|
306 | + /** |
|
307 | + * @return int |
|
308 | + */ |
|
309 | + public function order() |
|
310 | + { |
|
311 | + return $this->_order; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @return string |
|
318 | + */ |
|
319 | + public function template() |
|
320 | + { |
|
321 | + return $this->_template; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function success_message() |
|
330 | + { |
|
331 | + return $this->_success_message; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * _set_success_message |
|
338 | + * |
|
339 | + * @param string $success_message |
|
340 | + */ |
|
341 | + protected function _set_success_message($success_message) |
|
342 | + { |
|
343 | + $this->_success_message = $success_message; |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * _reset_success_message |
|
350 | + * |
|
351 | + * @return void |
|
352 | + */ |
|
353 | + protected function _reset_success_message() |
|
354 | + { |
|
355 | + $this->_success_message = ''; |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | 359 | |
360 | - /** |
|
361 | - * @return string |
|
362 | - */ |
|
363 | - public function _instructions() |
|
364 | - { |
|
365 | - return $this->_instructions; |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * @param string $instructions |
|
372 | - */ |
|
373 | - public function set_instructions($instructions) |
|
374 | - { |
|
375 | - $this->_instructions = apply_filters( |
|
376 | - 'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions', |
|
377 | - $instructions, |
|
378 | - $this |
|
379 | - ); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * @param array $valid_data |
|
386 | - */ |
|
387 | - public function set_valid_data($valid_data) |
|
388 | - { |
|
389 | - $this->_valid_data = $valid_data; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * @return array |
|
396 | - */ |
|
397 | - public function valid_data() |
|
398 | - { |
|
399 | - if (empty($this->_valid_data)) { |
|
400 | - $this->_valid_data = $this->reg_form->valid_data(); |
|
401 | - } |
|
402 | - return $this->_valid_data; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * @return string |
|
409 | - */ |
|
410 | - public function reg_form_name() |
|
411 | - { |
|
412 | - if (empty($this->_reg_form_name)) { |
|
413 | - $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
414 | - } |
|
415 | - return $this->_reg_form_name; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * @param string $reg_form_name |
|
422 | - */ |
|
423 | - protected function set_reg_form_name($reg_form_name) |
|
424 | - { |
|
425 | - $this->_reg_form_name = $reg_form_name; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * reg_step_url |
|
432 | - * |
|
433 | - * @param string $action |
|
434 | - * @return string |
|
435 | - */ |
|
436 | - public function reg_step_url($action = '') |
|
437 | - { |
|
438 | - $query_args = array('step' => $this->slug()); |
|
439 | - if (! empty($action)) { |
|
440 | - $query_args['action'] = $action; |
|
441 | - } |
|
442 | - // final step has no display |
|
443 | - if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') { |
|
444 | - $query_args['action'] = 'process_reg_step'; |
|
445 | - } |
|
446 | - if ($this->checkout->revisit) { |
|
447 | - $query_args['revisit'] = true; |
|
448 | - } |
|
449 | - if ($this->checkout->reg_url_link) { |
|
450 | - $query_args['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
451 | - } |
|
452 | - return add_query_arg($query_args, $this->checkout->reg_page_base_url); |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * creates the default hidden inputs section |
|
459 | - * |
|
460 | - * @return EE_Form_Section_Proper |
|
461 | - * @throws \EE_Error |
|
462 | - */ |
|
463 | - public function reg_step_hidden_inputs() |
|
464 | - { |
|
465 | - // hidden inputs for admin registrations |
|
466 | - if ($this->checkout->admin_request) { |
|
467 | - return new EE_Form_Section_Proper( |
|
468 | - array( |
|
469 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
470 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
471 | - 'subsections' => array( |
|
472 | - 'next_step' => new EE_Fixed_Hidden_Input( |
|
473 | - array( |
|
474 | - 'html_name' => 'next_step', |
|
475 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
476 | - 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
477 | - ? $this->checkout->next_step->slug() |
|
478 | - : '', |
|
479 | - ) |
|
480 | - ), |
|
481 | - ), |
|
482 | - ) |
|
483 | - ); |
|
484 | - } else { |
|
485 | - $default_form_action = apply_filters( |
|
486 | - 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action', |
|
487 | - empty($this->checkout->reg_url_link) |
|
488 | - ? 'process_reg_step' |
|
489 | - : 'update_reg_step', |
|
490 | - $this |
|
491 | - ); |
|
492 | - // hidden inputs for frontend registrations |
|
493 | - return new EE_Form_Section_Proper( |
|
494 | - array( |
|
495 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
496 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
497 | - 'subsections' => array( |
|
498 | - 'action' => new EE_Fixed_Hidden_Input( |
|
499 | - array( |
|
500 | - 'html_name' => 'action', |
|
501 | - 'html_id' => 'spco-' . $this->slug() . '-action', |
|
502 | - 'default' => $default_form_action, |
|
503 | - ) |
|
504 | - ), |
|
505 | - 'next_step' => new EE_Fixed_Hidden_Input( |
|
506 | - array( |
|
507 | - 'html_name' => 'next_step', |
|
508 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
509 | - 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
510 | - ? $this->checkout->next_step->slug() |
|
511 | - : '', |
|
512 | - ) |
|
513 | - ), |
|
514 | - 'e_reg_url_link' => new EE_Fixed_Hidden_Input( |
|
515 | - array( |
|
516 | - 'html_name' => 'e_reg_url_link', |
|
517 | - 'html_id' => 'spco-reg_url_link', |
|
518 | - 'default' => $this->checkout->reg_url_link, |
|
519 | - ) |
|
520 | - ), |
|
521 | - 'revisit' => new EE_Fixed_Hidden_Input( |
|
522 | - array( |
|
523 | - 'html_name' => 'revisit', |
|
524 | - 'html_id' => 'spco-revisit', |
|
525 | - 'default' => $this->checkout->revisit, |
|
526 | - ) |
|
527 | - ), |
|
528 | - ), |
|
529 | - ) |
|
530 | - ); |
|
531 | - } |
|
532 | - } |
|
533 | - |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * generate_reg_form_for_actions |
|
538 | - * |
|
539 | - * @param array $actions |
|
540 | - * @return void |
|
541 | - */ |
|
542 | - public function generate_reg_form_for_actions($actions = array()) |
|
543 | - { |
|
544 | - $actions = array_merge( |
|
545 | - array( |
|
546 | - 'generate_reg_form', |
|
547 | - 'display_spco_reg_step', |
|
548 | - 'process_reg_step', |
|
549 | - 'update_reg_step', |
|
550 | - ), |
|
551 | - $actions |
|
552 | - ); |
|
553 | - $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false; |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * @return string |
|
560 | - * @throws \EE_Error |
|
561 | - */ |
|
562 | - public function display_reg_form() |
|
563 | - { |
|
564 | - $html = ''; |
|
565 | - if ($this->reg_form instanceof EE_Form_Section_Proper) { |
|
566 | - $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : ''; |
|
567 | - if (EE_Registry::instance()->REQ->ajax) { |
|
568 | - $this->reg_form->localize_validation_rules(); |
|
569 | - $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
570 | - } |
|
571 | - $html .= $this->reg_form->get_html(); |
|
572 | - $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : ''; |
|
573 | - $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : ''; |
|
574 | - } |
|
575 | - return $html; |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
582 | - * |
|
583 | - * @return string |
|
584 | - * @throws \EE_Error |
|
585 | - */ |
|
586 | - public function reg_step_submit_button() |
|
587 | - { |
|
588 | - if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
589 | - return ''; |
|
590 | - } |
|
591 | - ob_start(); |
|
592 | - do_action( |
|
593 | - 'AHEE__before_spco_whats_next_buttons', |
|
594 | - $this->slug(), |
|
595 | - $this->checkout->next_step->slug(), |
|
596 | - $this->checkout |
|
597 | - ); |
|
598 | - $html = ob_get_clean(); |
|
599 | - // generate submit button |
|
600 | - $sbmt_btn = new EE_Submit_Input(array( |
|
601 | - 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
602 | - 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
603 | - 'html_class' => 'spco-next-step-btn', |
|
604 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
605 | - 'default' => $this->submit_button_text(), |
|
606 | - )); |
|
607 | - $sbmt_btn->set_button_css_attributes(true, 'large'); |
|
608 | - $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
|
609 | - $html .= EEH_HTML::div( |
|
610 | - apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
|
611 | - 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
612 | - 'spco-whats-next-buttons' |
|
613 | - ); |
|
614 | - return $html; |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - |
|
619 | - /** |
|
620 | - * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
621 | - * |
|
622 | - * @return string |
|
623 | - */ |
|
624 | - public function div_class() |
|
625 | - { |
|
626 | - return $this->is_current_step() ? '' : ' hidden'; |
|
627 | - } |
|
628 | - |
|
629 | - |
|
630 | - |
|
631 | - /** |
|
632 | - * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
633 | - * |
|
634 | - * @return string |
|
635 | - */ |
|
636 | - public function edit_lnk_url() |
|
637 | - { |
|
638 | - return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url); |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
645 | - * |
|
646 | - * @return string |
|
647 | - */ |
|
648 | - public function edit_link_class() |
|
649 | - { |
|
650 | - return $this->is_current_step() ? ' hidden' : ''; |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - |
|
655 | - /** |
|
656 | - * update_checkout with changes that have been made to the cart |
|
657 | - * |
|
658 | - * @return void |
|
659 | - * @throws \EE_Error |
|
660 | - */ |
|
661 | - public function update_checkout() |
|
662 | - { |
|
663 | - // grab the cart grand total and reset TXN total |
|
664 | - $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total()); |
|
665 | - $this->checkout->stash_transaction_and_checkout(); |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * __sleep |
|
674 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
675 | - * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
676 | - * reg form, because if needed, it will be regenerated anyways |
|
677 | - * |
|
678 | - * @return array |
|
679 | - */ |
|
680 | - public function __sleep() |
|
681 | - { |
|
682 | - // remove the reg form and the checkout |
|
683 | - return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout')); |
|
684 | - } |
|
360 | + /** |
|
361 | + * @return string |
|
362 | + */ |
|
363 | + public function _instructions() |
|
364 | + { |
|
365 | + return $this->_instructions; |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * @param string $instructions |
|
372 | + */ |
|
373 | + public function set_instructions($instructions) |
|
374 | + { |
|
375 | + $this->_instructions = apply_filters( |
|
376 | + 'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions', |
|
377 | + $instructions, |
|
378 | + $this |
|
379 | + ); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * @param array $valid_data |
|
386 | + */ |
|
387 | + public function set_valid_data($valid_data) |
|
388 | + { |
|
389 | + $this->_valid_data = $valid_data; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * @return array |
|
396 | + */ |
|
397 | + public function valid_data() |
|
398 | + { |
|
399 | + if (empty($this->_valid_data)) { |
|
400 | + $this->_valid_data = $this->reg_form->valid_data(); |
|
401 | + } |
|
402 | + return $this->_valid_data; |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * @return string |
|
409 | + */ |
|
410 | + public function reg_form_name() |
|
411 | + { |
|
412 | + if (empty($this->_reg_form_name)) { |
|
413 | + $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
414 | + } |
|
415 | + return $this->_reg_form_name; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * @param string $reg_form_name |
|
422 | + */ |
|
423 | + protected function set_reg_form_name($reg_form_name) |
|
424 | + { |
|
425 | + $this->_reg_form_name = $reg_form_name; |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * reg_step_url |
|
432 | + * |
|
433 | + * @param string $action |
|
434 | + * @return string |
|
435 | + */ |
|
436 | + public function reg_step_url($action = '') |
|
437 | + { |
|
438 | + $query_args = array('step' => $this->slug()); |
|
439 | + if (! empty($action)) { |
|
440 | + $query_args['action'] = $action; |
|
441 | + } |
|
442 | + // final step has no display |
|
443 | + if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') { |
|
444 | + $query_args['action'] = 'process_reg_step'; |
|
445 | + } |
|
446 | + if ($this->checkout->revisit) { |
|
447 | + $query_args['revisit'] = true; |
|
448 | + } |
|
449 | + if ($this->checkout->reg_url_link) { |
|
450 | + $query_args['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
451 | + } |
|
452 | + return add_query_arg($query_args, $this->checkout->reg_page_base_url); |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * creates the default hidden inputs section |
|
459 | + * |
|
460 | + * @return EE_Form_Section_Proper |
|
461 | + * @throws \EE_Error |
|
462 | + */ |
|
463 | + public function reg_step_hidden_inputs() |
|
464 | + { |
|
465 | + // hidden inputs for admin registrations |
|
466 | + if ($this->checkout->admin_request) { |
|
467 | + return new EE_Form_Section_Proper( |
|
468 | + array( |
|
469 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
470 | + 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
471 | + 'subsections' => array( |
|
472 | + 'next_step' => new EE_Fixed_Hidden_Input( |
|
473 | + array( |
|
474 | + 'html_name' => 'next_step', |
|
475 | + 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
476 | + 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
477 | + ? $this->checkout->next_step->slug() |
|
478 | + : '', |
|
479 | + ) |
|
480 | + ), |
|
481 | + ), |
|
482 | + ) |
|
483 | + ); |
|
484 | + } else { |
|
485 | + $default_form_action = apply_filters( |
|
486 | + 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action', |
|
487 | + empty($this->checkout->reg_url_link) |
|
488 | + ? 'process_reg_step' |
|
489 | + : 'update_reg_step', |
|
490 | + $this |
|
491 | + ); |
|
492 | + // hidden inputs for frontend registrations |
|
493 | + return new EE_Form_Section_Proper( |
|
494 | + array( |
|
495 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
496 | + 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
497 | + 'subsections' => array( |
|
498 | + 'action' => new EE_Fixed_Hidden_Input( |
|
499 | + array( |
|
500 | + 'html_name' => 'action', |
|
501 | + 'html_id' => 'spco-' . $this->slug() . '-action', |
|
502 | + 'default' => $default_form_action, |
|
503 | + ) |
|
504 | + ), |
|
505 | + 'next_step' => new EE_Fixed_Hidden_Input( |
|
506 | + array( |
|
507 | + 'html_name' => 'next_step', |
|
508 | + 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
509 | + 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
510 | + ? $this->checkout->next_step->slug() |
|
511 | + : '', |
|
512 | + ) |
|
513 | + ), |
|
514 | + 'e_reg_url_link' => new EE_Fixed_Hidden_Input( |
|
515 | + array( |
|
516 | + 'html_name' => 'e_reg_url_link', |
|
517 | + 'html_id' => 'spco-reg_url_link', |
|
518 | + 'default' => $this->checkout->reg_url_link, |
|
519 | + ) |
|
520 | + ), |
|
521 | + 'revisit' => new EE_Fixed_Hidden_Input( |
|
522 | + array( |
|
523 | + 'html_name' => 'revisit', |
|
524 | + 'html_id' => 'spco-revisit', |
|
525 | + 'default' => $this->checkout->revisit, |
|
526 | + ) |
|
527 | + ), |
|
528 | + ), |
|
529 | + ) |
|
530 | + ); |
|
531 | + } |
|
532 | + } |
|
533 | + |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * generate_reg_form_for_actions |
|
538 | + * |
|
539 | + * @param array $actions |
|
540 | + * @return void |
|
541 | + */ |
|
542 | + public function generate_reg_form_for_actions($actions = array()) |
|
543 | + { |
|
544 | + $actions = array_merge( |
|
545 | + array( |
|
546 | + 'generate_reg_form', |
|
547 | + 'display_spco_reg_step', |
|
548 | + 'process_reg_step', |
|
549 | + 'update_reg_step', |
|
550 | + ), |
|
551 | + $actions |
|
552 | + ); |
|
553 | + $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false; |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * @return string |
|
560 | + * @throws \EE_Error |
|
561 | + */ |
|
562 | + public function display_reg_form() |
|
563 | + { |
|
564 | + $html = ''; |
|
565 | + if ($this->reg_form instanceof EE_Form_Section_Proper) { |
|
566 | + $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : ''; |
|
567 | + if (EE_Registry::instance()->REQ->ajax) { |
|
568 | + $this->reg_form->localize_validation_rules(); |
|
569 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
570 | + } |
|
571 | + $html .= $this->reg_form->get_html(); |
|
572 | + $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : ''; |
|
573 | + $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : ''; |
|
574 | + } |
|
575 | + return $html; |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
582 | + * |
|
583 | + * @return string |
|
584 | + * @throws \EE_Error |
|
585 | + */ |
|
586 | + public function reg_step_submit_button() |
|
587 | + { |
|
588 | + if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
589 | + return ''; |
|
590 | + } |
|
591 | + ob_start(); |
|
592 | + do_action( |
|
593 | + 'AHEE__before_spco_whats_next_buttons', |
|
594 | + $this->slug(), |
|
595 | + $this->checkout->next_step->slug(), |
|
596 | + $this->checkout |
|
597 | + ); |
|
598 | + $html = ob_get_clean(); |
|
599 | + // generate submit button |
|
600 | + $sbmt_btn = new EE_Submit_Input(array( |
|
601 | + 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
602 | + 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
603 | + 'html_class' => 'spco-next-step-btn', |
|
604 | + 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
605 | + 'default' => $this->submit_button_text(), |
|
606 | + )); |
|
607 | + $sbmt_btn->set_button_css_attributes(true, 'large'); |
|
608 | + $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
|
609 | + $html .= EEH_HTML::div( |
|
610 | + apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
|
611 | + 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
612 | + 'spco-whats-next-buttons' |
|
613 | + ); |
|
614 | + return $html; |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + |
|
619 | + /** |
|
620 | + * div_class - returns nothing for current step, but a css class of "hidden" for others |
|
621 | + * |
|
622 | + * @return string |
|
623 | + */ |
|
624 | + public function div_class() |
|
625 | + { |
|
626 | + return $this->is_current_step() ? '' : ' hidden'; |
|
627 | + } |
|
628 | + |
|
629 | + |
|
630 | + |
|
631 | + /** |
|
632 | + * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
633 | + * |
|
634 | + * @return string |
|
635 | + */ |
|
636 | + public function edit_lnk_url() |
|
637 | + { |
|
638 | + return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url); |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * div_class - returns a css class of "hidden" for current step, but nothing for others |
|
645 | + * |
|
646 | + * @return string |
|
647 | + */ |
|
648 | + public function edit_link_class() |
|
649 | + { |
|
650 | + return $this->is_current_step() ? ' hidden' : ''; |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + |
|
655 | + /** |
|
656 | + * update_checkout with changes that have been made to the cart |
|
657 | + * |
|
658 | + * @return void |
|
659 | + * @throws \EE_Error |
|
660 | + */ |
|
661 | + public function update_checkout() |
|
662 | + { |
|
663 | + // grab the cart grand total and reset TXN total |
|
664 | + $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total()); |
|
665 | + $this->checkout->stash_transaction_and_checkout(); |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * __sleep |
|
674 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
675 | + * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
676 | + * reg form, because if needed, it will be regenerated anyways |
|
677 | + * |
|
678 | + * @return array |
|
679 | + */ |
|
680 | + public function __sleep() |
|
681 | + { |
|
682 | + // remove the reg form and the checkout |
|
683 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout')); |
|
684 | + } |
|
685 | 685 | |
686 | 686 | |
687 | 687 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function set_submit_button_text($submit_button_text = '') |
240 | 240 | { |
241 | - if (! empty($submit_button_text)) { |
|
241 | + if ( ! empty($submit_button_text)) { |
|
242 | 242 | $this->_submit_button_text = $submit_button_text; |
243 | 243 | } else if ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
244 | 244 | if ($this->checkout->revisit) { |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | public function reg_form_name() |
411 | 411 | { |
412 | 412 | if (empty($this->_reg_form_name)) { |
413 | - $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form'); |
|
413 | + $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form'); |
|
414 | 414 | } |
415 | 415 | return $this->_reg_form_name; |
416 | 416 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | public function reg_step_url($action = '') |
437 | 437 | { |
438 | 438 | $query_args = array('step' => $this->slug()); |
439 | - if (! empty($action)) { |
|
439 | + if ( ! empty($action)) { |
|
440 | 440 | $query_args['action'] = $action; |
441 | 441 | } |
442 | 442 | // final step has no display |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | return new EE_Form_Section_Proper( |
468 | 468 | array( |
469 | 469 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
470 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
470 | + 'html_id' => 'ee-'.$this->slug().'-hidden-inputs', |
|
471 | 471 | 'subsections' => array( |
472 | 472 | 'next_step' => new EE_Fixed_Hidden_Input( |
473 | 473 | array( |
474 | 474 | 'html_name' => 'next_step', |
475 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
475 | + 'html_id' => 'spco-'.$this->slug().'-next-step', |
|
476 | 476 | 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
477 | 477 | ? $this->checkout->next_step->slug() |
478 | 478 | : '', |
@@ -493,19 +493,19 @@ discard block |
||
493 | 493 | return new EE_Form_Section_Proper( |
494 | 494 | array( |
495 | 495 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
496 | - 'html_id' => 'ee-' . $this->slug() . '-hidden-inputs', |
|
496 | + 'html_id' => 'ee-'.$this->slug().'-hidden-inputs', |
|
497 | 497 | 'subsections' => array( |
498 | 498 | 'action' => new EE_Fixed_Hidden_Input( |
499 | 499 | array( |
500 | 500 | 'html_name' => 'action', |
501 | - 'html_id' => 'spco-' . $this->slug() . '-action', |
|
501 | + 'html_id' => 'spco-'.$this->slug().'-action', |
|
502 | 502 | 'default' => $default_form_action, |
503 | 503 | ) |
504 | 504 | ), |
505 | 505 | 'next_step' => new EE_Fixed_Hidden_Input( |
506 | 506 | array( |
507 | 507 | 'html_name' => 'next_step', |
508 | - 'html_id' => 'spco-' . $this->slug() . '-next-step', |
|
508 | + 'html_id' => 'spco-'.$this->slug().'-next-step', |
|
509 | 509 | 'default' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
510 | 510 | ? $this->checkout->next_step->slug() |
511 | 511 | : '', |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function reg_step_submit_button() |
587 | 587 | { |
588 | - if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
588 | + if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
589 | 589 | return ''; |
590 | 590 | } |
591 | 591 | ob_start(); |
@@ -598,17 +598,17 @@ discard block |
||
598 | 598 | $html = ob_get_clean(); |
599 | 599 | // generate submit button |
600 | 600 | $sbmt_btn = new EE_Submit_Input(array( |
601 | - 'html_name' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
602 | - 'html_id' => 'spco-go-to-step-' . $this->checkout->next_step->slug(), |
|
601 | + 'html_name' => 'spco-go-to-step-'.$this->checkout->next_step->slug(), |
|
602 | + 'html_id' => 'spco-go-to-step-'.$this->checkout->next_step->slug(), |
|
603 | 603 | 'html_class' => 'spco-next-step-btn', |
604 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
604 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
605 | 605 | 'default' => $this->submit_button_text(), |
606 | 606 | )); |
607 | 607 | $sbmt_btn->set_button_css_attributes(true, 'large'); |
608 | 608 | $sbmt_btn_html = $sbmt_btn->get_html_for_input(); |
609 | 609 | $html .= EEH_HTML::div( |
610 | 610 | apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this), |
611 | - 'spco-' . $this->slug() . '-whats-next-buttons-dv', |
|
611 | + 'spco-'.$this->slug().'-whats-next-buttons-dv', |
|
612 | 612 | 'spco-whats-next-buttons' |
613 | 613 | ); |
614 | 614 | return $html; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use EventEspresso\core\services\commands\CommandRequiresCapCheckInterface; |
14 | 14 | |
15 | 15 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
16 | - exit('No direct script access allowed'); |
|
16 | + exit('No direct script access allowed'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
@@ -29,162 +29,162 @@ discard block |
||
29 | 29 | class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var EE_Transaction $transaction |
|
34 | - */ |
|
35 | - private $transaction; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Ticket $ticket |
|
39 | - */ |
|
40 | - private $ticket; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Line_Item $ticket_line_item |
|
44 | - */ |
|
45 | - private $ticket_line_item; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int $reg_count |
|
49 | - */ |
|
50 | - private $reg_count; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var int $reg_group_size |
|
54 | - */ |
|
55 | - private $reg_group_size; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $reg_status |
|
59 | - */ |
|
60 | - private $reg_status; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var EE_Registration $registration |
|
64 | - */ |
|
65 | - protected $registration; |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * CreateRegistrationCommand constructor. |
|
71 | - * |
|
72 | - * @param EE_Transaction $transaction |
|
73 | - * @param EE_Line_Item $ticket_line_item |
|
74 | - * @param int $reg_count |
|
75 | - * @param int $reg_group_size |
|
76 | - * @param string $reg_status |
|
77 | - * @throws InvalidEntityException |
|
78 | - */ |
|
79 | - public function __construct( |
|
80 | - EE_Transaction $transaction, |
|
81 | - EE_Line_Item $ticket_line_item, |
|
82 | - $reg_count = 1, |
|
83 | - $reg_group_size = 0, |
|
84 | - $reg_status = EEM_Registration::status_id_incomplete |
|
85 | - ) { |
|
86 | - // grab the related ticket object for this line_item |
|
87 | - $this->ticket = $ticket_line_item->ticket(); |
|
88 | - if ( ! $this->ticket instanceof EE_Ticket) { |
|
89 | - throw new InvalidEntityException( |
|
90 | - is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
91 | - 'EE_Ticket', |
|
92 | - sprintf( |
|
93 | - __('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
94 | - $ticket_line_item->ID() |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - $this->transaction = $transaction; |
|
99 | - $this->ticket_line_item = $ticket_line_item; |
|
100 | - $this->reg_count = absint($reg_count); |
|
101 | - $this->reg_group_size = absint($reg_group_size); |
|
102 | - $this->reg_status = $reg_status; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
109 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
110 | - */ |
|
111 | - public function getCapCheck() |
|
112 | - { |
|
113 | - if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
114 | - return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
115 | - } |
|
116 | - return $this->cap_check; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @return EE_Transaction |
|
123 | - */ |
|
124 | - public function transaction() |
|
125 | - { |
|
126 | - return $this->transaction; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return EE_Ticket |
|
133 | - */ |
|
134 | - public function ticket() |
|
135 | - { |
|
136 | - return $this->ticket; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return EE_Line_Item |
|
143 | - */ |
|
144 | - public function ticketLineItem() |
|
145 | - { |
|
146 | - return $this->ticket_line_item; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @return int |
|
153 | - */ |
|
154 | - public function regCount() |
|
155 | - { |
|
156 | - return $this->reg_count; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - public function regGroupSize() |
|
165 | - { |
|
166 | - return $this->reg_group_size; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public function regStatus() |
|
175 | - { |
|
176 | - return $this->reg_status; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * @return EE_Registration |
|
183 | - */ |
|
184 | - public function registration() |
|
185 | - { |
|
186 | - return $this->registration; |
|
187 | - } |
|
32 | + /** |
|
33 | + * @var EE_Transaction $transaction |
|
34 | + */ |
|
35 | + private $transaction; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Ticket $ticket |
|
39 | + */ |
|
40 | + private $ticket; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Line_Item $ticket_line_item |
|
44 | + */ |
|
45 | + private $ticket_line_item; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int $reg_count |
|
49 | + */ |
|
50 | + private $reg_count; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var int $reg_group_size |
|
54 | + */ |
|
55 | + private $reg_group_size; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $reg_status |
|
59 | + */ |
|
60 | + private $reg_status; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var EE_Registration $registration |
|
64 | + */ |
|
65 | + protected $registration; |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * CreateRegistrationCommand constructor. |
|
71 | + * |
|
72 | + * @param EE_Transaction $transaction |
|
73 | + * @param EE_Line_Item $ticket_line_item |
|
74 | + * @param int $reg_count |
|
75 | + * @param int $reg_group_size |
|
76 | + * @param string $reg_status |
|
77 | + * @throws InvalidEntityException |
|
78 | + */ |
|
79 | + public function __construct( |
|
80 | + EE_Transaction $transaction, |
|
81 | + EE_Line_Item $ticket_line_item, |
|
82 | + $reg_count = 1, |
|
83 | + $reg_group_size = 0, |
|
84 | + $reg_status = EEM_Registration::status_id_incomplete |
|
85 | + ) { |
|
86 | + // grab the related ticket object for this line_item |
|
87 | + $this->ticket = $ticket_line_item->ticket(); |
|
88 | + if ( ! $this->ticket instanceof EE_Ticket) { |
|
89 | + throw new InvalidEntityException( |
|
90 | + is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
91 | + 'EE_Ticket', |
|
92 | + sprintf( |
|
93 | + __('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
94 | + $ticket_line_item->ID() |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + $this->transaction = $transaction; |
|
99 | + $this->ticket_line_item = $ticket_line_item; |
|
100 | + $this->reg_count = absint($reg_count); |
|
101 | + $this->reg_group_size = absint($reg_group_size); |
|
102 | + $this->reg_status = $reg_status; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
109 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
110 | + */ |
|
111 | + public function getCapCheck() |
|
112 | + { |
|
113 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
114 | + return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
115 | + } |
|
116 | + return $this->cap_check; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @return EE_Transaction |
|
123 | + */ |
|
124 | + public function transaction() |
|
125 | + { |
|
126 | + return $this->transaction; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return EE_Ticket |
|
133 | + */ |
|
134 | + public function ticket() |
|
135 | + { |
|
136 | + return $this->ticket; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return EE_Line_Item |
|
143 | + */ |
|
144 | + public function ticketLineItem() |
|
145 | + { |
|
146 | + return $this->ticket_line_item; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @return int |
|
153 | + */ |
|
154 | + public function regCount() |
|
155 | + { |
|
156 | + return $this->reg_count; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + public function regGroupSize() |
|
165 | + { |
|
166 | + return $this->reg_group_size; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public function regStatus() |
|
175 | + { |
|
176 | + return $this->reg_status; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * @return EE_Registration |
|
183 | + */ |
|
184 | + public function registration() |
|
185 | + { |
|
186 | + return $this->registration; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | 190 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use InvalidArgumentException; |
8 | 8 | |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -23,103 +23,103 @@ discard block |
||
23 | 23 | class RegUrlLink |
24 | 24 | { |
25 | 25 | |
26 | - /* |
|
26 | + /* |
|
27 | 27 | * @var string $reg_url_link |
28 | 28 | */ |
29 | - private $reg_url_link; |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @param string $reg_url_link |
|
35 | - * @return RegUrlLink |
|
36 | - * @throws InvalidArgumentException |
|
37 | - */ |
|
38 | - public static function fromRegUrlLinkString($reg_url_link) |
|
39 | - { |
|
40 | - if (empty($reg_url_link) || ! is_string($reg_url_link)) { |
|
41 | - throw new InvalidArgumentException( |
|
42 | - __( |
|
43 | - 'You must supply a valid non-empty string to generate a reg_url_link.', |
|
44 | - 'event_espresso' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
48 | - return new RegUrlLink(1, '', $reg_url_link); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param EE_Registration $registration |
|
55 | - * @return RegUrlLink |
|
56 | - * @throws EntityNotFoundException |
|
57 | - * @throws EE_Error |
|
58 | - * @throws InvalidArgumentException |
|
59 | - */ |
|
60 | - public static function fromRegistration(EE_Registration $registration) |
|
61 | - { |
|
62 | - return new RegUrlLink( |
|
63 | - $registration->count(), |
|
64 | - $registration->ticket_line_item() |
|
65 | - ); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * CreateRegUrlLinkCommand constructor. |
|
72 | - * |
|
73 | - * @param int $reg_count |
|
74 | - * @param mixed $base_code |
|
75 | - * @param string $reg_url_link |
|
76 | - * @throws InvalidArgumentException |
|
77 | - */ |
|
78 | - public function __construct( |
|
79 | - $reg_count = 1, |
|
80 | - $base_code = '', |
|
81 | - $reg_url_link = '' |
|
82 | - ) { |
|
83 | - if ( ! empty($reg_url_link) && is_string($reg_url_link)) { |
|
84 | - $this->reg_url_link = apply_filters( |
|
85 | - 'FHEE__\EventEspresso\core\domain\entities\RegUrlLink__construct__reg_url_link', |
|
86 | - $reg_url_link, |
|
87 | - $reg_count, |
|
88 | - $base_code, |
|
89 | - $reg_url_link |
|
90 | - ); |
|
91 | - return; |
|
92 | - } |
|
93 | - $reg_count = max(1, absint($reg_count)); |
|
94 | - $base_code = $base_code instanceof \EE_Line_Item ? $base_code->code() : $base_code; |
|
95 | - if (empty($base_code) || ! is_string($base_code)) { |
|
96 | - throw new InvalidArgumentException( |
|
97 | - __( |
|
98 | - 'You must supply a valid EE_Line_Item or a non-empty string to generate a reg_url_link.', |
|
99 | - 'event_espresso' |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - $this->reg_url_link = (string) apply_filters( |
|
104 | - 'FHEE__\EventEspresso\core\domain\entities\RegUrlLink__construct__reg_url_link', |
|
105 | - $reg_count . '-' . md5($base_code . microtime()), |
|
106 | - $reg_count, |
|
107 | - $base_code, |
|
108 | - $reg_url_link |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Return the object as a string |
|
116 | - * |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function __toString() |
|
120 | - { |
|
121 | - return $this->reg_url_link; |
|
122 | - } |
|
29 | + private $reg_url_link; |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @param string $reg_url_link |
|
35 | + * @return RegUrlLink |
|
36 | + * @throws InvalidArgumentException |
|
37 | + */ |
|
38 | + public static function fromRegUrlLinkString($reg_url_link) |
|
39 | + { |
|
40 | + if (empty($reg_url_link) || ! is_string($reg_url_link)) { |
|
41 | + throw new InvalidArgumentException( |
|
42 | + __( |
|
43 | + 'You must supply a valid non-empty string to generate a reg_url_link.', |
|
44 | + 'event_espresso' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | + return new RegUrlLink(1, '', $reg_url_link); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param EE_Registration $registration |
|
55 | + * @return RegUrlLink |
|
56 | + * @throws EntityNotFoundException |
|
57 | + * @throws EE_Error |
|
58 | + * @throws InvalidArgumentException |
|
59 | + */ |
|
60 | + public static function fromRegistration(EE_Registration $registration) |
|
61 | + { |
|
62 | + return new RegUrlLink( |
|
63 | + $registration->count(), |
|
64 | + $registration->ticket_line_item() |
|
65 | + ); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * CreateRegUrlLinkCommand constructor. |
|
72 | + * |
|
73 | + * @param int $reg_count |
|
74 | + * @param mixed $base_code |
|
75 | + * @param string $reg_url_link |
|
76 | + * @throws InvalidArgumentException |
|
77 | + */ |
|
78 | + public function __construct( |
|
79 | + $reg_count = 1, |
|
80 | + $base_code = '', |
|
81 | + $reg_url_link = '' |
|
82 | + ) { |
|
83 | + if ( ! empty($reg_url_link) && is_string($reg_url_link)) { |
|
84 | + $this->reg_url_link = apply_filters( |
|
85 | + 'FHEE__\EventEspresso\core\domain\entities\RegUrlLink__construct__reg_url_link', |
|
86 | + $reg_url_link, |
|
87 | + $reg_count, |
|
88 | + $base_code, |
|
89 | + $reg_url_link |
|
90 | + ); |
|
91 | + return; |
|
92 | + } |
|
93 | + $reg_count = max(1, absint($reg_count)); |
|
94 | + $base_code = $base_code instanceof \EE_Line_Item ? $base_code->code() : $base_code; |
|
95 | + if (empty($base_code) || ! is_string($base_code)) { |
|
96 | + throw new InvalidArgumentException( |
|
97 | + __( |
|
98 | + 'You must supply a valid EE_Line_Item or a non-empty string to generate a reg_url_link.', |
|
99 | + 'event_espresso' |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + $this->reg_url_link = (string) apply_filters( |
|
104 | + 'FHEE__\EventEspresso\core\domain\entities\RegUrlLink__construct__reg_url_link', |
|
105 | + $reg_count . '-' . md5($base_code . microtime()), |
|
106 | + $reg_count, |
|
107 | + $base_code, |
|
108 | + $reg_url_link |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Return the object as a string |
|
116 | + * |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function __toString() |
|
120 | + { |
|
121 | + return $this->reg_url_link; |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | // End of file RegUrlLink.php |
125 | 125 | // Location: /RegUrlLink.php |
126 | 126 | \ No newline at end of file |
@@ -102,7 +102,7 @@ |
||
102 | 102 | } |
103 | 103 | $this->reg_url_link = (string) apply_filters( |
104 | 104 | 'FHEE__\EventEspresso\core\domain\entities\RegUrlLink__construct__reg_url_link', |
105 | - $reg_count . '-' . md5($base_code . microtime()), |
|
105 | + $reg_count.'-'.md5($base_code.microtime()), |
|
106 | 106 | $reg_count, |
107 | 107 | $base_code, |
108 | 108 | $reg_url_link |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter; |
3 | 3 | |
4 | 4 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,480 +19,480 @@ discard block |
||
19 | 19 | abstract class EE_Form_Section_Base |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * the URL the form is submitted to |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_action; |
|
28 | - |
|
29 | - /** |
|
30 | - * POST (default) or GET |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $_method; |
|
35 | - |
|
36 | - /** |
|
37 | - * html_id and html_name are derived from this by default |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $_name; |
|
42 | - |
|
43 | - /** |
|
44 | - * $_html_id |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $_html_id; |
|
48 | - |
|
49 | - /** |
|
50 | - * $_html_class |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - protected $_html_class; |
|
54 | - |
|
55 | - /** |
|
56 | - * $_html_style |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $_html_style; |
|
60 | - |
|
61 | - /** |
|
62 | - * $_other_html_attributes |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $_other_html_attributes; |
|
66 | - |
|
67 | - /** |
|
68 | - * The form section of which this form section is a part |
|
69 | - * |
|
70 | - * @var EE_Form_Section_Proper |
|
71 | - */ |
|
72 | - protected $_parent_section; |
|
73 | - |
|
74 | - /** |
|
75 | - * flag indicating that _construct_finalize has been called. |
|
76 | - * If it hasn't been called and we try to use functions which require it, we call it |
|
77 | - * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
78 | - * |
|
79 | - * @var boolean |
|
80 | - */ |
|
81 | - protected $_construction_finalized; |
|
82 | - |
|
83 | - /** |
|
84 | - * Strategy for parsing the form HTML upon display |
|
85 | - * |
|
86 | - * @var FormHtmlFilter |
|
87 | - */ |
|
88 | - protected $_form_html_filter; |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param array $options_array { |
|
94 | - * @type $name string the name for this form section, if you want to explicitly define it |
|
95 | - * } |
|
96 | - */ |
|
97 | - public function __construct($options_array = array()) |
|
98 | - { |
|
99 | - // used by display strategies |
|
100 | - // assign incoming values to properties |
|
101 | - foreach ($options_array as $key => $value) { |
|
102 | - $key = '_' . $key; |
|
103 | - if (property_exists($this, $key) && empty($this->{$key})) { |
|
104 | - $this->{$key} = $value; |
|
105 | - } |
|
106 | - } |
|
107 | - // set parser which allows the form section's rendered HTML to be filtered |
|
108 | - if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
109 | - $this->_form_html_filter = $options_array['form_html_filter']; |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @param $parent_form_section |
|
117 | - * @param $name |
|
118 | - * @throws \EE_Error |
|
119 | - */ |
|
120 | - protected function _construct_finalize($parent_form_section, $name) |
|
121 | - { |
|
122 | - $this->_construction_finalized = true; |
|
123 | - $this->_parent_section = $parent_form_section; |
|
124 | - if ($name !== null) { |
|
125 | - $this->_name = $name; |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * make sure construction finalized was called, otherwise children might not be ready |
|
133 | - * |
|
134 | - * @return void |
|
135 | - * @throws \EE_Error |
|
136 | - */ |
|
137 | - public function ensure_construct_finalized_called() |
|
138 | - { |
|
139 | - if (! $this->_construction_finalized) { |
|
140 | - $this->_construct_finalize($this->_parent_section, $this->_name); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function action() |
|
150 | - { |
|
151 | - return $this->_action; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $action |
|
158 | - */ |
|
159 | - public function set_action($action) |
|
160 | - { |
|
161 | - $this->_action = $action; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - public function method() |
|
170 | - { |
|
171 | - return ! empty($this->_method) ? $this->_method : 'POST'; |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $method |
|
178 | - */ |
|
179 | - public function set_method($method) |
|
180 | - { |
|
181 | - switch ($method) { |
|
182 | - case 'get' : |
|
183 | - case 'GET' : |
|
184 | - $this->_method = 'GET'; |
|
185 | - break; |
|
186 | - default : |
|
187 | - $this->_method = 'POST'; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Sets the html_id to its default value, if none was specified in the constructor. |
|
195 | - * Calculation involves using the name and the parent's html id |
|
196 | - * return void |
|
197 | - * |
|
198 | - * @throws \EE_Error |
|
199 | - */ |
|
200 | - protected function _set_default_html_id_if_empty() |
|
201 | - { |
|
202 | - if (! $this->_html_id) { |
|
203 | - if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
204 | - $this->_html_id = $this->_parent_section->html_id() |
|
205 | - . '-' |
|
206 | - . $this->_prep_name_for_html_id($this->name()); |
|
207 | - } else { |
|
208 | - $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * _prep_name_for_html_id |
|
217 | - * |
|
218 | - * @param $name |
|
219 | - * @return string |
|
220 | - */ |
|
221 | - private function _prep_name_for_html_id($name) |
|
222 | - { |
|
223 | - return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
224 | - } |
|
22 | + /** |
|
23 | + * the URL the form is submitted to |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_action; |
|
28 | + |
|
29 | + /** |
|
30 | + * POST (default) or GET |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $_method; |
|
35 | + |
|
36 | + /** |
|
37 | + * html_id and html_name are derived from this by default |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $_name; |
|
42 | + |
|
43 | + /** |
|
44 | + * $_html_id |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $_html_id; |
|
48 | + |
|
49 | + /** |
|
50 | + * $_html_class |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + protected $_html_class; |
|
54 | + |
|
55 | + /** |
|
56 | + * $_html_style |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $_html_style; |
|
60 | + |
|
61 | + /** |
|
62 | + * $_other_html_attributes |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $_other_html_attributes; |
|
66 | + |
|
67 | + /** |
|
68 | + * The form section of which this form section is a part |
|
69 | + * |
|
70 | + * @var EE_Form_Section_Proper |
|
71 | + */ |
|
72 | + protected $_parent_section; |
|
73 | + |
|
74 | + /** |
|
75 | + * flag indicating that _construct_finalize has been called. |
|
76 | + * If it hasn't been called and we try to use functions which require it, we call it |
|
77 | + * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
78 | + * |
|
79 | + * @var boolean |
|
80 | + */ |
|
81 | + protected $_construction_finalized; |
|
82 | + |
|
83 | + /** |
|
84 | + * Strategy for parsing the form HTML upon display |
|
85 | + * |
|
86 | + * @var FormHtmlFilter |
|
87 | + */ |
|
88 | + protected $_form_html_filter; |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param array $options_array { |
|
94 | + * @type $name string the name for this form section, if you want to explicitly define it |
|
95 | + * } |
|
96 | + */ |
|
97 | + public function __construct($options_array = array()) |
|
98 | + { |
|
99 | + // used by display strategies |
|
100 | + // assign incoming values to properties |
|
101 | + foreach ($options_array as $key => $value) { |
|
102 | + $key = '_' . $key; |
|
103 | + if (property_exists($this, $key) && empty($this->{$key})) { |
|
104 | + $this->{$key} = $value; |
|
105 | + } |
|
106 | + } |
|
107 | + // set parser which allows the form section's rendered HTML to be filtered |
|
108 | + if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
109 | + $this->_form_html_filter = $options_array['form_html_filter']; |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @param $parent_form_section |
|
117 | + * @param $name |
|
118 | + * @throws \EE_Error |
|
119 | + */ |
|
120 | + protected function _construct_finalize($parent_form_section, $name) |
|
121 | + { |
|
122 | + $this->_construction_finalized = true; |
|
123 | + $this->_parent_section = $parent_form_section; |
|
124 | + if ($name !== null) { |
|
125 | + $this->_name = $name; |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * make sure construction finalized was called, otherwise children might not be ready |
|
133 | + * |
|
134 | + * @return void |
|
135 | + * @throws \EE_Error |
|
136 | + */ |
|
137 | + public function ensure_construct_finalized_called() |
|
138 | + { |
|
139 | + if (! $this->_construction_finalized) { |
|
140 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function action() |
|
150 | + { |
|
151 | + return $this->_action; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $action |
|
158 | + */ |
|
159 | + public function set_action($action) |
|
160 | + { |
|
161 | + $this->_action = $action; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + public function method() |
|
170 | + { |
|
171 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $method |
|
178 | + */ |
|
179 | + public function set_method($method) |
|
180 | + { |
|
181 | + switch ($method) { |
|
182 | + case 'get' : |
|
183 | + case 'GET' : |
|
184 | + $this->_method = 'GET'; |
|
185 | + break; |
|
186 | + default : |
|
187 | + $this->_method = 'POST'; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Sets the html_id to its default value, if none was specified in the constructor. |
|
195 | + * Calculation involves using the name and the parent's html id |
|
196 | + * return void |
|
197 | + * |
|
198 | + * @throws \EE_Error |
|
199 | + */ |
|
200 | + protected function _set_default_html_id_if_empty() |
|
201 | + { |
|
202 | + if (! $this->_html_id) { |
|
203 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
204 | + $this->_html_id = $this->_parent_section->html_id() |
|
205 | + . '-' |
|
206 | + . $this->_prep_name_for_html_id($this->name()); |
|
207 | + } else { |
|
208 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * _prep_name_for_html_id |
|
217 | + * |
|
218 | + * @param $name |
|
219 | + * @return string |
|
220 | + */ |
|
221 | + private function _prep_name_for_html_id($name) |
|
222 | + { |
|
223 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
230 | - * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
231 | - * and call get_html when you want to output the html. Calling get_html_and_js after |
|
232 | - * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
233 | - * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
234 | - * and so might stop working anytime. |
|
235 | - * |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - public function get_html_and_js() |
|
239 | - { |
|
240 | - return $this->get_html(); |
|
241 | - } |
|
228 | + /** |
|
229 | + * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
230 | + * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
231 | + * and call get_html when you want to output the html. Calling get_html_and_js after |
|
232 | + * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
233 | + * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
234 | + * and so might stop working anytime. |
|
235 | + * |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + public function get_html_and_js() |
|
239 | + { |
|
240 | + return $this->get_html(); |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | 244 | |
245 | - /** |
|
246 | - * Gets the HTML for displaying this form section |
|
247 | - * |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public abstract function get_html(); |
|
245 | + /** |
|
246 | + * Gets the HTML for displaying this form section |
|
247 | + * |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public abstract function get_html(); |
|
251 | 251 | |
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * @param bool $add_pound_sign |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - public function html_id($add_pound_sign = false) |
|
259 | - { |
|
260 | - $this->_set_default_html_id_if_empty(); |
|
261 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
262 | - } |
|
254 | + /** |
|
255 | + * @param bool $add_pound_sign |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + public function html_id($add_pound_sign = false) |
|
259 | + { |
|
260 | + $this->_set_default_html_id_if_empty(); |
|
261 | + return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
262 | + } |
|
263 | 263 | |
264 | 264 | |
265 | - |
|
266 | - /** |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public function html_class() |
|
270 | - { |
|
271 | - return $this->_html_class; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - public function html_style() |
|
280 | - { |
|
281 | - return $this->_html_style; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @param mixed $html_class |
|
288 | - */ |
|
289 | - public function set_html_class($html_class) |
|
290 | - { |
|
291 | - $this->_html_class = $html_class; |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - |
|
296 | - /** |
|
297 | - * @param mixed $html_id |
|
298 | - */ |
|
299 | - public function set_html_id($html_id) |
|
300 | - { |
|
301 | - $this->_html_id = $html_id; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * @param mixed $html_style |
|
308 | - */ |
|
309 | - public function set_html_style($html_style) |
|
310 | - { |
|
311 | - $this->_html_style = $html_style; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param string $other_html_attributes |
|
318 | - */ |
|
319 | - public function set_other_html_attributes($other_html_attributes) |
|
320 | - { |
|
321 | - $this->_other_html_attributes = $other_html_attributes; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function other_html_attributes() |
|
330 | - { |
|
331 | - return $this->_other_html_attributes; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * Gets the name of the form section. This is not the same as the HTML name. |
|
338 | - * |
|
339 | - * @throws EE_Error |
|
340 | - * @return string |
|
341 | - */ |
|
342 | - public function name() |
|
343 | - { |
|
344 | - if (! $this->_construction_finalized) { |
|
345 | - throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | - 'event_espresso'), get_class($this))); |
|
347 | - } |
|
348 | - return $this->_name; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * Gets the parent section |
|
355 | - * |
|
356 | - * @return EE_Form_Section_Proper |
|
357 | - */ |
|
358 | - public function parent_section() |
|
359 | - { |
|
360 | - return $this->_parent_section; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | - * |
|
368 | - * @param string $action the URL the form is submitted to |
|
369 | - * @param string $method POST (default) or GET |
|
370 | - * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | - * @return string |
|
372 | - */ |
|
373 | - public function form_open($action = '', $method = '', $other_attributes = '') |
|
374 | - { |
|
375 | - if (! empty($action)) { |
|
376 | - $this->set_action($action); |
|
377 | - } |
|
378 | - if (! empty($method)) { |
|
379 | - $this->set_method($method); |
|
380 | - } |
|
381 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | - $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
383 | - $html .= ' action="' . $this->action() . '"'; |
|
384 | - $html .= ' method="' . $this->method() . '"'; |
|
385 | - $html .= $other_attributes . '>'; |
|
386 | - return $html; |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * ensures that html id for form either ends in "-form" or "-frm" |
|
393 | - * so that id doesn't conflict/collide with other elements |
|
394 | - * |
|
395 | - * @param string $html_id |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - protected function get_html_id_for_form($html_id) |
|
399 | - { |
|
400 | - $strlen = strlen($html_id); |
|
401 | - $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
402 | - ? $html_id |
|
403 | - : $html_id . '-frm'; |
|
404 | - return $html_id; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * returns HTML for generating the closing form HTML tag (</form>) |
|
411 | - * |
|
412 | - * @return string |
|
413 | - */ |
|
414 | - public function form_close() |
|
415 | - { |
|
416 | - return EEH_HTML::nl(-1, 'form') |
|
417 | - . '</form>' |
|
418 | - . EEH_HTML::nl() |
|
419 | - . '<!-- end of ee-' |
|
420 | - . $this->html_id() |
|
421 | - . '-form -->' |
|
422 | - . EEH_HTML::nl(); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
429 | - * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
430 | - * Default does nothing, but child classes can override |
|
431 | - * |
|
432 | - * @return void |
|
433 | - */ |
|
434 | - public function enqueue_js() |
|
435 | - { |
|
436 | - //defaults to enqueue NO js or css |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
443 | - * with it, and it will be on each form section's 'other_data' property. |
|
444 | - * By default nothing is added, but child classes can extend this method to add something. |
|
445 | - * Eg, if you have an input that will cause a modal dialog to appear, |
|
446 | - * here you could add an entry like 'modal_dialog_inputs' to this array |
|
447 | - * to map between the input's html ID and the modal dialogue's ID, so that |
|
448 | - * your JS code will know where to find the modal dialog when the input is pressed. |
|
449 | - * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
450 | - * |
|
451 | - * @param array $form_other_js_data |
|
452 | - * @return array |
|
453 | - */ |
|
454 | - public function get_other_js_data($form_other_js_data = array()) |
|
455 | - { |
|
456 | - return $form_other_js_data; |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * This isn't just the name of an input, it's a path pointing to an input. The |
|
463 | - * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
464 | - * dot-dot-slash (../) means to ascend into the parent section. |
|
465 | - * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
466 | - * which will be returned. |
|
467 | - * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
468 | - * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
469 | - * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
470 | - * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
471 | - * Etc |
|
472 | - * |
|
473 | - * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
474 | - * @return EE_Form_Section_Base |
|
475 | - */ |
|
476 | - public function find_section_from_path($form_section_path) |
|
477 | - { |
|
478 | - if (strpos($form_section_path, '/') === 0) { |
|
479 | - $form_section_path = substr($form_section_path, strlen('/')); |
|
480 | - } |
|
481 | - if (empty($form_section_path)) { |
|
482 | - return $this; |
|
483 | - } |
|
484 | - if (strpos($form_section_path, '../') === 0) { |
|
485 | - $parent = $this->parent_section(); |
|
486 | - $form_section_path = substr($form_section_path, strlen('../')); |
|
487 | - if ($parent instanceof EE_Form_Section_Base) { |
|
488 | - return $parent->find_section_from_path($form_section_path); |
|
489 | - } elseif (empty($form_section_path)) { |
|
490 | - return $this; |
|
491 | - } |
|
492 | - } |
|
493 | - //couldn't find it using simple parent following |
|
494 | - return null; |
|
495 | - } |
|
265 | + |
|
266 | + /** |
|
267 | + * @return string |
|
268 | + */ |
|
269 | + public function html_class() |
|
270 | + { |
|
271 | + return $this->_html_class; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + public function html_style() |
|
280 | + { |
|
281 | + return $this->_html_style; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @param mixed $html_class |
|
288 | + */ |
|
289 | + public function set_html_class($html_class) |
|
290 | + { |
|
291 | + $this->_html_class = $html_class; |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + |
|
296 | + /** |
|
297 | + * @param mixed $html_id |
|
298 | + */ |
|
299 | + public function set_html_id($html_id) |
|
300 | + { |
|
301 | + $this->_html_id = $html_id; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * @param mixed $html_style |
|
308 | + */ |
|
309 | + public function set_html_style($html_style) |
|
310 | + { |
|
311 | + $this->_html_style = $html_style; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param string $other_html_attributes |
|
318 | + */ |
|
319 | + public function set_other_html_attributes($other_html_attributes) |
|
320 | + { |
|
321 | + $this->_other_html_attributes = $other_html_attributes; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function other_html_attributes() |
|
330 | + { |
|
331 | + return $this->_other_html_attributes; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * Gets the name of the form section. This is not the same as the HTML name. |
|
338 | + * |
|
339 | + * @throws EE_Error |
|
340 | + * @return string |
|
341 | + */ |
|
342 | + public function name() |
|
343 | + { |
|
344 | + if (! $this->_construction_finalized) { |
|
345 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | + 'event_espresso'), get_class($this))); |
|
347 | + } |
|
348 | + return $this->_name; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * Gets the parent section |
|
355 | + * |
|
356 | + * @return EE_Form_Section_Proper |
|
357 | + */ |
|
358 | + public function parent_section() |
|
359 | + { |
|
360 | + return $this->_parent_section; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | + * |
|
368 | + * @param string $action the URL the form is submitted to |
|
369 | + * @param string $method POST (default) or GET |
|
370 | + * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | + * @return string |
|
372 | + */ |
|
373 | + public function form_open($action = '', $method = '', $other_attributes = '') |
|
374 | + { |
|
375 | + if (! empty($action)) { |
|
376 | + $this->set_action($action); |
|
377 | + } |
|
378 | + if (! empty($method)) { |
|
379 | + $this->set_method($method); |
|
380 | + } |
|
381 | + $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | + $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
383 | + $html .= ' action="' . $this->action() . '"'; |
|
384 | + $html .= ' method="' . $this->method() . '"'; |
|
385 | + $html .= $other_attributes . '>'; |
|
386 | + return $html; |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * ensures that html id for form either ends in "-form" or "-frm" |
|
393 | + * so that id doesn't conflict/collide with other elements |
|
394 | + * |
|
395 | + * @param string $html_id |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + protected function get_html_id_for_form($html_id) |
|
399 | + { |
|
400 | + $strlen = strlen($html_id); |
|
401 | + $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
402 | + ? $html_id |
|
403 | + : $html_id . '-frm'; |
|
404 | + return $html_id; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * returns HTML for generating the closing form HTML tag (</form>) |
|
411 | + * |
|
412 | + * @return string |
|
413 | + */ |
|
414 | + public function form_close() |
|
415 | + { |
|
416 | + return EEH_HTML::nl(-1, 'form') |
|
417 | + . '</form>' |
|
418 | + . EEH_HTML::nl() |
|
419 | + . '<!-- end of ee-' |
|
420 | + . $this->html_id() |
|
421 | + . '-form -->' |
|
422 | + . EEH_HTML::nl(); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
429 | + * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
430 | + * Default does nothing, but child classes can override |
|
431 | + * |
|
432 | + * @return void |
|
433 | + */ |
|
434 | + public function enqueue_js() |
|
435 | + { |
|
436 | + //defaults to enqueue NO js or css |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
443 | + * with it, and it will be on each form section's 'other_data' property. |
|
444 | + * By default nothing is added, but child classes can extend this method to add something. |
|
445 | + * Eg, if you have an input that will cause a modal dialog to appear, |
|
446 | + * here you could add an entry like 'modal_dialog_inputs' to this array |
|
447 | + * to map between the input's html ID and the modal dialogue's ID, so that |
|
448 | + * your JS code will know where to find the modal dialog when the input is pressed. |
|
449 | + * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
450 | + * |
|
451 | + * @param array $form_other_js_data |
|
452 | + * @return array |
|
453 | + */ |
|
454 | + public function get_other_js_data($form_other_js_data = array()) |
|
455 | + { |
|
456 | + return $form_other_js_data; |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * This isn't just the name of an input, it's a path pointing to an input. The |
|
463 | + * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
464 | + * dot-dot-slash (../) means to ascend into the parent section. |
|
465 | + * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
466 | + * which will be returned. |
|
467 | + * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
468 | + * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
469 | + * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
470 | + * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
471 | + * Etc |
|
472 | + * |
|
473 | + * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
474 | + * @return EE_Form_Section_Base |
|
475 | + */ |
|
476 | + public function find_section_from_path($form_section_path) |
|
477 | + { |
|
478 | + if (strpos($form_section_path, '/') === 0) { |
|
479 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
480 | + } |
|
481 | + if (empty($form_section_path)) { |
|
482 | + return $this; |
|
483 | + } |
|
484 | + if (strpos($form_section_path, '../') === 0) { |
|
485 | + $parent = $this->parent_section(); |
|
486 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
487 | + if ($parent instanceof EE_Form_Section_Base) { |
|
488 | + return $parent->find_section_from_path($form_section_path); |
|
489 | + } elseif (empty($form_section_path)) { |
|
490 | + return $this; |
|
491 | + } |
|
492 | + } |
|
493 | + //couldn't find it using simple parent following |
|
494 | + return null; |
|
495 | + } |
|
496 | 496 | |
497 | 497 | |
498 | 498 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter; |
3 | 3 | |
4 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | 5 | exit('No direct script access allowed'); |
6 | 6 | } |
7 | 7 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // used by display strategies |
100 | 100 | // assign incoming values to properties |
101 | 101 | foreach ($options_array as $key => $value) { |
102 | - $key = '_' . $key; |
|
102 | + $key = '_'.$key; |
|
103 | 103 | if (property_exists($this, $key) && empty($this->{$key})) { |
104 | 104 | $this->{$key} = $value; |
105 | 105 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function ensure_construct_finalized_called() |
138 | 138 | { |
139 | - if (! $this->_construction_finalized) { |
|
139 | + if ( ! $this->_construction_finalized) { |
|
140 | 140 | $this->_construct_finalize($this->_parent_section, $this->_name); |
141 | 141 | } |
142 | 142 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function _set_default_html_id_if_empty() |
201 | 201 | { |
202 | - if (! $this->_html_id) { |
|
202 | + if ( ! $this->_html_id) { |
|
203 | 203 | if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
204 | 204 | $this->_html_id = $this->_parent_section->html_id() |
205 | 205 | . '-' |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | public function html_id($add_pound_sign = false) |
259 | 259 | { |
260 | 260 | $this->_set_default_html_id_if_empty(); |
261 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
261 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function name() |
343 | 343 | { |
344 | - if (! $this->_construction_finalized) { |
|
344 | + if ( ! $this->_construction_finalized) { |
|
345 | 345 | throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
346 | 346 | 'event_espresso'), get_class($this))); |
347 | 347 | } |
@@ -372,17 +372,17 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function form_open($action = '', $method = '', $other_attributes = '') |
374 | 374 | { |
375 | - if (! empty($action)) { |
|
375 | + if ( ! empty($action)) { |
|
376 | 376 | $this->set_action($action); |
377 | 377 | } |
378 | - if (! empty($method)) { |
|
378 | + if ( ! empty($method)) { |
|
379 | 379 | $this->set_method($method); |
380 | 380 | } |
381 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | - $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
383 | - $html .= ' action="' . $this->action() . '"'; |
|
384 | - $html .= ' method="' . $this->method() . '"'; |
|
385 | - $html .= $other_attributes . '>'; |
|
381 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
382 | + $html .= $this->html_id() !== '' ? ' id="'.$this->get_html_id_for_form($this->html_id()).'"' : ''; |
|
383 | + $html .= ' action="'.$this->action().'"'; |
|
384 | + $html .= ' method="'.$this->method().'"'; |
|
385 | + $html .= $other_attributes.'>'; |
|
386 | 386 | return $html; |
387 | 387 | } |
388 | 388 | |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | protected function get_html_id_for_form($html_id) |
399 | 399 | { |
400 | 400 | $strlen = strlen($html_id); |
401 | - $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
401 | + $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4 |
|
402 | 402 | ? $html_id |
403 | - : $html_id . '-frm'; |
|
403 | + : $html_id.'-frm'; |
|
404 | 404 | return $html_id; |
405 | 405 | } |
406 | 406 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\services\commands\middleware\InvalidCommandBusMiddlewareException; |
8 | 8 | |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -40,78 +40,78 @@ discard block |
||
40 | 40 | class CommandBus implements CommandBusInterface |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * @type CommandHandlerManagerInterface $command_handler_manager |
|
45 | - */ |
|
46 | - private $command_handler_manager; |
|
47 | - |
|
48 | - /** |
|
49 | - * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
50 | - */ |
|
51 | - private $command_bus_middleware; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * CommandBus constructor |
|
57 | - * |
|
58 | - * @param CommandHandlerManagerInterface $command_handler_manager |
|
59 | - * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - CommandHandlerManagerInterface $command_handler_manager, |
|
63 | - array $command_bus_middleware = array() |
|
64 | - ) { |
|
65 | - $this->command_handler_manager = $command_handler_manager; |
|
66 | - $this->command_bus_middleware = is_array($command_bus_middleware) |
|
67 | - ? $command_bus_middleware |
|
68 | - : array($command_bus_middleware); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @return CommandHandlerManagerInterface |
|
75 | - */ |
|
76 | - public function getCommandHandlerManager() |
|
77 | - { |
|
78 | - return $this->command_handler_manager; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @param CommandInterface $command |
|
85 | - * @return mixed |
|
86 | - * @throws InvalidDataTypeException |
|
87 | - * @throws InvalidCommandBusMiddlewareException |
|
88 | - */ |
|
89 | - public function execute($command) |
|
90 | - { |
|
91 | - if (! $command instanceof CommandInterface) { |
|
92 | - throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
93 | - } |
|
94 | - // we're going to add the Command Handler as a callable |
|
95 | - // that will get run at the end of our middleware stack |
|
96 | - // can't pass $this to a Closure, so use a named variable |
|
97 | - $command_bus = $this; |
|
98 | - $middleware = function ($command) use ($command_bus) { |
|
99 | - return $command_bus->getCommandHandlerManager() |
|
100 | - ->getCommandHandler($command, $command_bus) |
|
101 | - ->handle($command); |
|
102 | - }; |
|
103 | - // now build the rest of the middleware stack |
|
104 | - while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
105 | - if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
106 | - throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
107 | - } |
|
108 | - $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
109 | - return $command_bus_middleware->handle($command, $middleware); |
|
110 | - }; |
|
111 | - } |
|
112 | - // and finally, pass the command into the stack and return the results |
|
113 | - return $middleware($command); |
|
114 | - } |
|
43 | + /** |
|
44 | + * @type CommandHandlerManagerInterface $command_handler_manager |
|
45 | + */ |
|
46 | + private $command_handler_manager; |
|
47 | + |
|
48 | + /** |
|
49 | + * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
50 | + */ |
|
51 | + private $command_bus_middleware; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * CommandBus constructor |
|
57 | + * |
|
58 | + * @param CommandHandlerManagerInterface $command_handler_manager |
|
59 | + * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + CommandHandlerManagerInterface $command_handler_manager, |
|
63 | + array $command_bus_middleware = array() |
|
64 | + ) { |
|
65 | + $this->command_handler_manager = $command_handler_manager; |
|
66 | + $this->command_bus_middleware = is_array($command_bus_middleware) |
|
67 | + ? $command_bus_middleware |
|
68 | + : array($command_bus_middleware); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @return CommandHandlerManagerInterface |
|
75 | + */ |
|
76 | + public function getCommandHandlerManager() |
|
77 | + { |
|
78 | + return $this->command_handler_manager; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @param CommandInterface $command |
|
85 | + * @return mixed |
|
86 | + * @throws InvalidDataTypeException |
|
87 | + * @throws InvalidCommandBusMiddlewareException |
|
88 | + */ |
|
89 | + public function execute($command) |
|
90 | + { |
|
91 | + if (! $command instanceof CommandInterface) { |
|
92 | + throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
93 | + } |
|
94 | + // we're going to add the Command Handler as a callable |
|
95 | + // that will get run at the end of our middleware stack |
|
96 | + // can't pass $this to a Closure, so use a named variable |
|
97 | + $command_bus = $this; |
|
98 | + $middleware = function ($command) use ($command_bus) { |
|
99 | + return $command_bus->getCommandHandlerManager() |
|
100 | + ->getCommandHandler($command, $command_bus) |
|
101 | + ->handle($command); |
|
102 | + }; |
|
103 | + // now build the rest of the middleware stack |
|
104 | + while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
105 | + if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
106 | + throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
107 | + } |
|
108 | + $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
109 | + return $command_bus_middleware->handle($command, $middleware); |
|
110 | + }; |
|
111 | + } |
|
112 | + // and finally, pass the command into the stack and return the results |
|
113 | + return $middleware($command); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | } |
@@ -18,151 +18,151 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @var NoticeInterface[] $attention |
|
23 | - */ |
|
24 | - private $attention = array(); |
|
21 | + /** |
|
22 | + * @var NoticeInterface[] $attention |
|
23 | + */ |
|
24 | + private $attention = array(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @var NoticeInterface[] $error |
|
29 | - */ |
|
30 | - private $error = array(); |
|
27 | + /** |
|
28 | + * @var NoticeInterface[] $error |
|
29 | + */ |
|
30 | + private $error = array(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @var NoticeInterface[] $success |
|
35 | - */ |
|
36 | - private $success = array(); |
|
33 | + /** |
|
34 | + * @var NoticeInterface[] $success |
|
35 | + */ |
|
36 | + private $success = array(); |
|
37 | 37 | |
38 | 38 | |
39 | 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 | - } |
|
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 | 50 | |
51 | 51 | |
52 | 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 | - } |
|
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 | 63 | |
64 | 64 | |
65 | 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 | - } |
|
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 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return boolean |
|
81 | - */ |
|
82 | - public function hasAttention() |
|
83 | - { |
|
84 | - return ! empty($this->attention); |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return boolean |
|
81 | + */ |
|
82 | + public function hasAttention() |
|
83 | + { |
|
84 | + return ! empty($this->attention); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return boolean |
|
91 | - */ |
|
92 | - public function hasError() |
|
93 | - { |
|
94 | - return ! empty($this->error); |
|
95 | - } |
|
89 | + /** |
|
90 | + * @return boolean |
|
91 | + */ |
|
92 | + public function hasError() |
|
93 | + { |
|
94 | + return ! empty($this->error); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * @return boolean |
|
101 | - */ |
|
102 | - public function hasSuccess() |
|
103 | - { |
|
104 | - return ! empty($this->success); |
|
105 | - } |
|
99 | + /** |
|
100 | + * @return boolean |
|
101 | + */ |
|
102 | + public function hasSuccess() |
|
103 | + { |
|
104 | + return ! empty($this->success); |
|
105 | + } |
|
106 | 106 | |
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * @return int |
|
111 | - */ |
|
112 | - public function countAttention() |
|
113 | - { |
|
114 | - return count($this->attention); |
|
115 | - } |
|
109 | + /** |
|
110 | + * @return int |
|
111 | + */ |
|
112 | + public function countAttention() |
|
113 | + { |
|
114 | + return count($this->attention); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function countError() |
|
123 | - { |
|
124 | - return count($this->error); |
|
125 | - } |
|
119 | + /** |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function countError() |
|
123 | + { |
|
124 | + return count($this->error); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | 128 | |
129 | - /** |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function countSuccess() |
|
133 | - { |
|
134 | - return count($this->success); |
|
135 | - } |
|
129 | + /** |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function countSuccess() |
|
133 | + { |
|
134 | + return count($this->success); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * @return NoticeInterface[] |
|
141 | - */ |
|
142 | - public function getAttention() |
|
143 | - { |
|
144 | - return $this->attention; |
|
145 | - } |
|
139 | + /** |
|
140 | + * @return NoticeInterface[] |
|
141 | + */ |
|
142 | + public function getAttention() |
|
143 | + { |
|
144 | + return $this->attention; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
149 | - /** |
|
150 | - * @return NoticeInterface[] |
|
151 | - */ |
|
152 | - public function getError() |
|
153 | - { |
|
154 | - return $this->error; |
|
155 | - } |
|
149 | + /** |
|
150 | + * @return NoticeInterface[] |
|
151 | + */ |
|
152 | + public function getError() |
|
153 | + { |
|
154 | + return $this->error; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | 158 | |
159 | - /** |
|
160 | - * @return NoticeInterface[] |
|
161 | - */ |
|
162 | - public function getSuccess() |
|
163 | - { |
|
164 | - return $this->success; |
|
165 | - } |
|
159 | + /** |
|
160 | + * @return NoticeInterface[] |
|
161 | + */ |
|
162 | + public function getSuccess() |
|
163 | + { |
|
164 | + return $this->success; |
|
165 | + } |
|
166 | 166 | |
167 | 167 | |
168 | 168 | } |
@@ -17,108 +17,108 @@ |
||
17 | 17 | class Notice implements NoticeInterface |
18 | 18 | { |
19 | 19 | |
20 | - const ERROR = 'error'; |
|
21 | - const ATTENTION = 'attention'; |
|
22 | - const SUCCESS = 'success'; |
|
20 | + const ERROR = 'error'; |
|
21 | + const ATTENTION = 'attention'; |
|
22 | + const SUCCESS = 'success'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var string $type |
|
26 | - */ |
|
27 | - private $type; |
|
24 | + /** |
|
25 | + * @var string $type |
|
26 | + */ |
|
27 | + private $type; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @var string $message |
|
32 | - */ |
|
33 | - private $message; |
|
30 | + /** |
|
31 | + * @var string $message |
|
32 | + */ |
|
33 | + private $message; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @var string $file |
|
38 | - */ |
|
39 | - private $file; |
|
36 | + /** |
|
37 | + * @var string $file |
|
38 | + */ |
|
39 | + private $file; |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @var string $func |
|
44 | - */ |
|
45 | - private $func; |
|
42 | + /** |
|
43 | + * @var string $func |
|
44 | + */ |
|
45 | + private $func; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @var string $line |
|
50 | - */ |
|
51 | - private $line; |
|
48 | + /** |
|
49 | + * @var string $line |
|
50 | + */ |
|
51 | + private $line; |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Notice constructor. |
|
57 | - * |
|
58 | - * @param string $type |
|
59 | - * @param string $message |
|
60 | - * @param string $file |
|
61 | - * @param string $func |
|
62 | - * @param string $line |
|
63 | - */ |
|
64 | - public function __construct($type, $message, $file, $func, $line) |
|
65 | - { |
|
66 | - $this->type = $type; |
|
67 | - $this->message = $message; |
|
68 | - $this->file = $file; |
|
69 | - $this->func = $func; |
|
70 | - $this->line = $line; |
|
71 | - } |
|
55 | + /** |
|
56 | + * Notice constructor. |
|
57 | + * |
|
58 | + * @param string $type |
|
59 | + * @param string $message |
|
60 | + * @param string $file |
|
61 | + * @param string $func |
|
62 | + * @param string $line |
|
63 | + */ |
|
64 | + public function __construct($type, $message, $file, $func, $line) |
|
65 | + { |
|
66 | + $this->type = $type; |
|
67 | + $this->message = $message; |
|
68 | + $this->file = $file; |
|
69 | + $this->func = $func; |
|
70 | + $this->line = $line; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function type() |
|
79 | - { |
|
80 | - return $this->type; |
|
81 | - } |
|
75 | + /** |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function type() |
|
79 | + { |
|
80 | + return $this->type; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function message() |
|
89 | - { |
|
90 | - return $this->message; |
|
91 | - } |
|
85 | + /** |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function message() |
|
89 | + { |
|
90 | + return $this->message; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function file() |
|
99 | - { |
|
100 | - return $this->file; |
|
101 | - } |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function file() |
|
99 | + { |
|
100 | + return $this->file; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function func() |
|
109 | - { |
|
110 | - return $this->func; |
|
111 | - } |
|
105 | + /** |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function func() |
|
109 | + { |
|
110 | + return $this->func; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | 114 | |
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function line() |
|
119 | - { |
|
120 | - return $this->line; |
|
121 | - } |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function line() |
|
119 | + { |
|
120 | + return $this->line; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | 124 |
@@ -16,94 +16,94 @@ |
||
16 | 16 | interface NoticesContainerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $notice |
|
21 | - * @param string $file |
|
22 | - * @param string $func |
|
23 | - * @param string $line |
|
24 | - */ |
|
25 | - public function addAttention($notice, $file = '', $func = '', $line = ''); |
|
19 | + /** |
|
20 | + * @param string $notice |
|
21 | + * @param string $file |
|
22 | + * @param string $func |
|
23 | + * @param string $line |
|
24 | + */ |
|
25 | + public function addAttention($notice, $file = '', $func = '', $line = ''); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param string $notice |
|
31 | - * @param string $file |
|
32 | - * @param string $func |
|
33 | - * @param string $line |
|
34 | - */ |
|
35 | - public function addError($notice, $file, $func, $line); |
|
29 | + /** |
|
30 | + * @param string $notice |
|
31 | + * @param string $file |
|
32 | + * @param string $func |
|
33 | + * @param string $line |
|
34 | + */ |
|
35 | + public function addError($notice, $file, $func, $line); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param string $notice |
|
41 | - * @param string $file |
|
42 | - * @param string $func |
|
43 | - * @param string $line |
|
44 | - */ |
|
45 | - public function addSuccess($notice, $file = '', $func = '', $line = ''); |
|
39 | + /** |
|
40 | + * @param string $notice |
|
41 | + * @param string $file |
|
42 | + * @param string $func |
|
43 | + * @param string $line |
|
44 | + */ |
|
45 | + public function addSuccess($notice, $file = '', $func = '', $line = ''); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @return boolean |
|
51 | - */ |
|
52 | - public function hasAttention(); |
|
49 | + /** |
|
50 | + * @return boolean |
|
51 | + */ |
|
52 | + public function hasAttention(); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @return boolean |
|
58 | - */ |
|
59 | - public function hasError(); |
|
56 | + /** |
|
57 | + * @return boolean |
|
58 | + */ |
|
59 | + public function hasError(); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function hasSuccess(); |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function hasSuccess(); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @return int |
|
72 | - */ |
|
73 | - public function countAttention(); |
|
70 | + /** |
|
71 | + * @return int |
|
72 | + */ |
|
73 | + public function countAttention(); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return int |
|
79 | - */ |
|
80 | - public function countError(); |
|
77 | + /** |
|
78 | + * @return int |
|
79 | + */ |
|
80 | + public function countError(); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return int |
|
86 | - */ |
|
87 | - public function countSuccess(); |
|
84 | + /** |
|
85 | + * @return int |
|
86 | + */ |
|
87 | + public function countSuccess(); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return NoticeInterface[] |
|
93 | - */ |
|
94 | - public function getAttention(); |
|
91 | + /** |
|
92 | + * @return NoticeInterface[] |
|
93 | + */ |
|
94 | + public function getAttention(); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return NoticeInterface[] |
|
100 | - */ |
|
101 | - public function getError(); |
|
98 | + /** |
|
99 | + * @return NoticeInterface[] |
|
100 | + */ |
|
101 | + public function getError(); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return NoticeInterface[] |
|
107 | - */ |
|
108 | - public function getSuccess(); |
|
105 | + /** |
|
106 | + * @return NoticeInterface[] |
|
107 | + */ |
|
108 | + public function getSuccess(); |
|
109 | 109 | } |
110 | 110 | \ No newline at end of file |