@@ -29,121 +29,121 @@ |
||
29 | 29 | class RegFormFactory |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * legacy SPCO reg form |
|
34 | - */ |
|
35 | - const VERSION_1 = 'v1'; |
|
32 | + /** |
|
33 | + * legacy SPCO reg form |
|
34 | + */ |
|
35 | + const VERSION_1 = 'v1'; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Form Sections and Form Elements generated using Barista Form Builder |
|
39 | - */ |
|
40 | - const VERSION_2 = 'v2'; |
|
37 | + /** |
|
38 | + * Form Sections and Form Elements generated using Barista Form Builder |
|
39 | + */ |
|
40 | + const VERSION_2 = 'v2'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - private $reg_form_version; |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + private $reg_form_version; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * RegFormFactory constructor. |
|
50 | - * |
|
51 | - * @param string $reg_form_version |
|
52 | - */ |
|
53 | - public function __construct(string $reg_form_version = RegFormFactory::VERSION_1) |
|
54 | - { |
|
55 | - $this->reg_form_version = $reg_form_version; |
|
56 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 1); |
|
57 | - \EEH_Debug_Tools::printr($this->reg_form_version, '$this->reg_form_version', __FILE__, __LINE__); |
|
58 | - } |
|
48 | + /** |
|
49 | + * RegFormFactory constructor. |
|
50 | + * |
|
51 | + * @param string $reg_form_version |
|
52 | + */ |
|
53 | + public function __construct(string $reg_form_version = RegFormFactory::VERSION_1) |
|
54 | + { |
|
55 | + $this->reg_form_version = $reg_form_version; |
|
56 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 1); |
|
57 | + \EEH_Debug_Tools::printr($this->reg_form_version, '$this->reg_form_version', __FILE__, __LINE__); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @param array $dependencies |
|
63 | - * @return FormSectionProperInterface |
|
64 | - * @throws EE_Error |
|
65 | - * @throws ReflectionException |
|
66 | - */ |
|
67 | - public function getRegForm(array $dependencies): FormSectionProperInterface |
|
68 | - { |
|
69 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
70 | - $this->registerDependencies(); |
|
71 | - switch ($this->reg_form_version) { |
|
72 | - case RegFormFactory::VERSION_2: |
|
73 | - $reg_step = $dependencies[0]; |
|
74 | - if (! $reg_step instanceof EE_SPCO_Reg_Step) { |
|
75 | - throw new DomainException( |
|
76 | - esc_html__('Invalid or missing SPCO Registration Step', 'event_espresso') |
|
77 | - ); |
|
78 | - } |
|
79 | - /** @var FormSubmissionHandler $form_submission_handler */ |
|
80 | - $form_submission_handler = LoaderFactory::getNew( |
|
81 | - FormSubmissionHandler::class, |
|
82 | - [$reg_step->checkout->transaction] |
|
83 | - ); |
|
84 | - $form_data_api = $form_submission_handler->getFormDataAPI(); |
|
85 | - return LoaderFactory::getShared(RegFormV2::class, [$reg_step, $form_data_api]); |
|
86 | - case RegFormFactory::VERSION_1: |
|
87 | - default: |
|
88 | - return LoaderFactory::getShared(RegFormV1::class, $dependencies); |
|
89 | - } |
|
90 | - } |
|
61 | + /** |
|
62 | + * @param array $dependencies |
|
63 | + * @return FormSectionProperInterface |
|
64 | + * @throws EE_Error |
|
65 | + * @throws ReflectionException |
|
66 | + */ |
|
67 | + public function getRegForm(array $dependencies): FormSectionProperInterface |
|
68 | + { |
|
69 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
70 | + $this->registerDependencies(); |
|
71 | + switch ($this->reg_form_version) { |
|
72 | + case RegFormFactory::VERSION_2: |
|
73 | + $reg_step = $dependencies[0]; |
|
74 | + if (! $reg_step instanceof EE_SPCO_Reg_Step) { |
|
75 | + throw new DomainException( |
|
76 | + esc_html__('Invalid or missing SPCO Registration Step', 'event_espresso') |
|
77 | + ); |
|
78 | + } |
|
79 | + /** @var FormSubmissionHandler $form_submission_handler */ |
|
80 | + $form_submission_handler = LoaderFactory::getNew( |
|
81 | + FormSubmissionHandler::class, |
|
82 | + [$reg_step->checkout->transaction] |
|
83 | + ); |
|
84 | + $form_data_api = $form_submission_handler->getFormDataAPI(); |
|
85 | + return LoaderFactory::getShared(RegFormV2::class, [$reg_step, $form_data_api]); |
|
86 | + case RegFormFactory::VERSION_1: |
|
87 | + default: |
|
88 | + return LoaderFactory::getShared(RegFormV1::class, $dependencies); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @return void |
|
95 | - * @throws InvalidArgumentException |
|
96 | - */ |
|
97 | - private function registerDependencies() |
|
98 | - { |
|
99 | - switch ($this->reg_form_version) { |
|
100 | - case RegFormFactory::VERSION_1: |
|
101 | - /** @var RegFormDepHandlerV1 $dependency_handler */ |
|
102 | - $dependency_handler = LoaderFactory::getShared(RegFormDepHandlerV1::class); |
|
103 | - break; |
|
104 | - case RegFormFactory::VERSION_2: |
|
105 | - /** @var RegFormDepHandlerV2 $dependency_handler */ |
|
106 | - $dependency_handler = LoaderFactory::getShared(RegFormDepHandlerV2::class); |
|
107 | - break; |
|
108 | - default: |
|
109 | - throw new InvalidArgumentException( |
|
110 | - esc_html__( |
|
111 | - 'Invalid registration form version requested. Version number must match one of the RegFormFactory::VERSION_* constants.', |
|
112 | - 'event_espresso' |
|
113 | - ) |
|
114 | - ); |
|
115 | - } |
|
116 | - if (! $dependency_handler instanceof DependencyHandler) { |
|
117 | - throw new DomainException( |
|
118 | - esc_html__('Invalid Registration Form DependencyHandler.', 'event_espresso') |
|
119 | - ); |
|
120 | - } |
|
121 | - $dependency_handler->registerDependencies(); |
|
122 | - } |
|
93 | + /** |
|
94 | + * @return void |
|
95 | + * @throws InvalidArgumentException |
|
96 | + */ |
|
97 | + private function registerDependencies() |
|
98 | + { |
|
99 | + switch ($this->reg_form_version) { |
|
100 | + case RegFormFactory::VERSION_1: |
|
101 | + /** @var RegFormDepHandlerV1 $dependency_handler */ |
|
102 | + $dependency_handler = LoaderFactory::getShared(RegFormDepHandlerV1::class); |
|
103 | + break; |
|
104 | + case RegFormFactory::VERSION_2: |
|
105 | + /** @var RegFormDepHandlerV2 $dependency_handler */ |
|
106 | + $dependency_handler = LoaderFactory::getShared(RegFormDepHandlerV2::class); |
|
107 | + break; |
|
108 | + default: |
|
109 | + throw new InvalidArgumentException( |
|
110 | + esc_html__( |
|
111 | + 'Invalid registration form version requested. Version number must match one of the RegFormFactory::VERSION_* constants.', |
|
112 | + 'event_espresso' |
|
113 | + ) |
|
114 | + ); |
|
115 | + } |
|
116 | + if (! $dependency_handler instanceof DependencyHandler) { |
|
117 | + throw new DomainException( |
|
118 | + esc_html__('Invalid Registration Form DependencyHandler.', 'event_espresso') |
|
119 | + ); |
|
120 | + } |
|
121 | + $dependency_handler->registerDependencies(); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * @param EE_Checkout $checkout |
|
127 | - * @return RegFormHandlerInterface |
|
128 | - * @throws EE_Error |
|
129 | - * @throws ReflectionException |
|
130 | - */ |
|
131 | - public function getRegFormHandler(EE_Checkout $checkout): RegFormHandlerInterface |
|
132 | - { |
|
133 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
134 | - switch ($this->reg_form_version) { |
|
135 | - case RegFormFactory::VERSION_2: |
|
136 | - /** @var RegFormHandlerV2 $handler */ |
|
137 | - $handler = LoaderFactory::getNew(RegFormHandlerV2::class, [$checkout]); |
|
138 | - $handler->getFormSubmission(); |
|
139 | - $handler->initializeInputHandler(); |
|
140 | - return $handler; |
|
141 | - case RegFormFactory::VERSION_1: |
|
142 | - default: |
|
143 | - /** @var RegFormHandlerV1 $handler */ |
|
144 | - $handler = LoaderFactory::getNew(RegFormHandlerV1::class, [$checkout]); |
|
145 | - $handler->initializeInputHandler(); |
|
146 | - return $handler; |
|
147 | - } |
|
148 | - } |
|
125 | + /** |
|
126 | + * @param EE_Checkout $checkout |
|
127 | + * @return RegFormHandlerInterface |
|
128 | + * @throws EE_Error |
|
129 | + * @throws ReflectionException |
|
130 | + */ |
|
131 | + public function getRegFormHandler(EE_Checkout $checkout): RegFormHandlerInterface |
|
132 | + { |
|
133 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
134 | + switch ($this->reg_form_version) { |
|
135 | + case RegFormFactory::VERSION_2: |
|
136 | + /** @var RegFormHandlerV2 $handler */ |
|
137 | + $handler = LoaderFactory::getNew(RegFormHandlerV2::class, [$checkout]); |
|
138 | + $handler->getFormSubmission(); |
|
139 | + $handler->initializeInputHandler(); |
|
140 | + return $handler; |
|
141 | + case RegFormFactory::VERSION_1: |
|
142 | + default: |
|
143 | + /** @var RegFormHandlerV1 $handler */ |
|
144 | + $handler = LoaderFactory::getNew(RegFormHandlerV1::class, [$checkout]); |
|
145 | + $handler->initializeInputHandler(); |
|
146 | + return $handler; |
|
147 | + } |
|
148 | + } |
|
149 | 149 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | switch ($this->reg_form_version) { |
72 | 72 | case RegFormFactory::VERSION_2: |
73 | 73 | $reg_step = $dependencies[0]; |
74 | - if (! $reg_step instanceof EE_SPCO_Reg_Step) { |
|
74 | + if ( ! $reg_step instanceof EE_SPCO_Reg_Step) { |
|
75 | 75 | throw new DomainException( |
76 | 76 | esc_html__('Invalid or missing SPCO Registration Step', 'event_espresso') |
77 | 77 | ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | FormSubmissionHandler::class, |
82 | 82 | [$reg_step->checkout->transaction] |
83 | 83 | ); |
84 | - $form_data_api = $form_submission_handler->getFormDataAPI(); |
|
84 | + $form_data_api = $form_submission_handler->getFormDataAPI(); |
|
85 | 85 | return LoaderFactory::getShared(RegFormV2::class, [$reg_step, $form_data_api]); |
86 | 86 | case RegFormFactory::VERSION_1: |
87 | 87 | default: |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | } |
116 | - if (! $dependency_handler instanceof DependencyHandler) { |
|
116 | + if ( ! $dependency_handler instanceof DependencyHandler) { |
|
117 | 117 | throw new DomainException( |
118 | 118 | esc_html__('Invalid Registration Form DependencyHandler.', 'event_espresso') |
119 | 119 | ); |
@@ -32,263 +32,263 @@ |
||
32 | 32 | abstract class RegForm extends EE_Form_Section_Proper implements FormSectionProperInterface |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
38 | - protected $print_copy_info = false; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var EE_Registration_Config |
|
42 | - */ |
|
43 | - public $reg_config; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var int |
|
47 | - */ |
|
48 | - protected $reg_form_count = 0; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var EE_SPCO_Reg_Step_Attendee_Information |
|
52 | - */ |
|
53 | - public $reg_step; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - protected $required_questions = []; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var array |
|
62 | - */ |
|
63 | - protected $template_args = []; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * RegForm constructor. |
|
68 | - * |
|
69 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
70 | - * @param EE_Registration_Config $reg_config |
|
71 | - * @throws ReflectionException |
|
72 | - * @throws EE_Error |
|
73 | - */ |
|
74 | - public function __construct( |
|
75 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
76 | - EE_Registration_Config $reg_config |
|
77 | - ) { |
|
78 | - $this->reg_step = $reg_step; |
|
79 | - $this->reg_config = $reg_config; |
|
80 | - // setup some classes so that they are ready for loading during construction of other classes |
|
81 | - LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
82 | - LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
83 | - parent::__construct( |
|
84 | - [ |
|
85 | - 'name' => $this->reg_step->reg_form_name(), |
|
86 | - 'html_id' => $this->reg_step->reg_form_name(), |
|
87 | - 'subsections' => $this->generateSubsections(), |
|
88 | - 'layout_strategy' => new EE_Template_Layout( |
|
89 | - [ |
|
90 | - 'layout_template_file' => $this->reg_step->template(), // layout_template |
|
91 | - 'template_args' => $this->template_args, |
|
92 | - ] |
|
93 | - ), |
|
94 | - ] |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @param EE_Registration $registration |
|
101 | - * @param bool $admin_request |
|
102 | - * @param bool $copy_attendee_info |
|
103 | - * @param callable $enablePrintCopyInfo |
|
104 | - * @return RegistrantFormInterface |
|
105 | - */ |
|
106 | - abstract protected function getRegistrantForm( |
|
107 | - EE_Registration $registration, |
|
108 | - bool $admin_request, |
|
109 | - bool $copy_attendee_info, |
|
110 | - callable $enablePrintCopyInfo |
|
111 | - ): RegistrantFormInterface; |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function enablePrintCopyInfo(): void |
|
118 | - { |
|
119 | - $this->print_copy_info = true; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return bool |
|
125 | - */ |
|
126 | - public function printCopyInfo(): bool |
|
127 | - { |
|
128 | - return $this->print_copy_info; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @return int |
|
134 | - */ |
|
135 | - public function regFormCount(): int |
|
136 | - { |
|
137 | - return $this->reg_form_count; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return array |
|
143 | - */ |
|
144 | - public function requiredQuestions(): array |
|
145 | - { |
|
146 | - return $this->required_questions; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @param string $identifier |
|
152 | - * @param bool $required_question |
|
153 | - */ |
|
154 | - public function addRequiredQuestion(string $identifier, bool $required_question): void |
|
155 | - { |
|
156 | - $this->required_questions[ $identifier ] = $required_question; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @return EE_Form_Section_Proper[] |
|
162 | - * @throws DomainException |
|
163 | - * @throws EE_Error |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws ReflectionException |
|
166 | - * @throws EntityNotFoundException |
|
167 | - * @throws InvalidDataTypeException |
|
168 | - * @throws InvalidInterfaceException |
|
169 | - */ |
|
170 | - private function generateSubsections(): array |
|
171 | - { |
|
172 | - // Init reg forms count. |
|
173 | - $this->reg_form_count = 0; |
|
174 | - |
|
175 | - $primary_registrant = null; |
|
176 | - // autoload Line_Item_Display classes |
|
177 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
178 | - $Line_Item_Display = new EE_Line_Item_Display(); |
|
179 | - // calculate taxes |
|
180 | - $Line_Item_Display->display_line_item( |
|
181 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
182 | - ['set_tax_rate' => true] |
|
183 | - ); |
|
184 | - $extra_inputs_section = $this->reg_step->reg_step_hidden_inputs(); |
|
185 | - $this->addPrivacyConsentCheckbox($extra_inputs_section); |
|
186 | - $subsections = [ |
|
187 | - 'default_hidden_inputs' => $extra_inputs_section, |
|
188 | - ]; |
|
189 | - |
|
190 | - $this->template_args = [ |
|
191 | - 'revisit' => $this->reg_step->checkout->revisit, |
|
192 | - 'registrations' => [], |
|
193 | - 'ticket_count' => [], |
|
194 | - ]; |
|
195 | - // grab the saved registrations from the transaction |
|
196 | - $registrations = $this->reg_step->checkout->transaction->registrations( |
|
197 | - $this->reg_step->checkout->reg_cache_where_params |
|
198 | - ); |
|
199 | - if ($registrations) { |
|
200 | - foreach ($registrations as $registration) { |
|
201 | - // can this registration be processed during this visit ? |
|
202 | - if ( |
|
203 | - $registration instanceof EE_Registration |
|
204 | - && $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration) |
|
205 | - ) { |
|
206 | - $reg_url_link = $registration->reg_url_link(); |
|
207 | - $registrant_form = $this->getRegistrantForm( |
|
208 | - $registration, |
|
209 | - $this->reg_step->checkout->admin_request, |
|
210 | - $this->reg_config->copyAttendeeInfo(), |
|
211 | - [$this, 'enablePrintCopyInfo'] |
|
212 | - ); |
|
213 | - // Increment the reg forms number if form is valid. |
|
214 | - if ($registrant_form->hasQuestions()) { |
|
215 | - $this->reg_form_count++; |
|
216 | - $subsections[ $reg_url_link ] = $registrant_form; |
|
217 | - } else { |
|
218 | - // or just add a blank section if there are no questions |
|
219 | - $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
220 | - } |
|
221 | - |
|
222 | - $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
223 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
224 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
225 | - ) |
|
226 | - ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
227 | - : 1; |
|
228 | - $ticket_line_item = |
|
229 | - EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
230 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
231 | - 'Ticket', |
|
232 | - [$registration->ticket()->ID()] |
|
233 | - ); |
|
234 | - $ticket_line_item = |
|
235 | - is_array($ticket_line_item) |
|
236 | - ? reset($ticket_line_item) |
|
237 | - : $ticket_line_item; |
|
238 | - $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
239 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
240 | - if ($registration->is_primary_registrant()) { |
|
241 | - $primary_registrant = $reg_url_link; |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
245 | - |
|
246 | - if ($primary_registrant && count($registrations) > 1) { |
|
247 | - if ( |
|
248 | - isset($subsections[ $primary_registrant ]) |
|
249 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
250 | - ) { |
|
251 | - $copy_options['spco_copy_attendee_chk'] = $this->print_copy_info |
|
252 | - ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
253 | - : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
|
254 | - $subsections[ $primary_registrant ]->add_subsections( |
|
255 | - $copy_options, |
|
256 | - 'primary_registrant', |
|
257 | - false |
|
258 | - ); |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - // Set the registration form template (default: one form per ticket details table). |
|
264 | - // We decide the template to used based on the number of forms. |
|
265 | - $template = $this->reg_form_count > 1 |
|
266 | - ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
267 | - : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
268 | - $this->reg_step->setTemplate($template); |
|
269 | - |
|
270 | - return $subsections; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * @param EE_Form_Section_Proper $extra_inputs_section |
|
276 | - * @throws EE_Error |
|
277 | - */ |
|
278 | - private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
|
279 | - { |
|
280 | - // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
281 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
282 | - $extra_inputs_section->add_subsections( |
|
283 | - [ |
|
284 | - 'consent_box' => new PrivacyConsentCheckboxForm( |
|
285 | - $this->reg_step->slug(), |
|
286 | - $this->reg_config->getConsentCheckboxLabelText() |
|
287 | - ) |
|
288 | - ], |
|
289 | - null, |
|
290 | - false |
|
291 | - ); |
|
292 | - } |
|
293 | - } |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | + protected $print_copy_info = false; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var EE_Registration_Config |
|
42 | + */ |
|
43 | + public $reg_config; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var int |
|
47 | + */ |
|
48 | + protected $reg_form_count = 0; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var EE_SPCO_Reg_Step_Attendee_Information |
|
52 | + */ |
|
53 | + public $reg_step; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var array |
|
57 | + */ |
|
58 | + protected $required_questions = []; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var array |
|
62 | + */ |
|
63 | + protected $template_args = []; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * RegForm constructor. |
|
68 | + * |
|
69 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
70 | + * @param EE_Registration_Config $reg_config |
|
71 | + * @throws ReflectionException |
|
72 | + * @throws EE_Error |
|
73 | + */ |
|
74 | + public function __construct( |
|
75 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
76 | + EE_Registration_Config $reg_config |
|
77 | + ) { |
|
78 | + $this->reg_step = $reg_step; |
|
79 | + $this->reg_config = $reg_config; |
|
80 | + // setup some classes so that they are ready for loading during construction of other classes |
|
81 | + LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
82 | + LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
83 | + parent::__construct( |
|
84 | + [ |
|
85 | + 'name' => $this->reg_step->reg_form_name(), |
|
86 | + 'html_id' => $this->reg_step->reg_form_name(), |
|
87 | + 'subsections' => $this->generateSubsections(), |
|
88 | + 'layout_strategy' => new EE_Template_Layout( |
|
89 | + [ |
|
90 | + 'layout_template_file' => $this->reg_step->template(), // layout_template |
|
91 | + 'template_args' => $this->template_args, |
|
92 | + ] |
|
93 | + ), |
|
94 | + ] |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @param EE_Registration $registration |
|
101 | + * @param bool $admin_request |
|
102 | + * @param bool $copy_attendee_info |
|
103 | + * @param callable $enablePrintCopyInfo |
|
104 | + * @return RegistrantFormInterface |
|
105 | + */ |
|
106 | + abstract protected function getRegistrantForm( |
|
107 | + EE_Registration $registration, |
|
108 | + bool $admin_request, |
|
109 | + bool $copy_attendee_info, |
|
110 | + callable $enablePrintCopyInfo |
|
111 | + ): RegistrantFormInterface; |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function enablePrintCopyInfo(): void |
|
118 | + { |
|
119 | + $this->print_copy_info = true; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return bool |
|
125 | + */ |
|
126 | + public function printCopyInfo(): bool |
|
127 | + { |
|
128 | + return $this->print_copy_info; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @return int |
|
134 | + */ |
|
135 | + public function regFormCount(): int |
|
136 | + { |
|
137 | + return $this->reg_form_count; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return array |
|
143 | + */ |
|
144 | + public function requiredQuestions(): array |
|
145 | + { |
|
146 | + return $this->required_questions; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @param string $identifier |
|
152 | + * @param bool $required_question |
|
153 | + */ |
|
154 | + public function addRequiredQuestion(string $identifier, bool $required_question): void |
|
155 | + { |
|
156 | + $this->required_questions[ $identifier ] = $required_question; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @return EE_Form_Section_Proper[] |
|
162 | + * @throws DomainException |
|
163 | + * @throws EE_Error |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws ReflectionException |
|
166 | + * @throws EntityNotFoundException |
|
167 | + * @throws InvalidDataTypeException |
|
168 | + * @throws InvalidInterfaceException |
|
169 | + */ |
|
170 | + private function generateSubsections(): array |
|
171 | + { |
|
172 | + // Init reg forms count. |
|
173 | + $this->reg_form_count = 0; |
|
174 | + |
|
175 | + $primary_registrant = null; |
|
176 | + // autoload Line_Item_Display classes |
|
177 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
178 | + $Line_Item_Display = new EE_Line_Item_Display(); |
|
179 | + // calculate taxes |
|
180 | + $Line_Item_Display->display_line_item( |
|
181 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
182 | + ['set_tax_rate' => true] |
|
183 | + ); |
|
184 | + $extra_inputs_section = $this->reg_step->reg_step_hidden_inputs(); |
|
185 | + $this->addPrivacyConsentCheckbox($extra_inputs_section); |
|
186 | + $subsections = [ |
|
187 | + 'default_hidden_inputs' => $extra_inputs_section, |
|
188 | + ]; |
|
189 | + |
|
190 | + $this->template_args = [ |
|
191 | + 'revisit' => $this->reg_step->checkout->revisit, |
|
192 | + 'registrations' => [], |
|
193 | + 'ticket_count' => [], |
|
194 | + ]; |
|
195 | + // grab the saved registrations from the transaction |
|
196 | + $registrations = $this->reg_step->checkout->transaction->registrations( |
|
197 | + $this->reg_step->checkout->reg_cache_where_params |
|
198 | + ); |
|
199 | + if ($registrations) { |
|
200 | + foreach ($registrations as $registration) { |
|
201 | + // can this registration be processed during this visit ? |
|
202 | + if ( |
|
203 | + $registration instanceof EE_Registration |
|
204 | + && $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration) |
|
205 | + ) { |
|
206 | + $reg_url_link = $registration->reg_url_link(); |
|
207 | + $registrant_form = $this->getRegistrantForm( |
|
208 | + $registration, |
|
209 | + $this->reg_step->checkout->admin_request, |
|
210 | + $this->reg_config->copyAttendeeInfo(), |
|
211 | + [$this, 'enablePrintCopyInfo'] |
|
212 | + ); |
|
213 | + // Increment the reg forms number if form is valid. |
|
214 | + if ($registrant_form->hasQuestions()) { |
|
215 | + $this->reg_form_count++; |
|
216 | + $subsections[ $reg_url_link ] = $registrant_form; |
|
217 | + } else { |
|
218 | + // or just add a blank section if there are no questions |
|
219 | + $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
220 | + } |
|
221 | + |
|
222 | + $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
223 | + $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
224 | + $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
225 | + ) |
|
226 | + ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
227 | + : 1; |
|
228 | + $ticket_line_item = |
|
229 | + EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
230 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
231 | + 'Ticket', |
|
232 | + [$registration->ticket()->ID()] |
|
233 | + ); |
|
234 | + $ticket_line_item = |
|
235 | + is_array($ticket_line_item) |
|
236 | + ? reset($ticket_line_item) |
|
237 | + : $ticket_line_item; |
|
238 | + $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
239 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
240 | + if ($registration->is_primary_registrant()) { |
|
241 | + $primary_registrant = $reg_url_link; |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + |
|
246 | + if ($primary_registrant && count($registrations) > 1) { |
|
247 | + if ( |
|
248 | + isset($subsections[ $primary_registrant ]) |
|
249 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
250 | + ) { |
|
251 | + $copy_options['spco_copy_attendee_chk'] = $this->print_copy_info |
|
252 | + ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
253 | + : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
|
254 | + $subsections[ $primary_registrant ]->add_subsections( |
|
255 | + $copy_options, |
|
256 | + 'primary_registrant', |
|
257 | + false |
|
258 | + ); |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + // Set the registration form template (default: one form per ticket details table). |
|
264 | + // We decide the template to used based on the number of forms. |
|
265 | + $template = $this->reg_form_count > 1 |
|
266 | + ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
267 | + : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
268 | + $this->reg_step->setTemplate($template); |
|
269 | + |
|
270 | + return $subsections; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * @param EE_Form_Section_Proper $extra_inputs_section |
|
276 | + * @throws EE_Error |
|
277 | + */ |
|
278 | + private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
|
279 | + { |
|
280 | + // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
281 | + if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
282 | + $extra_inputs_section->add_subsections( |
|
283 | + [ |
|
284 | + 'consent_box' => new PrivacyConsentCheckboxForm( |
|
285 | + $this->reg_step->slug(), |
|
286 | + $this->reg_config->getConsentCheckboxLabelText() |
|
287 | + ) |
|
288 | + ], |
|
289 | + null, |
|
290 | + false |
|
291 | + ); |
|
292 | + } |
|
293 | + } |
|
294 | 294 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function addRequiredQuestion(string $identifier, bool $required_question): void |
155 | 155 | { |
156 | - $this->required_questions[ $identifier ] = $required_question; |
|
156 | + $this->required_questions[$identifier] = $required_question; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -213,29 +213,29 @@ discard block |
||
213 | 213 | // Increment the reg forms number if form is valid. |
214 | 214 | if ($registrant_form->hasQuestions()) { |
215 | 215 | $this->reg_form_count++; |
216 | - $subsections[ $reg_url_link ] = $registrant_form; |
|
216 | + $subsections[$reg_url_link] = $registrant_form; |
|
217 | 217 | } else { |
218 | 218 | // or just add a blank section if there are no questions |
219 | - $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
219 | + $subsections[$reg_url_link] = new EE_Form_Section_HTML(); |
|
220 | 220 | } |
221 | 221 | |
222 | - $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
223 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
224 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
222 | + $this->template_args['registrations'][$reg_url_link] = $registration; |
|
223 | + $this->template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
224 | + $this->template_args['ticket_count'][$registration->ticket()->ID()] |
|
225 | 225 | ) |
226 | - ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
226 | + ? $this->template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
227 | 227 | : 1; |
228 | - $ticket_line_item = |
|
228 | + $ticket_line_item = |
|
229 | 229 | EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
230 | 230 | $this->reg_step->checkout->cart->get_grand_total(), |
231 | 231 | 'Ticket', |
232 | 232 | [$registration->ticket()->ID()] |
233 | 233 | ); |
234 | - $ticket_line_item = |
|
234 | + $ticket_line_item = |
|
235 | 235 | is_array($ticket_line_item) |
236 | 236 | ? reset($ticket_line_item) |
237 | 237 | : $ticket_line_item; |
238 | - $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
238 | + $this->template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
239 | 239 | $Line_Item_Display->display_line_item($ticket_line_item); |
240 | 240 | if ($registration->is_primary_registrant()) { |
241 | 241 | $primary_registrant = $reg_url_link; |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | |
246 | 246 | if ($primary_registrant && count($registrations) > 1) { |
247 | 247 | if ( |
248 | - isset($subsections[ $primary_registrant ]) |
|
249 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
248 | + isset($subsections[$primary_registrant]) |
|
249 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
250 | 250 | ) { |
251 | 251 | $copy_options['spco_copy_attendee_chk'] = $this->print_copy_info |
252 | 252 | ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
253 | 253 | : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
254 | - $subsections[ $primary_registrant ]->add_subsections( |
|
254 | + $subsections[$primary_registrant]->add_subsections( |
|
255 | 255 | $copy_options, |
256 | 256 | 'primary_registrant', |
257 | 257 | false |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | // Set the registration form template (default: one form per ticket details table). |
264 | 264 | // We decide the template to used based on the number of forms. |
265 | 265 | $template = $this->reg_form_count > 1 |
266 | - ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
267 | - : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
266 | + ? SPCO_REG_STEPS_PATH . $this->reg_step->slug().'/attendee_info_main.template.php' |
|
267 | + : SPCO_REG_STEPS_PATH.$this->reg_step->slug().'/attendee_info_single.template.php'; |
|
268 | 268 | $this->reg_step->setTemplate($template); |
269 | 269 | |
270 | 270 | return $subsections; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
279 | 279 | { |
280 | 280 | // if this isn't a revisit, and they have the privacy consent box enabled, add it |
281 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
281 | + if ( ! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
282 | 282 | $extra_inputs_section->add_subsections( |
283 | 283 | [ |
284 | 284 | 'consent_box' => new PrivacyConsentCheckboxForm( |
@@ -11,137 +11,137 @@ |
||
11 | 11 | |
12 | 12 | abstract class RegistrantForm extends EE_Form_Section_Proper implements RegistrantFormInterface |
13 | 13 | { |
14 | - /** |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $form_args = []; |
|
18 | - |
|
19 | - /** |
|
20 | - * @var bool |
|
21 | - */ |
|
22 | - private $has_questions = false; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RegistrantForm constructor. |
|
27 | - * |
|
28 | - * @param array $form_args |
|
29 | - * @throws EE_Error |
|
30 | - */ |
|
31 | - public function __construct(array $form_args) |
|
32 | - { |
|
33 | - parent::__construct($form_args); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param EE_Registration $registration |
|
39 | - * @return void |
|
40 | - * @throws EE_Error |
|
41 | - */ |
|
42 | - protected function addAdditionalAttendeeRegInfoInput(EE_Registration $registration) |
|
43 | - { |
|
44 | - // generate hidden input |
|
45 | - $this->form_args['subsections']['additional_attendee_reg_info'] = new EE_Hidden_Input( |
|
46 | - [ |
|
47 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
48 | - 'default' => true, |
|
49 | - ] |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @param EE_Registration $registration |
|
56 | - * @return void |
|
57 | - * @throws EE_Error |
|
58 | - */ |
|
59 | - protected function addAdditionalPrimaryRegistrantInputs(EE_Registration $registration) |
|
60 | - { |
|
61 | - if ($registration->is_primary_registrant()) { |
|
62 | - // generate hidden input |
|
63 | - $this->form_args['subsections']['primary_registrant'] = new EE_Hidden_Input( |
|
64 | - [ |
|
65 | - 'html_id' => 'primary_registrant', |
|
66 | - 'default' => $registration->reg_url_link(), |
|
67 | - ] |
|
68 | - ); |
|
69 | - } |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param int $attendee_nmbr |
|
75 | - * @param bool $copy_attendee_info |
|
76 | - * @param callable $enablePrintCopyInfo |
|
77 | - */ |
|
78 | - protected function enablePrintCopyInfo( |
|
79 | - int $attendee_nmbr, |
|
80 | - bool $copy_attendee_info, |
|
81 | - callable $enablePrintCopyInfo |
|
82 | - ) { |
|
83 | - // If we have question groups for additional attendees, then display the copy options |
|
84 | - $printCopyInfo = apply_filters( |
|
85 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
86 | - $attendee_nmbr > 1 && $copy_attendee_info, |
|
87 | - $attendee_nmbr |
|
88 | - ); |
|
89 | - if ($printCopyInfo) { |
|
90 | - $enablePrintCopyInfo(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @param EE_Registration $registration |
|
97 | - * @param bool $admin_request |
|
98 | - * @param int $attendee_nmbr |
|
99 | - * @return array |
|
100 | - * @throws EE_Error |
|
101 | - */ |
|
102 | - protected function generateTopLevelFormArgs( |
|
103 | - EE_Registration $registration, |
|
104 | - bool $admin_request, |
|
105 | - int $attendee_nmbr |
|
106 | - ): array { |
|
107 | - return [ |
|
108 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
109 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
110 | - 'html_style' => $admin_request |
|
111 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
112 | - : '', |
|
113 | - 'subsections' => [], |
|
114 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
115 | - [ |
|
116 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
117 | - 'legend_text' => sprintf( |
|
118 | - esc_html_x( |
|
119 | - 'Attendee %d', |
|
120 | - 'Attendee 123', |
|
121 | - 'event_espresso' |
|
122 | - ), |
|
123 | - $attendee_nmbr |
|
124 | - ), |
|
125 | - ] |
|
126 | - ), |
|
127 | - ]; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function hasQuestions(): bool |
|
135 | - { |
|
136 | - return $this->has_questions; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - protected function setHasQuestions(): void |
|
144 | - { |
|
145 | - $this->has_questions = ! empty($this->form_args); |
|
146 | - } |
|
14 | + /** |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $form_args = []; |
|
18 | + |
|
19 | + /** |
|
20 | + * @var bool |
|
21 | + */ |
|
22 | + private $has_questions = false; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RegistrantForm constructor. |
|
27 | + * |
|
28 | + * @param array $form_args |
|
29 | + * @throws EE_Error |
|
30 | + */ |
|
31 | + public function __construct(array $form_args) |
|
32 | + { |
|
33 | + parent::__construct($form_args); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param EE_Registration $registration |
|
39 | + * @return void |
|
40 | + * @throws EE_Error |
|
41 | + */ |
|
42 | + protected function addAdditionalAttendeeRegInfoInput(EE_Registration $registration) |
|
43 | + { |
|
44 | + // generate hidden input |
|
45 | + $this->form_args['subsections']['additional_attendee_reg_info'] = new EE_Hidden_Input( |
|
46 | + [ |
|
47 | + 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
48 | + 'default' => true, |
|
49 | + ] |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @param EE_Registration $registration |
|
56 | + * @return void |
|
57 | + * @throws EE_Error |
|
58 | + */ |
|
59 | + protected function addAdditionalPrimaryRegistrantInputs(EE_Registration $registration) |
|
60 | + { |
|
61 | + if ($registration->is_primary_registrant()) { |
|
62 | + // generate hidden input |
|
63 | + $this->form_args['subsections']['primary_registrant'] = new EE_Hidden_Input( |
|
64 | + [ |
|
65 | + 'html_id' => 'primary_registrant', |
|
66 | + 'default' => $registration->reg_url_link(), |
|
67 | + ] |
|
68 | + ); |
|
69 | + } |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param int $attendee_nmbr |
|
75 | + * @param bool $copy_attendee_info |
|
76 | + * @param callable $enablePrintCopyInfo |
|
77 | + */ |
|
78 | + protected function enablePrintCopyInfo( |
|
79 | + int $attendee_nmbr, |
|
80 | + bool $copy_attendee_info, |
|
81 | + callable $enablePrintCopyInfo |
|
82 | + ) { |
|
83 | + // If we have question groups for additional attendees, then display the copy options |
|
84 | + $printCopyInfo = apply_filters( |
|
85 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
86 | + $attendee_nmbr > 1 && $copy_attendee_info, |
|
87 | + $attendee_nmbr |
|
88 | + ); |
|
89 | + if ($printCopyInfo) { |
|
90 | + $enablePrintCopyInfo(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @param EE_Registration $registration |
|
97 | + * @param bool $admin_request |
|
98 | + * @param int $attendee_nmbr |
|
99 | + * @return array |
|
100 | + * @throws EE_Error |
|
101 | + */ |
|
102 | + protected function generateTopLevelFormArgs( |
|
103 | + EE_Registration $registration, |
|
104 | + bool $admin_request, |
|
105 | + int $attendee_nmbr |
|
106 | + ): array { |
|
107 | + return [ |
|
108 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
109 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
110 | + 'html_style' => $admin_request |
|
111 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
112 | + : '', |
|
113 | + 'subsections' => [], |
|
114 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
115 | + [ |
|
116 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
117 | + 'legend_text' => sprintf( |
|
118 | + esc_html_x( |
|
119 | + 'Attendee %d', |
|
120 | + 'Attendee 123', |
|
121 | + 'event_espresso' |
|
122 | + ), |
|
123 | + $attendee_nmbr |
|
124 | + ), |
|
125 | + ] |
|
126 | + ), |
|
127 | + ]; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function hasQuestions(): bool |
|
135 | + { |
|
136 | + return $this->has_questions; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + protected function setHasQuestions(): void |
|
144 | + { |
|
145 | + $this->has_questions = ! empty($this->form_args); |
|
146 | + } |
|
147 | 147 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // generate hidden input |
45 | 45 | $this->form_args['subsections']['additional_attendee_reg_info'] = new EE_Hidden_Input( |
46 | 46 | [ |
47 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
47 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
48 | 48 | 'default' => true, |
49 | 49 | ] |
50 | 50 | ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | int $attendee_nmbr |
106 | 106 | ): array { |
107 | 107 | return [ |
108 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
108 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
109 | 109 | 'html_class' => 'ee-reg-form-attendee-dv', |
110 | 110 | 'html_style' => $admin_request |
111 | 111 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -19,272 +19,272 @@ |
||
19 | 19 | abstract class RegFormHandler implements RegFormHandlerInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EE_Checkout |
|
24 | - */ |
|
25 | - protected $checkout; |
|
22 | + /** |
|
23 | + * @var EE_Checkout |
|
24 | + */ |
|
25 | + protected $checkout; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $non_input_form_sections; |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $non_input_form_sections; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var RegFormAttendeeFactory |
|
34 | - */ |
|
35 | - protected $attendee_factory; |
|
32 | + /** |
|
33 | + * @var RegFormAttendeeFactory |
|
34 | + */ |
|
35 | + protected $attendee_factory; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var RegistrantData |
|
39 | - */ |
|
40 | - protected $registrant_data; |
|
37 | + /** |
|
38 | + * @var RegistrantData |
|
39 | + */ |
|
40 | + protected $registrant_data; |
|
41 | 41 | |
42 | - /** |
|
43 | - * the registration form for the current checkout step |
|
44 | - * |
|
45 | - * @var EE_Form_Section_Proper $reg_form |
|
46 | - */ |
|
47 | - protected $reg_form; |
|
42 | + /** |
|
43 | + * the registration form for the current checkout step |
|
44 | + * |
|
45 | + * @var EE_Form_Section_Proper $reg_form |
|
46 | + */ |
|
47 | + protected $reg_form; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @var EE_Registration_Processor |
|
51 | - */ |
|
52 | - protected $registration_processor; |
|
49 | + /** |
|
50 | + * @var EE_Registration_Processor |
|
51 | + */ |
|
52 | + protected $registration_processor; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @var bool |
|
56 | - */ |
|
57 | - protected $valid = true; |
|
54 | + /** |
|
55 | + * @var bool |
|
56 | + */ |
|
57 | + protected $valid = true; |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * RegFormHandler constructor. |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - EE_Checkout $checkout, |
|
65 | - RegistrantData $registrant_data, |
|
66 | - EE_Form_Section_Proper $reg_form, |
|
67 | - RegFormAttendeeFactory $attendee_factory, |
|
68 | - EE_Registration_Processor $registration_processor |
|
69 | - ) { |
|
70 | - $this->checkout = $checkout; |
|
71 | - $this->reg_form = $reg_form; |
|
72 | - $this->registrant_data = $registrant_data; |
|
73 | - $this->attendee_factory = $attendee_factory; |
|
74 | - $this->registration_processor = $registration_processor; |
|
75 | - // reg form sections that do not contain inputs |
|
76 | - $this->non_input_form_sections = [ |
|
77 | - 'primary_registrant', |
|
78 | - 'additional_attendee_reg_info', |
|
79 | - 'spco_copy_attendee_chk', |
|
80 | - ]; |
|
81 | - } |
|
60 | + /** |
|
61 | + * RegFormHandler constructor. |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + EE_Checkout $checkout, |
|
65 | + RegistrantData $registrant_data, |
|
66 | + EE_Form_Section_Proper $reg_form, |
|
67 | + RegFormAttendeeFactory $attendee_factory, |
|
68 | + EE_Registration_Processor $registration_processor |
|
69 | + ) { |
|
70 | + $this->checkout = $checkout; |
|
71 | + $this->reg_form = $reg_form; |
|
72 | + $this->registrant_data = $registrant_data; |
|
73 | + $this->attendee_factory = $attendee_factory; |
|
74 | + $this->registration_processor = $registration_processor; |
|
75 | + // reg form sections that do not contain inputs |
|
76 | + $this->non_input_form_sections = [ |
|
77 | + 'primary_registrant', |
|
78 | + 'additional_attendee_reg_info', |
|
79 | + 'spco_copy_attendee_chk', |
|
80 | + ]; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - abstract public function initializeInputHandler(); |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + abstract public function initializeInputHandler(); |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * @param EE_Registration $registration |
|
92 | - * @param string $reg_url_link |
|
93 | - * @param array $reg_form_data |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - abstract protected function processRegFormData( |
|
97 | - EE_Registration $registration, |
|
98 | - string $reg_url_link, |
|
99 | - array $reg_form_data |
|
100 | - ): bool; |
|
90 | + /** |
|
91 | + * @param EE_Registration $registration |
|
92 | + * @param string $reg_url_link |
|
93 | + * @param array $reg_form_data |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + abstract protected function processRegFormData( |
|
97 | + EE_Registration $registration, |
|
98 | + string $reg_url_link, |
|
99 | + array $reg_form_data |
|
100 | + ): bool; |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @return int |
|
105 | - */ |
|
106 | - public function attendeeCount(): int |
|
107 | - { |
|
108 | - return $this->registrant_data->attendeeCount(); |
|
109 | - } |
|
103 | + /** |
|
104 | + * @return int |
|
105 | + */ |
|
106 | + public function attendeeCount(): int |
|
107 | + { |
|
108 | + return $this->registrant_data->attendeeCount(); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return bool |
|
114 | - */ |
|
115 | - protected function isInvalid(): bool |
|
116 | - { |
|
117 | - $this->valid = false; |
|
118 | - return $this->valid; |
|
119 | - } |
|
112 | + /** |
|
113 | + * @return bool |
|
114 | + */ |
|
115 | + protected function isInvalid(): bool |
|
116 | + { |
|
117 | + $this->valid = false; |
|
118 | + return $this->valid; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * @param EE_Registration[] $registrations |
|
124 | - * @param array[][] $reg_form_data |
|
125 | - * @return bool |
|
126 | - * @throws EntityNotFoundException |
|
127 | - * @throws EE_Error |
|
128 | - * @throws InvalidArgumentException |
|
129 | - * @throws ReflectionException |
|
130 | - * @throws RuntimeException |
|
131 | - * @throws InvalidDataTypeException |
|
132 | - * @throws InvalidInterfaceException |
|
133 | - */ |
|
134 | - public function processRegistrations(array $registrations, array $reg_form_data): bool |
|
135 | - { |
|
136 | - // start off optimistic, then trip this to false if anything goes wrong |
|
137 | - $this->valid = true; |
|
138 | - foreach ($registrations as $registration) { |
|
139 | - // verify EE_Registration object |
|
140 | - if (! $this->isValidRegistration($registration)) { |
|
141 | - return $this->isInvalid(); |
|
142 | - } |
|
143 | - // reg_url_link exists ? |
|
144 | - $reg_url_link = $registration->reg_url_link(); |
|
145 | - if (! $this->isValidRegUrlLink($reg_url_link)) { |
|
146 | - return $this->isInvalid(); |
|
147 | - } |
|
148 | - // should this registration be processed during this visit ? |
|
149 | - if (! $this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
150 | - continue; |
|
151 | - } |
|
152 | - // if NOT revisiting, then let's save the registration now, |
|
153 | - // so that we have a REG_ID to use when generating other objects |
|
154 | - if (! $this->checkout->revisit) { |
|
155 | - $registration->save(); |
|
156 | - } |
|
157 | - /** |
|
158 | - * This allows plugins to trigger a fail on processing of a |
|
159 | - * registration for any conditions they may have for it to pass. |
|
160 | - * |
|
161 | - * @var bool if true is returned by the plugin then the registration processing is halted. |
|
162 | - */ |
|
163 | - if ( |
|
164 | - apply_filters( |
|
165 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
166 | - false, |
|
167 | - $this->attendeeCount(), |
|
168 | - $registration, |
|
169 | - $registrations, |
|
170 | - $reg_form_data, |
|
171 | - $this |
|
172 | - ) |
|
173 | - ) { |
|
174 | - return $this->isInvalid(); |
|
175 | - } |
|
122 | + /** |
|
123 | + * @param EE_Registration[] $registrations |
|
124 | + * @param array[][] $reg_form_data |
|
125 | + * @return bool |
|
126 | + * @throws EntityNotFoundException |
|
127 | + * @throws EE_Error |
|
128 | + * @throws InvalidArgumentException |
|
129 | + * @throws ReflectionException |
|
130 | + * @throws RuntimeException |
|
131 | + * @throws InvalidDataTypeException |
|
132 | + * @throws InvalidInterfaceException |
|
133 | + */ |
|
134 | + public function processRegistrations(array $registrations, array $reg_form_data): bool |
|
135 | + { |
|
136 | + // start off optimistic, then trip this to false if anything goes wrong |
|
137 | + $this->valid = true; |
|
138 | + foreach ($registrations as $registration) { |
|
139 | + // verify EE_Registration object |
|
140 | + if (! $this->isValidRegistration($registration)) { |
|
141 | + return $this->isInvalid(); |
|
142 | + } |
|
143 | + // reg_url_link exists ? |
|
144 | + $reg_url_link = $registration->reg_url_link(); |
|
145 | + if (! $this->isValidRegUrlLink($reg_url_link)) { |
|
146 | + return $this->isInvalid(); |
|
147 | + } |
|
148 | + // should this registration be processed during this visit ? |
|
149 | + if (! $this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
150 | + continue; |
|
151 | + } |
|
152 | + // if NOT revisiting, then let's save the registration now, |
|
153 | + // so that we have a REG_ID to use when generating other objects |
|
154 | + if (! $this->checkout->revisit) { |
|
155 | + $registration->save(); |
|
156 | + } |
|
157 | + /** |
|
158 | + * This allows plugins to trigger a fail on processing of a |
|
159 | + * registration for any conditions they may have for it to pass. |
|
160 | + * |
|
161 | + * @var bool if true is returned by the plugin then the registration processing is halted. |
|
162 | + */ |
|
163 | + if ( |
|
164 | + apply_filters( |
|
165 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
166 | + false, |
|
167 | + $this->attendeeCount(), |
|
168 | + $registration, |
|
169 | + $registrations, |
|
170 | + $reg_form_data, |
|
171 | + $this |
|
172 | + ) |
|
173 | + ) { |
|
174 | + return $this->isInvalid(); |
|
175 | + } |
|
176 | 176 | |
177 | - // Houston, we have a registration! |
|
178 | - if (! $this->processRegistration($registration, $reg_url_link, $reg_form_data)) { |
|
179 | - return $this->isInvalid(); |
|
180 | - } |
|
181 | - } |
|
182 | - return $this->valid; |
|
183 | - } |
|
177 | + // Houston, we have a registration! |
|
178 | + if (! $this->processRegistration($registration, $reg_url_link, $reg_form_data)) { |
|
179 | + return $this->isInvalid(); |
|
180 | + } |
|
181 | + } |
|
182 | + return $this->valid; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | - /** |
|
187 | - * @param string $reg_url_link |
|
188 | - * @return bool |
|
189 | - */ |
|
190 | - protected function isValidRegUrlLink(string $reg_url_link): bool |
|
191 | - { |
|
192 | - if (! empty($reg_url_link)) { |
|
193 | - return true; |
|
194 | - } |
|
195 | - EE_Error::add_error( |
|
196 | - esc_html__( |
|
197 | - 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
198 | - 'event_espresso' |
|
199 | - ), |
|
200 | - __FILE__, |
|
201 | - __FUNCTION__, |
|
202 | - __LINE__ |
|
203 | - ); |
|
204 | - return false; |
|
205 | - } |
|
186 | + /** |
|
187 | + * @param string $reg_url_link |
|
188 | + * @return bool |
|
189 | + */ |
|
190 | + protected function isValidRegUrlLink(string $reg_url_link): bool |
|
191 | + { |
|
192 | + if (! empty($reg_url_link)) { |
|
193 | + return true; |
|
194 | + } |
|
195 | + EE_Error::add_error( |
|
196 | + esc_html__( |
|
197 | + 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
198 | + 'event_espresso' |
|
199 | + ), |
|
200 | + __FILE__, |
|
201 | + __FUNCTION__, |
|
202 | + __LINE__ |
|
203 | + ); |
|
204 | + return false; |
|
205 | + } |
|
206 | 206 | |
207 | 207 | |
208 | - /** |
|
209 | - * @param EE_Registration|null $registration |
|
210 | - * @return bool |
|
211 | - */ |
|
212 | - protected function isValidRegistration(?EE_Registration $registration): bool |
|
213 | - { |
|
214 | - // verify EE_Registration object |
|
215 | - if ($registration instanceof EE_Registration) { |
|
216 | - return true; |
|
217 | - } |
|
218 | - EE_Error::add_error( |
|
219 | - esc_html__( |
|
220 | - 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
221 | - 'event_espresso' |
|
222 | - ), |
|
223 | - __FILE__, |
|
224 | - __FUNCTION__, |
|
225 | - __LINE__ |
|
226 | - ); |
|
227 | - return false; |
|
228 | - } |
|
208 | + /** |
|
209 | + * @param EE_Registration|null $registration |
|
210 | + * @return bool |
|
211 | + */ |
|
212 | + protected function isValidRegistration(?EE_Registration $registration): bool |
|
213 | + { |
|
214 | + // verify EE_Registration object |
|
215 | + if ($registration instanceof EE_Registration) { |
|
216 | + return true; |
|
217 | + } |
|
218 | + EE_Error::add_error( |
|
219 | + esc_html__( |
|
220 | + 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
221 | + 'event_espresso' |
|
222 | + ), |
|
223 | + __FILE__, |
|
224 | + __FUNCTION__, |
|
225 | + __LINE__ |
|
226 | + ); |
|
227 | + return false; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | |
231 | - /** |
|
232 | - * @param EE_Registration $registration |
|
233 | - * @param string $reg_url_link |
|
234 | - * @param array[][] $reg_form_data |
|
235 | - * @return bool |
|
236 | - * @throws EE_Error |
|
237 | - * @throws ReflectionException |
|
238 | - */ |
|
239 | - protected function processRegistration( |
|
240 | - EE_Registration $registration, |
|
241 | - string $reg_url_link, |
|
242 | - array $reg_form_data |
|
243 | - ): bool { |
|
244 | - $this->registrant_data->initializeRegistrantData($registration); |
|
245 | - if (! $this->processRegFormData($registration, $reg_url_link, $reg_form_data)) { |
|
246 | - return false; |
|
247 | - } |
|
248 | - // RegFormAttendeeFactory |
|
249 | - if (! $this->attendee_factory->create($registration, $reg_url_link)) { |
|
250 | - return false; |
|
251 | - } |
|
252 | - // at this point, we should have enough details about the registrant to consider the registration |
|
253 | - // NOT incomplete |
|
254 | - $this->registration_processor->toggle_incomplete_registration_status_to_default( |
|
255 | - $registration, |
|
256 | - false, |
|
257 | - new Context( |
|
258 | - 'spco_reg_step_attendee_information_process_registrations', |
|
259 | - esc_html__( |
|
260 | - 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
261 | - 'event_espresso' |
|
262 | - ) |
|
263 | - ) |
|
264 | - ); |
|
265 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
|
266 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
267 | - // if we've gotten this far, then let's save what we have |
|
268 | - $registration->save(); |
|
269 | - // add relation between TXN and registration |
|
270 | - $this->associateRegistrationWithTransaction($registration); |
|
271 | - return true; |
|
272 | - } |
|
231 | + /** |
|
232 | + * @param EE_Registration $registration |
|
233 | + * @param string $reg_url_link |
|
234 | + * @param array[][] $reg_form_data |
|
235 | + * @return bool |
|
236 | + * @throws EE_Error |
|
237 | + * @throws ReflectionException |
|
238 | + */ |
|
239 | + protected function processRegistration( |
|
240 | + EE_Registration $registration, |
|
241 | + string $reg_url_link, |
|
242 | + array $reg_form_data |
|
243 | + ): bool { |
|
244 | + $this->registrant_data->initializeRegistrantData($registration); |
|
245 | + if (! $this->processRegFormData($registration, $reg_url_link, $reg_form_data)) { |
|
246 | + return false; |
|
247 | + } |
|
248 | + // RegFormAttendeeFactory |
|
249 | + if (! $this->attendee_factory->create($registration, $reg_url_link)) { |
|
250 | + return false; |
|
251 | + } |
|
252 | + // at this point, we should have enough details about the registrant to consider the registration |
|
253 | + // NOT incomplete |
|
254 | + $this->registration_processor->toggle_incomplete_registration_status_to_default( |
|
255 | + $registration, |
|
256 | + false, |
|
257 | + new Context( |
|
258 | + 'spco_reg_step_attendee_information_process_registrations', |
|
259 | + esc_html__( |
|
260 | + 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
261 | + 'event_espresso' |
|
262 | + ) |
|
263 | + ) |
|
264 | + ); |
|
265 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
|
266 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
267 | + // if we've gotten this far, then let's save what we have |
|
268 | + $registration->save(); |
|
269 | + // add relation between TXN and registration |
|
270 | + $this->associateRegistrationWithTransaction($registration); |
|
271 | + return true; |
|
272 | + } |
|
273 | 273 | |
274 | 274 | |
275 | - /** |
|
276 | - * @param EE_Registration $registration |
|
277 | - * @return void |
|
278 | - * @throws EE_Error |
|
279 | - * @throws InvalidArgumentException |
|
280 | - * @throws ReflectionException |
|
281 | - * @throws InvalidDataTypeException |
|
282 | - * @throws InvalidInterfaceException |
|
283 | - */ |
|
284 | - private function associateRegistrationWithTransaction(EE_Registration $registration) |
|
285 | - { |
|
286 | - // add relation to registration |
|
287 | - $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
288 | - $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
289 | - } |
|
275 | + /** |
|
276 | + * @param EE_Registration $registration |
|
277 | + * @return void |
|
278 | + * @throws EE_Error |
|
279 | + * @throws InvalidArgumentException |
|
280 | + * @throws ReflectionException |
|
281 | + * @throws InvalidDataTypeException |
|
282 | + * @throws InvalidInterfaceException |
|
283 | + */ |
|
284 | + private function associateRegistrationWithTransaction(EE_Registration $registration) |
|
285 | + { |
|
286 | + // add relation to registration |
|
287 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
288 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
289 | + } |
|
290 | 290 | } |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | $this->valid = true; |
138 | 138 | foreach ($registrations as $registration) { |
139 | 139 | // verify EE_Registration object |
140 | - if (! $this->isValidRegistration($registration)) { |
|
140 | + if ( ! $this->isValidRegistration($registration)) { |
|
141 | 141 | return $this->isInvalid(); |
142 | 142 | } |
143 | 143 | // reg_url_link exists ? |
144 | 144 | $reg_url_link = $registration->reg_url_link(); |
145 | - if (! $this->isValidRegUrlLink($reg_url_link)) { |
|
145 | + if ( ! $this->isValidRegUrlLink($reg_url_link)) { |
|
146 | 146 | return $this->isInvalid(); |
147 | 147 | } |
148 | 148 | // should this registration be processed during this visit ? |
149 | - if (! $this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
149 | + if ( ! $this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | // if NOT revisiting, then let's save the registration now, |
153 | 153 | // so that we have a REG_ID to use when generating other objects |
154 | - if (! $this->checkout->revisit) { |
|
154 | + if ( ! $this->checkout->revisit) { |
|
155 | 155 | $registration->save(); |
156 | 156 | } |
157 | 157 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // Houston, we have a registration! |
178 | - if (! $this->processRegistration($registration, $reg_url_link, $reg_form_data)) { |
|
178 | + if ( ! $this->processRegistration($registration, $reg_url_link, $reg_form_data)) { |
|
179 | 179 | return $this->isInvalid(); |
180 | 180 | } |
181 | 181 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function isValidRegUrlLink(string $reg_url_link): bool |
191 | 191 | { |
192 | - if (! empty($reg_url_link)) { |
|
192 | + if ( ! empty($reg_url_link)) { |
|
193 | 193 | return true; |
194 | 194 | } |
195 | 195 | EE_Error::add_error( |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | array $reg_form_data |
243 | 243 | ): bool { |
244 | 244 | $this->registrant_data->initializeRegistrantData($registration); |
245 | - if (! $this->processRegFormData($registration, $reg_url_link, $reg_form_data)) { |
|
245 | + if ( ! $this->processRegFormData($registration, $reg_url_link, $reg_form_data)) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | // RegFormAttendeeFactory |
249 | - if (! $this->attendee_factory->create($registration, $reg_url_link)) { |
|
249 | + if ( ! $this->attendee_factory->create($registration, $reg_url_link)) { |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | // at this point, we should have enough details about the registrant to consider the registration |
@@ -22,66 +22,66 @@ |
||
22 | 22 | */ |
23 | 23 | class RegForm extends RegFormBase |
24 | 24 | { |
25 | - /** |
|
26 | - * @var JsonDataAPI |
|
27 | - */ |
|
28 | - public $form_data_api; |
|
25 | + /** |
|
26 | + * @var JsonDataAPI |
|
27 | + */ |
|
28 | + public $form_data_api; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var RegistrantFormInput |
|
32 | - */ |
|
33 | - public $reg_form_input_factory; |
|
30 | + /** |
|
31 | + * @var RegistrantFormInput |
|
32 | + */ |
|
33 | + public $reg_form_input_factory; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * RegForm constructor. |
|
38 | - * |
|
39 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
40 | - * @param JsonDataAPI $form_data_api |
|
41 | - * @param EE_Registration_Config $reg_config |
|
42 | - * @throws EE_Error |
|
43 | - * @throws ReflectionException |
|
44 | - */ |
|
45 | - public function __construct( |
|
46 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
47 | - JsonDataAPI $form_data_api, |
|
48 | - EE_Registration_Config $reg_config |
|
49 | - ) { |
|
50 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
51 | - $this->form_data_api = $form_data_api; |
|
52 | - $this->reg_form_input_factory = LoaderFactory::getNew( |
|
53 | - RegistrantFormInput::class, |
|
54 | - [ |
|
55 | - [$this, 'addRequiredQuestion'], |
|
56 | - $this->form_data_api |
|
57 | - ] |
|
58 | - ); |
|
59 | - parent::__construct($reg_step, $reg_config); |
|
60 | - } |
|
36 | + /** |
|
37 | + * RegForm constructor. |
|
38 | + * |
|
39 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
40 | + * @param JsonDataAPI $form_data_api |
|
41 | + * @param EE_Registration_Config $reg_config |
|
42 | + * @throws EE_Error |
|
43 | + * @throws ReflectionException |
|
44 | + */ |
|
45 | + public function __construct( |
|
46 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
47 | + JsonDataAPI $form_data_api, |
|
48 | + EE_Registration_Config $reg_config |
|
49 | + ) { |
|
50 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2); |
|
51 | + $this->form_data_api = $form_data_api; |
|
52 | + $this->reg_form_input_factory = LoaderFactory::getNew( |
|
53 | + RegistrantFormInput::class, |
|
54 | + [ |
|
55 | + [$this, 'addRequiredQuestion'], |
|
56 | + $this->form_data_api |
|
57 | + ] |
|
58 | + ); |
|
59 | + parent::__construct($reg_step, $reg_config); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @param EE_Registration $registration |
|
65 | - * @param bool $admin_request |
|
66 | - * @param bool $copy_attendee_info |
|
67 | - * @param callable $enablePrintCopyInfo |
|
68 | - * @return RegistrantFormInterface |
|
69 | - */ |
|
70 | - protected function getRegistrantForm( |
|
71 | - EE_Registration $registration, |
|
72 | - bool $admin_request, |
|
73 | - bool $copy_attendee_info, |
|
74 | - callable $enablePrintCopyInfo |
|
75 | - ): RegistrantFormInterface { |
|
76 | - return LoaderFactory::getNew( |
|
77 | - RegistrantForm::class, |
|
78 | - [ |
|
79 | - $registration, |
|
80 | - $admin_request, |
|
81 | - $copy_attendee_info, |
|
82 | - $enablePrintCopyInfo, |
|
83 | - $this->reg_form_input_factory, |
|
84 | - ] |
|
85 | - ); |
|
86 | - } |
|
63 | + /** |
|
64 | + * @param EE_Registration $registration |
|
65 | + * @param bool $admin_request |
|
66 | + * @param bool $copy_attendee_info |
|
67 | + * @param callable $enablePrintCopyInfo |
|
68 | + * @return RegistrantFormInterface |
|
69 | + */ |
|
70 | + protected function getRegistrantForm( |
|
71 | + EE_Registration $registration, |
|
72 | + bool $admin_request, |
|
73 | + bool $copy_attendee_info, |
|
74 | + callable $enablePrintCopyInfo |
|
75 | + ): RegistrantFormInterface { |
|
76 | + return LoaderFactory::getNew( |
|
77 | + RegistrantForm::class, |
|
78 | + [ |
|
79 | + $registration, |
|
80 | + $admin_request, |
|
81 | + $copy_attendee_info, |
|
82 | + $enablePrintCopyInfo, |
|
83 | + $this->reg_form_input_factory, |
|
84 | + ] |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | } |
@@ -19,280 +19,280 @@ |
||
19 | 19 | class RegFormInputHandler extends RegFormInputHandlerV1 |
20 | 20 | { |
21 | 21 | |
22 | - // /** |
|
23 | - // * @var array |
|
24 | - // */ |
|
25 | - // protected $non_persistable_fields = [SystemInputFieldNamesInterface::EMAIL_CONFIRM]; |
|
22 | + // /** |
|
23 | + // * @var array |
|
24 | + // */ |
|
25 | + // protected $non_persistable_fields = [SystemInputFieldNamesInterface::EMAIL_CONFIRM]; |
|
26 | 26 | |
27 | - // /** |
|
28 | - // * @var EEM_Attendee |
|
29 | - // */ |
|
30 | - // private $attendee_model; |
|
31 | - // |
|
32 | - // /** |
|
33 | - // * @var string |
|
34 | - // */ |
|
35 | - // private $checkout_reg_url_link; |
|
27 | + // /** |
|
28 | + // * @var EEM_Attendee |
|
29 | + // */ |
|
30 | + // private $attendee_model; |
|
31 | + // |
|
32 | + // /** |
|
33 | + // * @var string |
|
34 | + // */ |
|
35 | + // private $checkout_reg_url_link; |
|
36 | 36 | |
37 | - // /** |
|
38 | - // * @var RegistrantData |
|
39 | - // */ |
|
40 | - // private $registrant_data; |
|
41 | - // |
|
42 | - // /** |
|
43 | - // * @var array |
|
44 | - // */ |
|
45 | - // private $required_questions; |
|
37 | + // /** |
|
38 | + // * @var RegistrantData |
|
39 | + // */ |
|
40 | + // private $registrant_data; |
|
41 | + // |
|
42 | + // /** |
|
43 | + // * @var array |
|
44 | + // */ |
|
45 | + // private $required_questions; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * RegFormHandler constructor. |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - string $checkout_reg_url_link, |
|
53 | - array $required_questions, |
|
54 | - EEM_Attendee $attendee_model, |
|
55 | - RegistrantData $registrant_data, |
|
56 | - SystemInputFieldNames $system_input_field_names |
|
57 | - ) { |
|
58 | - parent::__construct( |
|
59 | - $checkout_reg_url_link, |
|
60 | - $required_questions, |
|
61 | - $attendee_model, |
|
62 | - $registrant_data, |
|
63 | - $system_input_field_names |
|
64 | - ); |
|
65 | - } |
|
48 | + /** |
|
49 | + * RegFormHandler constructor. |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + string $checkout_reg_url_link, |
|
53 | + array $required_questions, |
|
54 | + EEM_Attendee $attendee_model, |
|
55 | + RegistrantData $registrant_data, |
|
56 | + SystemInputFieldNames $system_input_field_names |
|
57 | + ) { |
|
58 | + parent::__construct( |
|
59 | + $checkout_reg_url_link, |
|
60 | + $required_questions, |
|
61 | + $attendee_model, |
|
62 | + $registrant_data, |
|
63 | + $system_input_field_names |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - // /** |
|
69 | - // * @param EE_Registration $registration |
|
70 | - // * @param string $reg_url_link |
|
71 | - // * @param int|string $form_input |
|
72 | - // * @param float|int|string $input_value |
|
73 | - // * @return bool |
|
74 | - // * @throws EE_Error |
|
75 | - // * @throws ReflectionException |
|
76 | - // */ |
|
77 | - // public function processFormInput( |
|
78 | - // EE_Registration $registration, |
|
79 | - // string $reg_url_link, |
|
80 | - // $form_input, |
|
81 | - // $input_value |
|
82 | - // ): bool { |
|
83 | - // // check for critical inputs |
|
84 | - // if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
85 | - // return false; |
|
86 | - // } |
|
87 | - // $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
88 | - // $reg_url_link, |
|
89 | - // $form_input, |
|
90 | - // $input_value |
|
91 | - // ); |
|
92 | - // if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
93 | - // EE_Error::add_error( |
|
94 | - // sprintf( |
|
95 | - // esc_html_x( |
|
96 | - // 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
97 | - // 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
98 | - // 'event_espresso' |
|
99 | - // ), |
|
100 | - // $form_input, |
|
101 | - // $input_value |
|
102 | - // ), |
|
103 | - // __FILE__, |
|
104 | - // __FUNCTION__, |
|
105 | - // __LINE__ |
|
106 | - // ); |
|
107 | - // return false; |
|
108 | - // } |
|
109 | - // return true; |
|
110 | - // } |
|
68 | + // /** |
|
69 | + // * @param EE_Registration $registration |
|
70 | + // * @param string $reg_url_link |
|
71 | + // * @param int|string $form_input |
|
72 | + // * @param float|int|string $input_value |
|
73 | + // * @return bool |
|
74 | + // * @throws EE_Error |
|
75 | + // * @throws ReflectionException |
|
76 | + // */ |
|
77 | + // public function processFormInput( |
|
78 | + // EE_Registration $registration, |
|
79 | + // string $reg_url_link, |
|
80 | + // $form_input, |
|
81 | + // $input_value |
|
82 | + // ): bool { |
|
83 | + // // check for critical inputs |
|
84 | + // if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
85 | + // return false; |
|
86 | + // } |
|
87 | + // $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
88 | + // $reg_url_link, |
|
89 | + // $form_input, |
|
90 | + // $input_value |
|
91 | + // ); |
|
92 | + // if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
93 | + // EE_Error::add_error( |
|
94 | + // sprintf( |
|
95 | + // esc_html_x( |
|
96 | + // 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
97 | + // 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
98 | + // 'event_espresso' |
|
99 | + // ), |
|
100 | + // $form_input, |
|
101 | + // $input_value |
|
102 | + // ), |
|
103 | + // __FILE__, |
|
104 | + // __FUNCTION__, |
|
105 | + // __LINE__ |
|
106 | + // ); |
|
107 | + // return false; |
|
108 | + // } |
|
109 | + // return true; |
|
110 | + // } |
|
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * @param EE_Registration $registration |
|
115 | - * @param string $reg_url_link |
|
116 | - * @param int|string $field |
|
117 | - * @param float|int|string $value |
|
118 | - * @return bool |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidArgumentException |
|
121 | - * @throws InvalidDataTypeException |
|
122 | - * @throws InvalidInterfaceException |
|
123 | - * @throws ReflectionException |
|
124 | - */ |
|
125 | - protected function saveRegistrationFormInput( |
|
126 | - EE_Registration $registration, |
|
127 | - string $reg_url_link, |
|
128 | - $field = '', |
|
129 | - $value = '' |
|
130 | - ): bool { |
|
131 | - // echo '<br />'; |
|
132 | - \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 1); |
|
133 | - \EEH_Debug_Tools::printr($field, '$field', '', __LINE__); |
|
134 | - \EEH_Debug_Tools::printr($value, '$value', '', __LINE__); |
|
135 | - // echo '<br />'; |
|
136 | - if ($this->bypassSaveRegFormInputValue($registration, $field, $value)) { |
|
137 | - echo '<br />@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br />'; |
|
138 | - return true; |
|
139 | - } |
|
140 | - /* |
|
113 | + /** |
|
114 | + * @param EE_Registration $registration |
|
115 | + * @param string $reg_url_link |
|
116 | + * @param int|string $field |
|
117 | + * @param float|int|string $value |
|
118 | + * @return bool |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidArgumentException |
|
121 | + * @throws InvalidDataTypeException |
|
122 | + * @throws InvalidInterfaceException |
|
123 | + * @throws ReflectionException |
|
124 | + */ |
|
125 | + protected function saveRegistrationFormInput( |
|
126 | + EE_Registration $registration, |
|
127 | + string $reg_url_link, |
|
128 | + $field = '', |
|
129 | + $value = '' |
|
130 | + ): bool { |
|
131 | + // echo '<br />'; |
|
132 | + \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 1); |
|
133 | + \EEH_Debug_Tools::printr($field, '$field', '', __LINE__); |
|
134 | + \EEH_Debug_Tools::printr($value, '$value', '', __LINE__); |
|
135 | + // echo '<br />'; |
|
136 | + if ($this->bypassSaveRegFormInputValue($registration, $field, $value)) { |
|
137 | + echo '<br />@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br />'; |
|
138 | + return true; |
|
139 | + } |
|
140 | + /* |
|
141 | 141 | * $answer_cache_id is the key used to find the EE_Answer we want |
142 | 142 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
143 | 143 | */ |
144 | - $answer_cache_id = $this->checkout_reg_url_link |
|
145 | - ? $field . '-' . $reg_url_link |
|
146 | - : $field; |
|
147 | - \EEH_Debug_Tools::printr($answer_cache_id, '$answer_cache_id', __FILE__, __LINE__); |
|
144 | + $answer_cache_id = $this->checkout_reg_url_link |
|
145 | + ? $field . '-' . $reg_url_link |
|
146 | + : $field; |
|
147 | + \EEH_Debug_Tools::printr($answer_cache_id, '$answer_cache_id', __FILE__, __LINE__); |
|
148 | 148 | |
149 | - $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
150 | - \EEH_Debug_Tools::printr($registrant_answer, '$registrant_answer', __FILE__, __LINE__); |
|
151 | - // $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
152 | - // \EEH_Debug_Tools::printr($answer_is_obj, '$answer_is_obj', __FILE__, __LINE__); |
|
153 | - // if this form input has a corresponding attendee property |
|
154 | - if ($this->isAttendeeProperty($field)) { |
|
155 | - // rename form_inputs if they are EE_Attendee properties |
|
156 | - $field = $this->renameFormInput($field); |
|
157 | - \EEH_Debug_Tools::printr($field, '$field', __FILE__, __LINE__); |
|
158 | - $this->registrant_data->addRegistrantDataValue($reg_url_link, $field, $value); |
|
159 | - // if ($answer_is_obj) { |
|
160 | - // // and delete the corresponding answer since we won't be storing this data in that object |
|
161 | - // $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
162 | - // $registrant_answer->delete_permanently(); |
|
163 | - // } |
|
164 | - return true; |
|
165 | - } |
|
166 | - // if ($answer_is_obj) { |
|
167 | - // // save this data to the answer object |
|
168 | - // $registrant_answer->set_value($value); |
|
169 | - // $result = $registrant_answer->save(); |
|
170 | - // return $result !== false; |
|
171 | - // } |
|
172 | - // foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
173 | - // if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
174 | - // $answer->set_value($value); |
|
175 | - // $result = $answer->save(); |
|
176 | - // return $result !== false; |
|
177 | - // } |
|
178 | - // } |
|
179 | - echo '<br />*********************************************************<br />'; |
|
180 | - return false; |
|
181 | - } |
|
149 | + $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
150 | + \EEH_Debug_Tools::printr($registrant_answer, '$registrant_answer', __FILE__, __LINE__); |
|
151 | + // $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
152 | + // \EEH_Debug_Tools::printr($answer_is_obj, '$answer_is_obj', __FILE__, __LINE__); |
|
153 | + // if this form input has a corresponding attendee property |
|
154 | + if ($this->isAttendeeProperty($field)) { |
|
155 | + // rename form_inputs if they are EE_Attendee properties |
|
156 | + $field = $this->renameFormInput($field); |
|
157 | + \EEH_Debug_Tools::printr($field, '$field', __FILE__, __LINE__); |
|
158 | + $this->registrant_data->addRegistrantDataValue($reg_url_link, $field, $value); |
|
159 | + // if ($answer_is_obj) { |
|
160 | + // // and delete the corresponding answer since we won't be storing this data in that object |
|
161 | + // $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
162 | + // $registrant_answer->delete_permanently(); |
|
163 | + // } |
|
164 | + return true; |
|
165 | + } |
|
166 | + // if ($answer_is_obj) { |
|
167 | + // // save this data to the answer object |
|
168 | + // $registrant_answer->set_value($value); |
|
169 | + // $result = $registrant_answer->save(); |
|
170 | + // return $result !== false; |
|
171 | + // } |
|
172 | + // foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
173 | + // if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
174 | + // $answer->set_value($value); |
|
175 | + // $result = $answer->save(); |
|
176 | + // return $result !== false; |
|
177 | + // } |
|
178 | + // } |
|
179 | + echo '<br />*********************************************************<br />'; |
|
180 | + return false; |
|
181 | + } |
|
182 | 182 | |
183 | 183 | |
184 | - // /** |
|
185 | - // * @param EE_Registration $registration |
|
186 | - // * @param string $form_input |
|
187 | - // * @param mixed $input_value |
|
188 | - // * @return bool |
|
189 | - // */ |
|
190 | - // private function bypassSaveRegFormInputValue(EE_Registration $registration, string $form_input, $input_value): bool |
|
191 | - // { |
|
192 | - // // If email_confirm is sent it's not saved |
|
193 | - // if ($form_input === 'email_confirm') { |
|
194 | - // return true; |
|
195 | - // } |
|
196 | - // // allow for plugins to hook in and do their own processing of the form input. |
|
197 | - // // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
198 | - // // NOTE: this hook does the opposite of what its name implies... |
|
199 | - // // ie: returning true does NOT save the input here, meaning it needs to be saved externally. |
|
200 | - // // This should have been named something like "bypass_save_registration_form_input" |
|
201 | - // return filter_var( |
|
202 | - // apply_filters( |
|
203 | - // 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
204 | - // false, |
|
205 | - // $registration, |
|
206 | - // $form_input, |
|
207 | - // $input_value, |
|
208 | - // $this |
|
209 | - // ), |
|
210 | - // FILTER_VALIDATE_BOOLEAN |
|
211 | - // ); |
|
212 | - // } |
|
184 | + // /** |
|
185 | + // * @param EE_Registration $registration |
|
186 | + // * @param string $form_input |
|
187 | + // * @param mixed $input_value |
|
188 | + // * @return bool |
|
189 | + // */ |
|
190 | + // private function bypassSaveRegFormInputValue(EE_Registration $registration, string $form_input, $input_value): bool |
|
191 | + // { |
|
192 | + // // If email_confirm is sent it's not saved |
|
193 | + // if ($form_input === 'email_confirm') { |
|
194 | + // return true; |
|
195 | + // } |
|
196 | + // // allow for plugins to hook in and do their own processing of the form input. |
|
197 | + // // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
198 | + // // NOTE: this hook does the opposite of what its name implies... |
|
199 | + // // ie: returning true does NOT save the input here, meaning it needs to be saved externally. |
|
200 | + // // This should have been named something like "bypass_save_registration_form_input" |
|
201 | + // return filter_var( |
|
202 | + // apply_filters( |
|
203 | + // 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
204 | + // false, |
|
205 | + // $registration, |
|
206 | + // $form_input, |
|
207 | + // $input_value, |
|
208 | + // $this |
|
209 | + // ), |
|
210 | + // FILTER_VALIDATE_BOOLEAN |
|
211 | + // ); |
|
212 | + // } |
|
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * @param string $field |
|
217 | - * @return bool |
|
218 | - */ |
|
219 | - private function isAttendeeProperty(string $field): bool |
|
220 | - { |
|
221 | - // $this->reg_form_input_factory |
|
222 | - switch ($field) { |
|
223 | - case 'state': |
|
224 | - case 'STA_ID': |
|
225 | - case 'country': |
|
226 | - case 'CNT_ISO': |
|
227 | - return true; |
|
228 | - default: |
|
229 | - return $this->attendee_model->has_field("ATT_$field"); |
|
230 | - } |
|
231 | - } |
|
215 | + /** |
|
216 | + * @param string $field |
|
217 | + * @return bool |
|
218 | + */ |
|
219 | + private function isAttendeeProperty(string $field): bool |
|
220 | + { |
|
221 | + // $this->reg_form_input_factory |
|
222 | + switch ($field) { |
|
223 | + case 'state': |
|
224 | + case 'STA_ID': |
|
225 | + case 'country': |
|
226 | + case 'CNT_ISO': |
|
227 | + return true; |
|
228 | + default: |
|
229 | + return $this->attendee_model->has_field("ATT_$field"); |
|
230 | + } |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - // /** |
|
235 | - // * @param string $field |
|
236 | - // * @return string |
|
237 | - // */ |
|
238 | - // private function renameFormInput(string $field): string |
|
239 | - // { |
|
240 | - // switch ($field) { |
|
241 | - // case 'state': |
|
242 | - // case 'STA_ID': |
|
243 | - // return 'STA_ID'; |
|
244 | - // |
|
245 | - // case 'country': |
|
246 | - // case 'CNT_ISO': |
|
247 | - // return 'CNT_ISO'; |
|
248 | - // |
|
249 | - // default: |
|
250 | - // return "ATT_$field"; |
|
251 | - // } |
|
252 | - // } |
|
234 | + // /** |
|
235 | + // * @param string $field |
|
236 | + // * @return string |
|
237 | + // */ |
|
238 | + // private function renameFormInput(string $field): string |
|
239 | + // { |
|
240 | + // switch ($field) { |
|
241 | + // case 'state': |
|
242 | + // case 'STA_ID': |
|
243 | + // return 'STA_ID'; |
|
244 | + // |
|
245 | + // case 'country': |
|
246 | + // case 'CNT_ISO': |
|
247 | + // return 'CNT_ISO'; |
|
248 | + // |
|
249 | + // default: |
|
250 | + // return "ATT_$field"; |
|
251 | + // } |
|
252 | + // } |
|
253 | 253 | |
254 | 254 | |
255 | - /** |
|
256 | - * @param int|string $field |
|
257 | - * @param float|int|string $value |
|
258 | - * @return boolean |
|
259 | - */ |
|
260 | - private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
261 | - $field = '', |
|
262 | - $value = '' |
|
263 | - ): bool { |
|
264 | - if (empty($value)) { |
|
265 | - // if the form input isn't marked as being required, then just return |
|
266 | - if (! isset($this->required_questions[ $field ]) || ! $this->required_questions[ $field ]) { |
|
267 | - return true; |
|
268 | - } |
|
269 | - switch ($field) { |
|
270 | - case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::FIRST_NAME): |
|
271 | - EE_Error::add_error( |
|
272 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
273 | - __FILE__, |
|
274 | - __FUNCTION__, |
|
275 | - __LINE__ |
|
276 | - ); |
|
277 | - return false; |
|
278 | - case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::LAST_NAME): |
|
279 | - EE_Error::add_error( |
|
280 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
281 | - __FILE__, |
|
282 | - __FUNCTION__, |
|
283 | - __LINE__ |
|
284 | - ); |
|
285 | - return false; |
|
286 | - case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::EMAIL): |
|
287 | - EE_Error::add_error( |
|
288 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
289 | - __FILE__, |
|
290 | - __FUNCTION__, |
|
291 | - __LINE__ |
|
292 | - ); |
|
293 | - return false; |
|
294 | - } |
|
295 | - } |
|
296 | - return true; |
|
297 | - } |
|
255 | + /** |
|
256 | + * @param int|string $field |
|
257 | + * @param float|int|string $value |
|
258 | + * @return boolean |
|
259 | + */ |
|
260 | + private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
261 | + $field = '', |
|
262 | + $value = '' |
|
263 | + ): bool { |
|
264 | + if (empty($value)) { |
|
265 | + // if the form input isn't marked as being required, then just return |
|
266 | + if (! isset($this->required_questions[ $field ]) || ! $this->required_questions[ $field ]) { |
|
267 | + return true; |
|
268 | + } |
|
269 | + switch ($field) { |
|
270 | + case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::FIRST_NAME): |
|
271 | + EE_Error::add_error( |
|
272 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
273 | + __FILE__, |
|
274 | + __FUNCTION__, |
|
275 | + __LINE__ |
|
276 | + ); |
|
277 | + return false; |
|
278 | + case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::LAST_NAME): |
|
279 | + EE_Error::add_error( |
|
280 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
281 | + __FILE__, |
|
282 | + __FUNCTION__, |
|
283 | + __LINE__ |
|
284 | + ); |
|
285 | + return false; |
|
286 | + case $this->system_input_field_names->getInputName(SystemInputFieldNamesInterface::EMAIL): |
|
287 | + EE_Error::add_error( |
|
288 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
289 | + __FILE__, |
|
290 | + __FUNCTION__, |
|
291 | + __LINE__ |
|
292 | + ); |
|
293 | + return false; |
|
294 | + } |
|
295 | + } |
|
296 | + return true; |
|
297 | + } |
|
298 | 298 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
143 | 143 | */ |
144 | 144 | $answer_cache_id = $this->checkout_reg_url_link |
145 | - ? $field . '-' . $reg_url_link |
|
145 | + ? $field.'-'.$reg_url_link |
|
146 | 146 | : $field; |
147 | 147 | \EEH_Debug_Tools::printr($answer_cache_id, '$answer_cache_id', __FILE__, __LINE__); |
148 | 148 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | ): bool { |
264 | 264 | if (empty($value)) { |
265 | 265 | // if the form input isn't marked as being required, then just return |
266 | - if (! isset($this->required_questions[ $field ]) || ! $this->required_questions[ $field ]) { |
|
266 | + if ( ! isset($this->required_questions[$field]) || ! $this->required_questions[$field]) { |
|
267 | 267 | return true; |
268 | 268 | } |
269 | 269 | switch ($field) { |
@@ -16,62 +16,62 @@ |
||
16 | 16 | |
17 | 17 | class FormInputValidationStrategies |
18 | 18 | { |
19 | - /** |
|
20 | - * @var FieldLengthCalculator |
|
21 | - */ |
|
22 | - public $field_length_calculator; |
|
19 | + /** |
|
20 | + * @var FieldLengthCalculator |
|
21 | + */ |
|
22 | + public $field_length_calculator; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * FormInputFactory constructor. |
|
27 | - * |
|
28 | - * @param FieldLengthCalculator $field_length_calculator |
|
29 | - */ |
|
30 | - public function __construct(FieldLengthCalculator $field_length_calculator) |
|
31 | - { |
|
32 | - $this->field_length_calculator = $field_length_calculator; |
|
33 | - } |
|
25 | + /** |
|
26 | + * FormInputFactory constructor. |
|
27 | + * |
|
28 | + * @param FieldLengthCalculator $field_length_calculator |
|
29 | + */ |
|
30 | + public function __construct(FieldLengthCalculator $field_length_calculator) |
|
31 | + { |
|
32 | + $this->field_length_calculator = $field_length_calculator; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param EE_Form_Element $form_input |
|
38 | - * @param array $input_args |
|
39 | - * @return array |
|
40 | - * @throws EE_Error |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - public function applyValidationStrategies(EE_Form_Element $form_input, array $input_args): array |
|
44 | - { |
|
45 | - if ($form_input->getAttribute('max') !== EE_INF || $form_input->mapsTo()) { |
|
46 | - $max_field_length = $this->field_length_calculator->getMaxFieldLengthForInput($form_input); |
|
47 | - if ($max_field_length !== EE_INF) { |
|
48 | - $input_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
49 | - null, |
|
50 | - $max_field_length |
|
51 | - ); |
|
52 | - } |
|
53 | - } |
|
54 | - if ($form_input->getAttribute('min') > 0 || $form_input->mapsTo()) { |
|
55 | - $min_field_length = $this->field_length_calculator->getMinFieldLengthForInput($form_input); |
|
56 | - if ($min_field_length !== EE_INF) { |
|
57 | - $input_args['validation_strategies'][] = new EE_Min_Length_Validation_Strategy( |
|
58 | - null, |
|
59 | - $min_field_length |
|
60 | - ); |
|
61 | - } |
|
62 | - } |
|
36 | + /** |
|
37 | + * @param EE_Form_Element $form_input |
|
38 | + * @param array $input_args |
|
39 | + * @return array |
|
40 | + * @throws EE_Error |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + public function applyValidationStrategies(EE_Form_Element $form_input, array $input_args): array |
|
44 | + { |
|
45 | + if ($form_input->getAttribute('max') !== EE_INF || $form_input->mapsTo()) { |
|
46 | + $max_field_length = $this->field_length_calculator->getMaxFieldLengthForInput($form_input); |
|
47 | + if ($max_field_length !== EE_INF) { |
|
48 | + $input_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
49 | + null, |
|
50 | + $max_field_length |
|
51 | + ); |
|
52 | + } |
|
53 | + } |
|
54 | + if ($form_input->getAttribute('min') > 0 || $form_input->mapsTo()) { |
|
55 | + $min_field_length = $this->field_length_calculator->getMinFieldLengthForInput($form_input); |
|
56 | + if ($min_field_length !== EE_INF) { |
|
57 | + $input_args['validation_strategies'][] = new EE_Min_Length_Validation_Strategy( |
|
58 | + null, |
|
59 | + $min_field_length |
|
60 | + ); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - if ($form_input->type() === Text::TYPE_TEXTAREA) { |
|
65 | - $input_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
66 | - } |
|
64 | + if ($form_input->type() === Text::TYPE_TEXTAREA) { |
|
65 | + $input_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
66 | + } |
|
67 | 67 | |
68 | - if ($form_input->type() === Text::TYPE_TEXTAREA_HTML) { |
|
69 | - $input_args['validation_strategies'][] = new EE_Full_HTML_Validation_Strategy(); |
|
70 | - } |
|
68 | + if ($form_input->type() === Text::TYPE_TEXTAREA_HTML) { |
|
69 | + $input_args['validation_strategies'][] = new EE_Full_HTML_Validation_Strategy(); |
|
70 | + } |
|
71 | 71 | |
72 | - if ($form_input->type() === Input::TYPE_URL) { |
|
73 | - $input_args['validation_strategies'][] = LoaderFactory::getNew(EE_URL_Validation_Strategy::class); |
|
74 | - } |
|
75 | - return $input_args; |
|
76 | - } |
|
72 | + if ($form_input->type() === Input::TYPE_URL) { |
|
73 | + $input_args['validation_strategies'][] = LoaderFactory::getNew(EE_URL_Validation_Strategy::class); |
|
74 | + } |
|
75 | + return $input_args; |
|
76 | + } |
|
77 | 77 | } |
@@ -34,225 +34,225 @@ |
||
34 | 34 | |
35 | 35 | class FormInputFactory |
36 | 36 | { |
37 | - /** |
|
38 | - * @var stdClass |
|
39 | - */ |
|
40 | - private $config; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var FormInputValidationStrategies |
|
44 | - */ |
|
45 | - public $validation_strategies; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * FormInputFactory constructor. |
|
50 | - * |
|
51 | - * @param FormInputValidationStrategies $validation_strategies |
|
52 | - */ |
|
53 | - public function __construct(FormInputValidationStrategies $validation_strategies) |
|
54 | - { |
|
55 | - $this->validation_strategies = $validation_strategies; |
|
56 | - $this->config = new stdClass(); |
|
57 | - $days = range(1, 31); |
|
58 | - $months = range(1, 12); |
|
59 | - $this->config->days = array_combine($days, $days); |
|
60 | - $this->config->months = array_combine($months, $months); |
|
61 | - $this->config->year_input = new stdClass(); |
|
62 | - $this->config->year_input->four_digit = (bool) apply_filters( |
|
63 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
64 | - true, |
|
65 | - $this |
|
66 | - ); |
|
67 | - $this->config->year_input->early_range = (int) apply_filters( |
|
68 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
69 | - 100, |
|
70 | - $this |
|
71 | - ); |
|
72 | - $this->config->year_input->end_range = (int) apply_filters( |
|
73 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
74 | - 100, |
|
75 | - $this |
|
76 | - ); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param EE_Registration $registration |
|
82 | - * @param EE_Form_Element $form_input |
|
83 | - * @param int|float|string $answer |
|
84 | - * @return EE_Form_Input_Base|null |
|
85 | - * @throws EE_Error |
|
86 | - * @throws ReflectionException |
|
87 | - */ |
|
88 | - public function create( |
|
89 | - EE_Registration $registration, |
|
90 | - EE_Form_Element $form_input, |
|
91 | - $answer |
|
92 | - ): ?EE_Form_Input_Base { |
|
93 | - $input_args = (array) apply_filters( |
|
94 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
95 | - $this->generateInputArgs($registration, $form_input, $answer), |
|
96 | - $registration, |
|
97 | - $this, |
|
98 | - $answer |
|
99 | - ); |
|
100 | - return $this->getInput($form_input, $input_args); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @param EE_Registration $registration |
|
106 | - * @param EE_Form_Element $form_input |
|
107 | - * @param int|float|string $answer |
|
108 | - * @return array |
|
109 | - * @throws EE_Error |
|
110 | - * @throws ReflectionException |
|
111 | - */ |
|
112 | - private function generateInputArgs(EE_Registration $registration, EE_Form_Element $form_input, $answer): array |
|
113 | - { |
|
114 | - $identifier = $form_input->slug(); |
|
115 | - $reg_id = $registration->ID(); |
|
116 | - $label = $form_input->label(); |
|
117 | - $required = $form_input->required(); |
|
118 | - // group_name |
|
119 | - $input_args = [ |
|
120 | - 'default' => $answer, |
|
121 | - 'html_name' => "ee_reg_qstn[$reg_id][$identifier]", |
|
122 | - 'html_id' => "ee_reg_qstn-$reg_id-$identifier", |
|
123 | - 'html_class' => "ee-reg-qstn ee-reg-qstn-$identifier", |
|
124 | - 'html_label_id' => "ee_reg_qstn-$reg_id-$identifier-lbl", |
|
125 | - 'html_label_class' => 'ee-reg-qstn', |
|
126 | - 'html_label_text' => $label instanceof FormLabel ? $label->publicLabel() : '', |
|
127 | - 'required' => $required instanceof Required ? $required->isRequired() : false, |
|
128 | - 'required_validation_error_message' => $required instanceof Required ? $required->validationText() : '', |
|
129 | - ]; |
|
130 | - return $this->validation_strategies->applyValidationStrategies($form_input, $input_args); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param EE_Form_Element $form_input |
|
136 | - * @param array $input_args |
|
137 | - * @return EE_Form_Input_Base|null |
|
138 | - * @throws EE_Error |
|
139 | - * @throws ReflectionException |
|
140 | - */ |
|
141 | - private function getInput(EE_Form_Element $form_input, array $input_args): ?EE_Form_Input_Base |
|
142 | - { |
|
143 | - $input_options = $form_input->options(); |
|
144 | - $options = $input_options instanceof InputOptions ? $input_options->options() : []; |
|
145 | - switch ($form_input->type()) { |
|
146 | - |
|
147 | - // date type inputs |
|
148 | - case DateTime::TYPE_DATE: |
|
149 | - return new EE_Datepicker_Input($input_args); |
|
150 | - |
|
151 | - case DateTime::TYPE_DATETIME_LOCAL: |
|
152 | - $input_args['type'] = 'datetime-local'; |
|
153 | - return new EE_Text_Input($input_args); |
|
154 | - |
|
155 | - case DateTime::TYPE_MONTH: |
|
156 | - $input_args['type'] = 'month'; |
|
157 | - return new EE_Text_Input($input_args); |
|
158 | - |
|
159 | - case DateTime::TYPE_TIME: |
|
160 | - $input_args['type'] = 'time'; |
|
161 | - return new EE_Text_Input($input_args); |
|
162 | - |
|
163 | - case DateTime::TYPE_WEEK: |
|
164 | - $input_args['type'] = 'week'; |
|
165 | - return new EE_Text_Input($input_args); |
|
166 | - |
|
167 | - case DateTime::TYPE_SELECT_DAY: |
|
168 | - return new EE_Select_Input($this->config->days, $input_args); |
|
169 | - |
|
170 | - case DateTime::TYPE_SELECT_MONTH: |
|
171 | - return new EE_Select_Input($this->config->months, $input_args); |
|
172 | - |
|
173 | - case DateTime::TYPE_SELECT_YEAR: |
|
174 | - return new EE_Year_Input( |
|
175 | - $input_args, |
|
176 | - $this->config->year_input->four_digit, |
|
177 | - $this->config->year_input->early_range, |
|
178 | - $this->config->year_input->end_range |
|
179 | - ); |
|
180 | - |
|
181 | - // input type inputs (???) |
|
182 | - case Input::TYPE_CHECKBOX: |
|
183 | - return new EE_Checkbox_Multi_Input($options, $input_args); |
|
184 | - |
|
185 | - case Input::TYPE_COLOR: |
|
186 | - $input_args['type'] = 'color'; |
|
187 | - return new EE_Text_Input($input_args); |
|
188 | - |
|
189 | - case Input::TYPE_FILE: |
|
190 | - $input_args['type'] = 'file'; |
|
191 | - return new EE_Text_Input($input_args); |
|
192 | - |
|
193 | - case Input::TYPE_HIDDEN: |
|
194 | - $input_args['type'] = 'hidden'; |
|
195 | - return new EE_Text_Input($input_args); |
|
196 | - |
|
197 | - case Input::TYPE_IMAGE: |
|
198 | - $input_args['type'] = 'image'; |
|
199 | - return new EE_Text_Input($input_args); |
|
200 | - |
|
201 | - case Input::TYPE_PASSWORD: |
|
202 | - $input_args['type'] = 'password'; |
|
203 | - return new EE_Text_Input($input_args); |
|
204 | - |
|
205 | - case Input::TYPE_URL: |
|
206 | - $input_args['type'] = 'url'; |
|
207 | - return new EE_Text_Input($input_args); |
|
208 | - |
|
209 | - case Input::TYPE_RADIO: |
|
210 | - return new EE_Radio_Button_Input($options, $input_args); |
|
211 | - |
|
212 | - // numeric type inputs |
|
213 | - case Number::TYPE_FLOAT: |
|
214 | - return new EE_Float_Input($input_args); |
|
215 | - |
|
216 | - case Number::TYPE_INT: |
|
217 | - return new EE_Integer_Input($input_args); |
|
218 | - |
|
219 | - case Number::TYPE_RANGE: |
|
220 | - $input_args['type'] = 'range'; |
|
221 | - return new EE_Text_Input($input_args); |
|
222 | - |
|
223 | - // phone type inputs |
|
224 | - case Phone::INPUT_TYPE: |
|
225 | - $input_args['type'] = 'tel'; |
|
226 | - return new EE_Text_Input($input_args); |
|
227 | - // return new EE_Phone_Input($input_args); |
|
228 | - |
|
229 | - // select type inputs |
|
230 | - case Select::TYPE_SELECT: |
|
231 | - return new EE_Select_Input($options, $input_args); |
|
232 | - |
|
233 | - case Select::TYPE_SELECT_COUNTRY: |
|
234 | - return new EE_Country_Select_Input([], $input_args); |
|
235 | - |
|
236 | - case Select::TYPE_SELECT_STATE: |
|
237 | - return new EE_State_Select_Input([], $input_args); |
|
238 | - |
|
239 | - case Select::TYPE_SELECT_MULTI: |
|
240 | - return new EE_Select_Multiple_Input($options, $input_args); |
|
241 | - |
|
242 | - // text type inputs |
|
243 | - case Text::TYPE_TEXTAREA: |
|
244 | - case Text::TYPE_TEXTAREA_HTML: |
|
245 | - return new EE_Text_Area_Input($input_args); |
|
37 | + /** |
|
38 | + * @var stdClass |
|
39 | + */ |
|
40 | + private $config; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var FormInputValidationStrategies |
|
44 | + */ |
|
45 | + public $validation_strategies; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * FormInputFactory constructor. |
|
50 | + * |
|
51 | + * @param FormInputValidationStrategies $validation_strategies |
|
52 | + */ |
|
53 | + public function __construct(FormInputValidationStrategies $validation_strategies) |
|
54 | + { |
|
55 | + $this->validation_strategies = $validation_strategies; |
|
56 | + $this->config = new stdClass(); |
|
57 | + $days = range(1, 31); |
|
58 | + $months = range(1, 12); |
|
59 | + $this->config->days = array_combine($days, $days); |
|
60 | + $this->config->months = array_combine($months, $months); |
|
61 | + $this->config->year_input = new stdClass(); |
|
62 | + $this->config->year_input->four_digit = (bool) apply_filters( |
|
63 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
64 | + true, |
|
65 | + $this |
|
66 | + ); |
|
67 | + $this->config->year_input->early_range = (int) apply_filters( |
|
68 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
69 | + 100, |
|
70 | + $this |
|
71 | + ); |
|
72 | + $this->config->year_input->end_range = (int) apply_filters( |
|
73 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
74 | + 100, |
|
75 | + $this |
|
76 | + ); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param EE_Registration $registration |
|
82 | + * @param EE_Form_Element $form_input |
|
83 | + * @param int|float|string $answer |
|
84 | + * @return EE_Form_Input_Base|null |
|
85 | + * @throws EE_Error |
|
86 | + * @throws ReflectionException |
|
87 | + */ |
|
88 | + public function create( |
|
89 | + EE_Registration $registration, |
|
90 | + EE_Form_Element $form_input, |
|
91 | + $answer |
|
92 | + ): ?EE_Form_Input_Base { |
|
93 | + $input_args = (array) apply_filters( |
|
94 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
95 | + $this->generateInputArgs($registration, $form_input, $answer), |
|
96 | + $registration, |
|
97 | + $this, |
|
98 | + $answer |
|
99 | + ); |
|
100 | + return $this->getInput($form_input, $input_args); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @param EE_Registration $registration |
|
106 | + * @param EE_Form_Element $form_input |
|
107 | + * @param int|float|string $answer |
|
108 | + * @return array |
|
109 | + * @throws EE_Error |
|
110 | + * @throws ReflectionException |
|
111 | + */ |
|
112 | + private function generateInputArgs(EE_Registration $registration, EE_Form_Element $form_input, $answer): array |
|
113 | + { |
|
114 | + $identifier = $form_input->slug(); |
|
115 | + $reg_id = $registration->ID(); |
|
116 | + $label = $form_input->label(); |
|
117 | + $required = $form_input->required(); |
|
118 | + // group_name |
|
119 | + $input_args = [ |
|
120 | + 'default' => $answer, |
|
121 | + 'html_name' => "ee_reg_qstn[$reg_id][$identifier]", |
|
122 | + 'html_id' => "ee_reg_qstn-$reg_id-$identifier", |
|
123 | + 'html_class' => "ee-reg-qstn ee-reg-qstn-$identifier", |
|
124 | + 'html_label_id' => "ee_reg_qstn-$reg_id-$identifier-lbl", |
|
125 | + 'html_label_class' => 'ee-reg-qstn', |
|
126 | + 'html_label_text' => $label instanceof FormLabel ? $label->publicLabel() : '', |
|
127 | + 'required' => $required instanceof Required ? $required->isRequired() : false, |
|
128 | + 'required_validation_error_message' => $required instanceof Required ? $required->validationText() : '', |
|
129 | + ]; |
|
130 | + return $this->validation_strategies->applyValidationStrategies($form_input, $input_args); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param EE_Form_Element $form_input |
|
136 | + * @param array $input_args |
|
137 | + * @return EE_Form_Input_Base|null |
|
138 | + * @throws EE_Error |
|
139 | + * @throws ReflectionException |
|
140 | + */ |
|
141 | + private function getInput(EE_Form_Element $form_input, array $input_args): ?EE_Form_Input_Base |
|
142 | + { |
|
143 | + $input_options = $form_input->options(); |
|
144 | + $options = $input_options instanceof InputOptions ? $input_options->options() : []; |
|
145 | + switch ($form_input->type()) { |
|
146 | + |
|
147 | + // date type inputs |
|
148 | + case DateTime::TYPE_DATE: |
|
149 | + return new EE_Datepicker_Input($input_args); |
|
150 | + |
|
151 | + case DateTime::TYPE_DATETIME_LOCAL: |
|
152 | + $input_args['type'] = 'datetime-local'; |
|
153 | + return new EE_Text_Input($input_args); |
|
154 | + |
|
155 | + case DateTime::TYPE_MONTH: |
|
156 | + $input_args['type'] = 'month'; |
|
157 | + return new EE_Text_Input($input_args); |
|
158 | + |
|
159 | + case DateTime::TYPE_TIME: |
|
160 | + $input_args['type'] = 'time'; |
|
161 | + return new EE_Text_Input($input_args); |
|
162 | + |
|
163 | + case DateTime::TYPE_WEEK: |
|
164 | + $input_args['type'] = 'week'; |
|
165 | + return new EE_Text_Input($input_args); |
|
166 | + |
|
167 | + case DateTime::TYPE_SELECT_DAY: |
|
168 | + return new EE_Select_Input($this->config->days, $input_args); |
|
169 | + |
|
170 | + case DateTime::TYPE_SELECT_MONTH: |
|
171 | + return new EE_Select_Input($this->config->months, $input_args); |
|
172 | + |
|
173 | + case DateTime::TYPE_SELECT_YEAR: |
|
174 | + return new EE_Year_Input( |
|
175 | + $input_args, |
|
176 | + $this->config->year_input->four_digit, |
|
177 | + $this->config->year_input->early_range, |
|
178 | + $this->config->year_input->end_range |
|
179 | + ); |
|
180 | + |
|
181 | + // input type inputs (???) |
|
182 | + case Input::TYPE_CHECKBOX: |
|
183 | + return new EE_Checkbox_Multi_Input($options, $input_args); |
|
184 | + |
|
185 | + case Input::TYPE_COLOR: |
|
186 | + $input_args['type'] = 'color'; |
|
187 | + return new EE_Text_Input($input_args); |
|
188 | + |
|
189 | + case Input::TYPE_FILE: |
|
190 | + $input_args['type'] = 'file'; |
|
191 | + return new EE_Text_Input($input_args); |
|
192 | + |
|
193 | + case Input::TYPE_HIDDEN: |
|
194 | + $input_args['type'] = 'hidden'; |
|
195 | + return new EE_Text_Input($input_args); |
|
196 | + |
|
197 | + case Input::TYPE_IMAGE: |
|
198 | + $input_args['type'] = 'image'; |
|
199 | + return new EE_Text_Input($input_args); |
|
200 | + |
|
201 | + case Input::TYPE_PASSWORD: |
|
202 | + $input_args['type'] = 'password'; |
|
203 | + return new EE_Text_Input($input_args); |
|
204 | + |
|
205 | + case Input::TYPE_URL: |
|
206 | + $input_args['type'] = 'url'; |
|
207 | + return new EE_Text_Input($input_args); |
|
208 | + |
|
209 | + case Input::TYPE_RADIO: |
|
210 | + return new EE_Radio_Button_Input($options, $input_args); |
|
211 | + |
|
212 | + // numeric type inputs |
|
213 | + case Number::TYPE_FLOAT: |
|
214 | + return new EE_Float_Input($input_args); |
|
215 | + |
|
216 | + case Number::TYPE_INT: |
|
217 | + return new EE_Integer_Input($input_args); |
|
218 | + |
|
219 | + case Number::TYPE_RANGE: |
|
220 | + $input_args['type'] = 'range'; |
|
221 | + return new EE_Text_Input($input_args); |
|
222 | + |
|
223 | + // phone type inputs |
|
224 | + case Phone::INPUT_TYPE: |
|
225 | + $input_args['type'] = 'tel'; |
|
226 | + return new EE_Text_Input($input_args); |
|
227 | + // return new EE_Phone_Input($input_args); |
|
228 | + |
|
229 | + // select type inputs |
|
230 | + case Select::TYPE_SELECT: |
|
231 | + return new EE_Select_Input($options, $input_args); |
|
232 | + |
|
233 | + case Select::TYPE_SELECT_COUNTRY: |
|
234 | + return new EE_Country_Select_Input([], $input_args); |
|
235 | + |
|
236 | + case Select::TYPE_SELECT_STATE: |
|
237 | + return new EE_State_Select_Input([], $input_args); |
|
238 | + |
|
239 | + case Select::TYPE_SELECT_MULTI: |
|
240 | + return new EE_Select_Multiple_Input($options, $input_args); |
|
241 | + |
|
242 | + // text type inputs |
|
243 | + case Text::TYPE_TEXTAREA: |
|
244 | + case Text::TYPE_TEXTAREA_HTML: |
|
245 | + return new EE_Text_Area_Input($input_args); |
|
246 | 246 | |
247 | - case Text::TYPE_EMAIL: |
|
248 | - return new EE_Email_Input($input_args); |
|
247 | + case Text::TYPE_EMAIL: |
|
248 | + return new EE_Email_Input($input_args); |
|
249 | 249 | |
250 | - case Text::TYPE_EMAIL_CONFIRMATION: |
|
251 | - return new EE_Email_Confirm_Input($input_args); |
|
250 | + case Text::TYPE_EMAIL_CONFIRMATION: |
|
251 | + return new EE_Email_Confirm_Input($input_args); |
|
252 | 252 | |
253 | - case Text::TYPE_TEXT: |
|
254 | - default: |
|
255 | - return new EE_Text_Input($input_args); |
|
256 | - } |
|
257 | - } |
|
253 | + case Text::TYPE_TEXT: |
|
254 | + default: |
|
255 | + return new EE_Text_Input($input_args); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | 100, |
70 | 70 | $this |
71 | 71 | ); |
72 | - $this->config->year_input->end_range = (int) apply_filters( |
|
72 | + $this->config->year_input->end_range = (int) apply_filters( |
|
73 | 73 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
74 | 74 | 100, |
75 | 75 | $this |
@@ -18,175 +18,175 @@ |
||
18 | 18 | class RegistrantFormSection extends EE_Form_Section_Proper |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var RegistrantFormInput |
|
23 | - */ |
|
24 | - public $reg_form_input; |
|
21 | + /** |
|
22 | + * @var RegistrantFormInput |
|
23 | + */ |
|
24 | + public $reg_form_input; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * RegistrantFormSection constructor. |
|
29 | - * |
|
30 | - * @param EE_Registration $registration |
|
31 | - * @param EE_Form_Section $form_section |
|
32 | - * @param bool $admin_request |
|
33 | - * @param RegistrantFormInput $reg_form_input |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - public function __construct( |
|
38 | - EE_Registration $registration, |
|
39 | - EE_Form_Section $form_section, |
|
40 | - bool $admin_request, |
|
41 | - RegistrantFormInput $reg_form_input |
|
42 | - ) { |
|
43 | - $this->reg_form_input = $reg_form_input; |
|
44 | - parent::__construct($this->generateFormArgs($registration, $form_section, $admin_request)); |
|
45 | - } |
|
27 | + /** |
|
28 | + * RegistrantFormSection constructor. |
|
29 | + * |
|
30 | + * @param EE_Registration $registration |
|
31 | + * @param EE_Form_Section $form_section |
|
32 | + * @param bool $admin_request |
|
33 | + * @param RegistrantFormInput $reg_form_input |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + public function __construct( |
|
38 | + EE_Registration $registration, |
|
39 | + EE_Form_Section $form_section, |
|
40 | + bool $admin_request, |
|
41 | + RegistrantFormInput $reg_form_input |
|
42 | + ) { |
|
43 | + $this->reg_form_input = $reg_form_input; |
|
44 | + parent::__construct($this->generateFormArgs($registration, $form_section, $admin_request)); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param EE_Registration $registration |
|
50 | - * @param EE_Form_Section $form_section |
|
51 | - * @param bool $admin_request |
|
52 | - * @return array |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - private function generateFormArgs( |
|
57 | - EE_Registration $registration, |
|
58 | - EE_Form_Section $form_section, |
|
59 | - bool $admin_request |
|
60 | - ): array { |
|
61 | - $form_args = $this->generateTopLevelFormArgs($registration, $form_section, $admin_request); |
|
62 | - $form_inputs = $form_section->formElements(); |
|
63 | - // loop thru questions |
|
64 | - foreach ($form_inputs as $form_input) { |
|
65 | - if ($form_input instanceof EE_Form_Element) { |
|
66 | - $form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput( |
|
67 | - $registration, |
|
68 | - $form_section, |
|
69 | - $form_input |
|
70 | - ); |
|
71 | - } |
|
72 | - } |
|
73 | - $form_args['subsections'] = $this->filterFormSectionContent( |
|
74 | - $registration, |
|
75 | - $form_section, |
|
76 | - $form_args['subsections'] |
|
77 | - ); |
|
78 | - return $form_args; |
|
79 | - } |
|
48 | + /** |
|
49 | + * @param EE_Registration $registration |
|
50 | + * @param EE_Form_Section $form_section |
|
51 | + * @param bool $admin_request |
|
52 | + * @return array |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + private function generateFormArgs( |
|
57 | + EE_Registration $registration, |
|
58 | + EE_Form_Section $form_section, |
|
59 | + bool $admin_request |
|
60 | + ): array { |
|
61 | + $form_args = $this->generateTopLevelFormArgs($registration, $form_section, $admin_request); |
|
62 | + $form_inputs = $form_section->formElements(); |
|
63 | + // loop thru questions |
|
64 | + foreach ($form_inputs as $form_input) { |
|
65 | + if ($form_input instanceof EE_Form_Element) { |
|
66 | + $form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput( |
|
67 | + $registration, |
|
68 | + $form_section, |
|
69 | + $form_input |
|
70 | + ); |
|
71 | + } |
|
72 | + } |
|
73 | + $form_args['subsections'] = $this->filterFormSectionContent( |
|
74 | + $registration, |
|
75 | + $form_section, |
|
76 | + $form_args['subsections'] |
|
77 | + ); |
|
78 | + return $form_args; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param EE_Registration $registration |
|
84 | - * @param EE_Form_Section $form_section |
|
85 | - * @param bool $admin_request |
|
86 | - * @return array |
|
87 | - * @throws EE_Error |
|
88 | - * @throws ReflectionException |
|
89 | - */ |
|
90 | - protected function generateTopLevelFormArgs( |
|
91 | - EE_Registration $registration, |
|
92 | - EE_Form_Section $form_section, |
|
93 | - bool $admin_request |
|
94 | - ): array { |
|
95 | - return [ |
|
96 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(), |
|
97 | - 'html_class' => $admin_request |
|
98 | - ? 'form-table ee-reg-form-qstn-grp-dv' |
|
99 | - : 'ee-reg-form-qstn-grp-dv', |
|
100 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl', |
|
101 | - 'subsections' => [ |
|
102 | - 'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request), |
|
103 | - ], |
|
104 | - 'layout_strategy' => $admin_request |
|
105 | - ? new EE_Admin_Two_Column_Layout() |
|
106 | - : new EE_Div_Per_Section_Layout(), |
|
107 | - ]; |
|
108 | - } |
|
82 | + /** |
|
83 | + * @param EE_Registration $registration |
|
84 | + * @param EE_Form_Section $form_section |
|
85 | + * @param bool $admin_request |
|
86 | + * @return array |
|
87 | + * @throws EE_Error |
|
88 | + * @throws ReflectionException |
|
89 | + */ |
|
90 | + protected function generateTopLevelFormArgs( |
|
91 | + EE_Registration $registration, |
|
92 | + EE_Form_Section $form_section, |
|
93 | + bool $admin_request |
|
94 | + ): array { |
|
95 | + return [ |
|
96 | + 'html_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(), |
|
97 | + 'html_class' => $admin_request |
|
98 | + ? 'form-table ee-reg-form-qstn-grp-dv' |
|
99 | + : 'ee-reg-form-qstn-grp-dv', |
|
100 | + 'html_label_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl', |
|
101 | + 'subsections' => [ |
|
102 | + 'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request), |
|
103 | + ], |
|
104 | + 'layout_strategy' => $admin_request |
|
105 | + ? new EE_Admin_Two_Column_Layout() |
|
106 | + : new EE_Div_Per_Section_Layout(), |
|
107 | + ]; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * @param EE_Form_Section $form_section |
|
113 | - * @param bool $admin_request |
|
114 | - * @return EE_Form_Section_HTML |
|
115 | - * @throws EE_Error |
|
116 | - * @throws ReflectionException |
|
117 | - */ |
|
118 | - private function formSectionHeader(EE_Form_Section $form_section, bool $admin_request): EE_Form_Section_HTML |
|
119 | - { |
|
120 | - $html = ''; |
|
121 | - $label = $form_section->label(); |
|
122 | - // group_name |
|
123 | - if ($label instanceof FormLabel && $label->showLabel()) { |
|
124 | - if ($admin_request && $label->adminLabel() !== '') { |
|
125 | - $html .= EEH_HTML::br(); |
|
126 | - $html .= EEH_HTML::h3( |
|
127 | - $label->adminLabel(), |
|
128 | - '', |
|
129 | - 'ee-reg-form-qstn-grp-title title', |
|
130 | - 'font-size: 1.3em; padding-left:0;' |
|
131 | - ); |
|
132 | - } elseif (! $admin_request && $label->publicLabel() !== '') { |
|
133 | - $html .= EEH_HTML::h4( |
|
134 | - $label->publicLabel(), |
|
135 | - '', |
|
136 | - 'ee-reg-form-qstn-grp-title section-title' |
|
137 | - ); |
|
138 | - } |
|
139 | - } |
|
140 | - // group_desc |
|
141 | - // if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
142 | - // $html .= EEH_HTML::p( |
|
143 | - // $question_group->desc(), |
|
144 | - // '', |
|
145 | - // $admin_request |
|
146 | - // ? 'ee-reg-form-qstn-grp-desc-pg' |
|
147 | - // : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
148 | - // ); |
|
149 | - // } |
|
150 | - return new EE_Form_Section_HTML($html); |
|
151 | - } |
|
111 | + /** |
|
112 | + * @param EE_Form_Section $form_section |
|
113 | + * @param bool $admin_request |
|
114 | + * @return EE_Form_Section_HTML |
|
115 | + * @throws EE_Error |
|
116 | + * @throws ReflectionException |
|
117 | + */ |
|
118 | + private function formSectionHeader(EE_Form_Section $form_section, bool $admin_request): EE_Form_Section_HTML |
|
119 | + { |
|
120 | + $html = ''; |
|
121 | + $label = $form_section->label(); |
|
122 | + // group_name |
|
123 | + if ($label instanceof FormLabel && $label->showLabel()) { |
|
124 | + if ($admin_request && $label->adminLabel() !== '') { |
|
125 | + $html .= EEH_HTML::br(); |
|
126 | + $html .= EEH_HTML::h3( |
|
127 | + $label->adminLabel(), |
|
128 | + '', |
|
129 | + 'ee-reg-form-qstn-grp-title title', |
|
130 | + 'font-size: 1.3em; padding-left:0;' |
|
131 | + ); |
|
132 | + } elseif (! $admin_request && $label->publicLabel() !== '') { |
|
133 | + $html .= EEH_HTML::h4( |
|
134 | + $label->publicLabel(), |
|
135 | + '', |
|
136 | + 'ee-reg-form-qstn-grp-title section-title' |
|
137 | + ); |
|
138 | + } |
|
139 | + } |
|
140 | + // group_desc |
|
141 | + // if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
142 | + // $html .= EEH_HTML::p( |
|
143 | + // $question_group->desc(), |
|
144 | + // '', |
|
145 | + // $admin_request |
|
146 | + // ? 'ee-reg-form-qstn-grp-desc-pg' |
|
147 | + // : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
148 | + // ); |
|
149 | + // } |
|
150 | + return new EE_Form_Section_HTML($html); |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * @param EE_Registration $registration |
|
156 | - * @param EE_Form_Section $form_section |
|
157 | - * @param array $subsections |
|
158 | - * @return array |
|
159 | - */ |
|
160 | - private function filterFormSectionContent( |
|
161 | - EE_Registration $registration, |
|
162 | - EE_Form_Section $form_section, |
|
163 | - array $subsections |
|
164 | - ): array { |
|
165 | - // filter for additional content before questions |
|
166 | - $filtered = (array) apply_filters( |
|
167 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v2_RegistrantFormSection__filterFormSectionContent', |
|
168 | - [ |
|
169 | - 'before_inputs' => '', |
|
170 | - 'form_section' => $subsections, |
|
171 | - 'after_inputs' => '', |
|
172 | - ], |
|
173 | - $registration, |
|
174 | - $form_section, |
|
175 | - $this |
|
176 | - ); |
|
154 | + /** |
|
155 | + * @param EE_Registration $registration |
|
156 | + * @param EE_Form_Section $form_section |
|
157 | + * @param array $subsections |
|
158 | + * @return array |
|
159 | + */ |
|
160 | + private function filterFormSectionContent( |
|
161 | + EE_Registration $registration, |
|
162 | + EE_Form_Section $form_section, |
|
163 | + array $subsections |
|
164 | + ): array { |
|
165 | + // filter for additional content before questions |
|
166 | + $filtered = (array) apply_filters( |
|
167 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v2_RegistrantFormSection__filterFormSectionContent', |
|
168 | + [ |
|
169 | + 'before_inputs' => '', |
|
170 | + 'form_section' => $subsections, |
|
171 | + 'after_inputs' => '', |
|
172 | + ], |
|
173 | + $registration, |
|
174 | + $form_section, |
|
175 | + $this |
|
176 | + ); |
|
177 | 177 | |
178 | - if (! isset($filtered['form_section'])) { |
|
179 | - throw new RuntimeException( |
|
180 | - esc_html__('Form Section arguments can not be removed.', 'event_espresso') |
|
181 | - ); |
|
182 | - } |
|
183 | - $form_args = $filtered['form_section']; |
|
184 | - if (! empty($filtered['before_inputs'])) { |
|
185 | - $form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']); |
|
186 | - } |
|
187 | - if (! empty($filtered['after_inputs'])) { |
|
188 | - $form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']); |
|
189 | - } |
|
190 | - return $form_args; |
|
191 | - } |
|
178 | + if (! isset($filtered['form_section'])) { |
|
179 | + throw new RuntimeException( |
|
180 | + esc_html__('Form Section arguments can not be removed.', 'event_espresso') |
|
181 | + ); |
|
182 | + } |
|
183 | + $form_args = $filtered['form_section']; |
|
184 | + if (! empty($filtered['before_inputs'])) { |
|
185 | + $form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']); |
|
186 | + } |
|
187 | + if (! empty($filtered['after_inputs'])) { |
|
188 | + $form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']); |
|
189 | + } |
|
190 | + return $form_args; |
|
191 | + } |
|
192 | 192 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // loop thru questions |
64 | 64 | foreach ($form_inputs as $form_input) { |
65 | 65 | if ($form_input instanceof EE_Form_Element) { |
66 | - $form_args['subsections'][ $form_input->slug() ] = $this->reg_form_input->generateFormInput( |
|
66 | + $form_args['subsections'][$form_input->slug()] = $this->reg_form_input->generateFormInput( |
|
67 | 67 | $registration, |
68 | 68 | $form_section, |
69 | 69 | $form_input |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | bool $admin_request |
94 | 94 | ): array { |
95 | 95 | return [ |
96 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID(), |
|
96 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$form_section->slug().'-'.$registration->ID(), |
|
97 | 97 | 'html_class' => $admin_request |
98 | 98 | ? 'form-table ee-reg-form-qstn-grp-dv' |
99 | 99 | : 'ee-reg-form-qstn-grp-dv', |
100 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $form_section->slug() . '-' . $registration->ID() . '-lbl', |
|
100 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$form_section->slug().'-'.$registration->ID().'-lbl', |
|
101 | 101 | 'subsections' => [ |
102 | 102 | 'reg_form_qstn_grp_hdr' => $this->formSectionHeader($form_section, $admin_request), |
103 | 103 | ], |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'ee-reg-form-qstn-grp-title title', |
130 | 130 | 'font-size: 1.3em; padding-left:0;' |
131 | 131 | ); |
132 | - } elseif (! $admin_request && $label->publicLabel() !== '') { |
|
132 | + } elseif ( ! $admin_request && $label->publicLabel() !== '') { |
|
133 | 133 | $html .= EEH_HTML::h4( |
134 | 134 | $label->publicLabel(), |
135 | 135 | '', |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | $this |
176 | 176 | ); |
177 | 177 | |
178 | - if (! isset($filtered['form_section'])) { |
|
178 | + if ( ! isset($filtered['form_section'])) { |
|
179 | 179 | throw new RuntimeException( |
180 | 180 | esc_html__('Form Section arguments can not be removed.', 'event_espresso') |
181 | 181 | ); |
182 | 182 | } |
183 | 183 | $form_args = $filtered['form_section']; |
184 | - if (! empty($filtered['before_inputs'])) { |
|
184 | + if ( ! empty($filtered['before_inputs'])) { |
|
185 | 185 | $form_args['reg_form_questions_before'] = new EE_Form_Section_HTML($filtered['before_inputs']); |
186 | 186 | } |
187 | - if (! empty($filtered['after_inputs'])) { |
|
187 | + if ( ! empty($filtered['after_inputs'])) { |
|
188 | 188 | $form_args['reg_form_questions_after'] = new EE_Form_Section_HTML($filtered['after_inputs']); |
189 | 189 | } |
190 | 190 | return $form_args; |