@@ -2,62 +2,62 @@ |
||
2 | 2 | |
3 | 3 | class EE_Boolean_Field extends EE_Integer_Field |
4 | 4 | { |
5 | - /** |
|
6 | - * @param string $table_column |
|
7 | - * @param string $nicename |
|
8 | - * @param bool $nullable |
|
9 | - * @param null $default_value |
|
10 | - */ |
|
11 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
14 | - $this->setSchemaType('boolean'); |
|
15 | - } |
|
5 | + /** |
|
6 | + * @param string $table_column |
|
7 | + * @param string $nicename |
|
8 | + * @param bool $nullable |
|
9 | + * @param null $default_value |
|
10 | + */ |
|
11 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
14 | + $this->setSchemaType('boolean'); |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * Double-checks the value being returned is an boolean. |
|
19 | - * @since 4.9.74.p |
|
20 | - * @param mixed $value_of_field_on_model_object |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function prepare_for_get($value_of_field_on_model_object) |
|
24 | - { |
|
25 | - return (bool) parent::prepare_for_get($value_of_field_on_model_object); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Double-checks the value being returned is an boolean. |
|
19 | + * @since 4.9.74.p |
|
20 | + * @param mixed $value_of_field_on_model_object |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function prepare_for_get($value_of_field_on_model_object) |
|
24 | + { |
|
25 | + return (bool) parent::prepare_for_get($value_of_field_on_model_object); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @since 4.9.74.p |
|
30 | - * @param $value_inputted_for_field_on_model_object |
|
31 | - * @return boolean |
|
32 | - */ |
|
33 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | - { |
|
35 | - return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN); |
|
36 | - } |
|
28 | + /** |
|
29 | + * @since 4.9.74.p |
|
30 | + * @param $value_inputted_for_field_on_model_object |
|
31 | + * @return boolean |
|
32 | + */ |
|
33 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
34 | + { |
|
35 | + return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Make sure we're returning booleans |
|
40 | - * |
|
41 | - * @param string $value_inputted_for_field_on_model_object |
|
42 | - * @return boolean |
|
43 | - */ |
|
44 | - public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
45 | - { |
|
46 | - return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN); |
|
47 | - } |
|
38 | + /** |
|
39 | + * Make sure we're returning booleans |
|
40 | + * |
|
41 | + * @param string $value_inputted_for_field_on_model_object |
|
42 | + * @return boolean |
|
43 | + */ |
|
44 | + public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
45 | + { |
|
46 | + return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Gets a nice Yes/No value for this field |
|
51 | - * |
|
52 | - * @param boolean $value_on_field_to_be_outputted |
|
53 | - * @return string Yes or No |
|
54 | - */ |
|
55 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
56 | - { |
|
57 | - return apply_filters( |
|
58 | - 'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return', |
|
59 | - $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'), |
|
60 | - $value_on_field_to_be_outputted |
|
61 | - ); |
|
62 | - } |
|
49 | + /** |
|
50 | + * Gets a nice Yes/No value for this field |
|
51 | + * |
|
52 | + * @param boolean $value_on_field_to_be_outputted |
|
53 | + * @return string Yes or No |
|
54 | + */ |
|
55 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
56 | + { |
|
57 | + return apply_filters( |
|
58 | + 'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return', |
|
59 | + $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'), |
|
60 | + $value_on_field_to_be_outputted |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | } |
@@ -35,233 +35,233 @@ |
||
35 | 35 | class EEM_Form_Input extends EEM_Form_Element |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * @var EEM_Form_Input |
|
40 | - */ |
|
41 | - protected static $_instance; |
|
38 | + /** |
|
39 | + * @var EEM_Form_Input |
|
40 | + */ |
|
41 | + protected static $_instance; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var RequestInterface |
|
45 | - */ |
|
46 | - private $request; |
|
43 | + /** |
|
44 | + * @var RequestInterface |
|
45 | + */ |
|
46 | + private $request; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - private $input_types; |
|
48 | + /** |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + private $input_types; |
|
52 | 52 | |
53 | 53 | |
54 | - protected function __construct(Element $element, InputTypes $input_types, $timezone = null) |
|
55 | - { |
|
56 | - $this->input_types = $input_types; |
|
57 | - $this->singular_item = esc_html__('Form Input', 'event_espresso'); |
|
58 | - $this->plural_item = esc_html__('Form Inputs', 'event_espresso'); |
|
54 | + protected function __construct(Element $element, InputTypes $input_types, $timezone = null) |
|
55 | + { |
|
56 | + $this->input_types = $input_types; |
|
57 | + $this->singular_item = esc_html__('Form Input', 'event_espresso'); |
|
58 | + $this->plural_item = esc_html__('Form Inputs', 'event_espresso'); |
|
59 | 59 | |
60 | - $this->_tables = [ |
|
61 | - 'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_ID'), |
|
62 | - ]; |
|
63 | - $this->_fields = [ |
|
64 | - 'Form_Input' => [ |
|
65 | - 'FIN_ID' => new EE_Integer_Field( |
|
66 | - 'FIN_ID', |
|
67 | - esc_html__('Form Input ID (autoincrement db id)', 'event_espresso'), |
|
68 | - false |
|
69 | - ), |
|
70 | - 'FIN_UUID' => new EE_Primary_Key_String_Field( |
|
71 | - 'FIN_UUID', |
|
72 | - esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso') |
|
73 | - ), |
|
74 | - 'FIN_adminLabel' => new EE_Plain_Text_Field( |
|
75 | - 'FIN_adminLabel', |
|
76 | - esc_html__( |
|
77 | - 'Input label displayed in the admin to help differentiate input from others.', |
|
78 | - 'event_espresso' |
|
79 | - ), |
|
80 | - true, |
|
81 | - null |
|
82 | - ), |
|
83 | - 'FIN_adminOnly' => new EE_Boolean_Field( |
|
84 | - 'FIN_adminOnly', |
|
85 | - esc_html__( |
|
86 | - 'Whether or not input is only displayed in the admin. If false, input will appear in public forms', |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - false, |
|
90 | - false |
|
91 | - ), |
|
92 | - 'FIN_belongsTo' => new EE_Foreign_Key_String_Field( |
|
93 | - 'FIN_belongsTo', |
|
94 | - esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'), |
|
95 | - true, |
|
96 | - null, |
|
97 | - ['Form_Section'] |
|
98 | - ), |
|
99 | - 'FIN_helpClass' => new EE_Plain_Text_Field( |
|
100 | - 'FIN_helpClass', |
|
101 | - esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'), |
|
102 | - true, |
|
103 | - null |
|
104 | - ), |
|
105 | - 'FIN_helpText' => new EE_Plain_Text_Field( |
|
106 | - 'FIN_helpText', |
|
107 | - esc_html__( |
|
108 | - 'Additional text displayed alongside a form input to assist users with completing the form.', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - true, |
|
112 | - null |
|
113 | - ), |
|
114 | - 'FIN_htmlClass' => new EE_Plain_Text_Field( |
|
115 | - 'FIN_htmlClass', |
|
116 | - esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'), |
|
117 | - true, |
|
118 | - null |
|
119 | - ), |
|
120 | - 'FIN_max' => new EE_Integer_Field( |
|
121 | - 'FIN_max', |
|
122 | - esc_html__( |
|
123 | - 'Maximum numeric value or maximum characters allowed for form input answer.', |
|
124 | - 'event_espresso' |
|
125 | - ), |
|
126 | - false, |
|
127 | - EE_INF |
|
128 | - ), |
|
129 | - 'FIN_min' => new EE_Integer_Field( |
|
130 | - 'FIN_min', |
|
131 | - esc_html__( |
|
132 | - 'Minimum numeric value or minimum characters allowed for form input answer.', |
|
133 | - 'event_espresso' |
|
134 | - ), |
|
135 | - true, |
|
136 | - null |
|
137 | - ), |
|
138 | - 'FIN_order' => new EE_Integer_Field( |
|
139 | - 'FIN_order', |
|
140 | - esc_html__('Order in which form input appears in a form.', 'event_espresso'), |
|
141 | - false, |
|
142 | - 0 |
|
143 | - ), |
|
144 | - 'FIN_placeholder' => new EE_Plain_Text_Field( |
|
145 | - 'FIN_placeholder', |
|
146 | - esc_html__( |
|
147 | - 'Example text displayed within an input to assist users with completing the form.', |
|
148 | - 'event_espresso' |
|
149 | - ), |
|
150 | - true, |
|
151 | - null |
|
152 | - ), |
|
153 | - 'FIN_publicLabel' => new EE_Plain_Text_Field( |
|
154 | - 'FIN_publicLabel', |
|
155 | - esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'), |
|
156 | - true, |
|
157 | - null |
|
158 | - ), |
|
159 | - 'FIN_required' => new EE_Boolean_Field( |
|
160 | - 'FIN_required', |
|
161 | - esc_html__( |
|
162 | - 'Whether or not the input must be supplied with a value in order to complete the form.', |
|
163 | - 'event_espresso' |
|
164 | - ), |
|
165 | - false, |
|
166 | - false |
|
167 | - ), |
|
168 | - 'FIN_requiredText' => new EE_Plain_Text_Field( |
|
169 | - 'FIN_requiredText', |
|
170 | - esc_html__( |
|
171 | - 'Custom validation text displayed alongside a required form input to assist users with completing the form.', |
|
172 | - 'event_espresso' |
|
173 | - ), |
|
174 | - true, |
|
175 | - null |
|
176 | - ), |
|
177 | - 'FIN_status' => new EE_Enum_Text_Field( |
|
178 | - 'FIN_status', |
|
179 | - esc_html__( |
|
180 | - 'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Input::STATUS_* constants.', |
|
181 | - 'event_espresso' |
|
182 | - ), |
|
183 | - false, |
|
184 | - Element::STATUS_ACTIVE, |
|
185 | - $element->validStatusOptions() |
|
186 | - ), |
|
187 | - 'FIN_type' => new EE_Enum_Text_Field( |
|
188 | - 'FIN_type', |
|
189 | - esc_html__( |
|
190 | - 'Form input type. Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.', |
|
191 | - 'event_espresso' |
|
192 | - ), |
|
193 | - false, |
|
194 | - Text::TYPE_TEXT, |
|
195 | - $this->validTypeOptions() |
|
196 | - ), |
|
197 | - 'FIN_wpUser' => new EE_WP_User_Field( |
|
198 | - 'FIN_wpUser', |
|
199 | - esc_html__('ID of the WP User that created this form input.', 'event_espresso'), |
|
200 | - false |
|
201 | - ), |
|
202 | - ], |
|
203 | - ]; |
|
204 | - $this->_model_relations = []; |
|
205 | - $this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation(); |
|
206 | - // this model is generally available for reading |
|
207 | - $restrictions = []; |
|
208 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
209 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
210 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
211 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
212 | - $this->_cap_restriction_generators = $restrictions; |
|
213 | - parent::__construct($element, $timezone); |
|
214 | - $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
215 | - } |
|
60 | + $this->_tables = [ |
|
61 | + 'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_ID'), |
|
62 | + ]; |
|
63 | + $this->_fields = [ |
|
64 | + 'Form_Input' => [ |
|
65 | + 'FIN_ID' => new EE_Integer_Field( |
|
66 | + 'FIN_ID', |
|
67 | + esc_html__('Form Input ID (autoincrement db id)', 'event_espresso'), |
|
68 | + false |
|
69 | + ), |
|
70 | + 'FIN_UUID' => new EE_Primary_Key_String_Field( |
|
71 | + 'FIN_UUID', |
|
72 | + esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso') |
|
73 | + ), |
|
74 | + 'FIN_adminLabel' => new EE_Plain_Text_Field( |
|
75 | + 'FIN_adminLabel', |
|
76 | + esc_html__( |
|
77 | + 'Input label displayed in the admin to help differentiate input from others.', |
|
78 | + 'event_espresso' |
|
79 | + ), |
|
80 | + true, |
|
81 | + null |
|
82 | + ), |
|
83 | + 'FIN_adminOnly' => new EE_Boolean_Field( |
|
84 | + 'FIN_adminOnly', |
|
85 | + esc_html__( |
|
86 | + 'Whether or not input is only displayed in the admin. If false, input will appear in public forms', |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + false, |
|
90 | + false |
|
91 | + ), |
|
92 | + 'FIN_belongsTo' => new EE_Foreign_Key_String_Field( |
|
93 | + 'FIN_belongsTo', |
|
94 | + esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'), |
|
95 | + true, |
|
96 | + null, |
|
97 | + ['Form_Section'] |
|
98 | + ), |
|
99 | + 'FIN_helpClass' => new EE_Plain_Text_Field( |
|
100 | + 'FIN_helpClass', |
|
101 | + esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'), |
|
102 | + true, |
|
103 | + null |
|
104 | + ), |
|
105 | + 'FIN_helpText' => new EE_Plain_Text_Field( |
|
106 | + 'FIN_helpText', |
|
107 | + esc_html__( |
|
108 | + 'Additional text displayed alongside a form input to assist users with completing the form.', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + true, |
|
112 | + null |
|
113 | + ), |
|
114 | + 'FIN_htmlClass' => new EE_Plain_Text_Field( |
|
115 | + 'FIN_htmlClass', |
|
116 | + esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'), |
|
117 | + true, |
|
118 | + null |
|
119 | + ), |
|
120 | + 'FIN_max' => new EE_Integer_Field( |
|
121 | + 'FIN_max', |
|
122 | + esc_html__( |
|
123 | + 'Maximum numeric value or maximum characters allowed for form input answer.', |
|
124 | + 'event_espresso' |
|
125 | + ), |
|
126 | + false, |
|
127 | + EE_INF |
|
128 | + ), |
|
129 | + 'FIN_min' => new EE_Integer_Field( |
|
130 | + 'FIN_min', |
|
131 | + esc_html__( |
|
132 | + 'Minimum numeric value or minimum characters allowed for form input answer.', |
|
133 | + 'event_espresso' |
|
134 | + ), |
|
135 | + true, |
|
136 | + null |
|
137 | + ), |
|
138 | + 'FIN_order' => new EE_Integer_Field( |
|
139 | + 'FIN_order', |
|
140 | + esc_html__('Order in which form input appears in a form.', 'event_espresso'), |
|
141 | + false, |
|
142 | + 0 |
|
143 | + ), |
|
144 | + 'FIN_placeholder' => new EE_Plain_Text_Field( |
|
145 | + 'FIN_placeholder', |
|
146 | + esc_html__( |
|
147 | + 'Example text displayed within an input to assist users with completing the form.', |
|
148 | + 'event_espresso' |
|
149 | + ), |
|
150 | + true, |
|
151 | + null |
|
152 | + ), |
|
153 | + 'FIN_publicLabel' => new EE_Plain_Text_Field( |
|
154 | + 'FIN_publicLabel', |
|
155 | + esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'), |
|
156 | + true, |
|
157 | + null |
|
158 | + ), |
|
159 | + 'FIN_required' => new EE_Boolean_Field( |
|
160 | + 'FIN_required', |
|
161 | + esc_html__( |
|
162 | + 'Whether or not the input must be supplied with a value in order to complete the form.', |
|
163 | + 'event_espresso' |
|
164 | + ), |
|
165 | + false, |
|
166 | + false |
|
167 | + ), |
|
168 | + 'FIN_requiredText' => new EE_Plain_Text_Field( |
|
169 | + 'FIN_requiredText', |
|
170 | + esc_html__( |
|
171 | + 'Custom validation text displayed alongside a required form input to assist users with completing the form.', |
|
172 | + 'event_espresso' |
|
173 | + ), |
|
174 | + true, |
|
175 | + null |
|
176 | + ), |
|
177 | + 'FIN_status' => new EE_Enum_Text_Field( |
|
178 | + 'FIN_status', |
|
179 | + esc_html__( |
|
180 | + 'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Input::STATUS_* constants.', |
|
181 | + 'event_espresso' |
|
182 | + ), |
|
183 | + false, |
|
184 | + Element::STATUS_ACTIVE, |
|
185 | + $element->validStatusOptions() |
|
186 | + ), |
|
187 | + 'FIN_type' => new EE_Enum_Text_Field( |
|
188 | + 'FIN_type', |
|
189 | + esc_html__( |
|
190 | + 'Form input type. Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.', |
|
191 | + 'event_espresso' |
|
192 | + ), |
|
193 | + false, |
|
194 | + Text::TYPE_TEXT, |
|
195 | + $this->validTypeOptions() |
|
196 | + ), |
|
197 | + 'FIN_wpUser' => new EE_WP_User_Field( |
|
198 | + 'FIN_wpUser', |
|
199 | + esc_html__('ID of the WP User that created this form input.', 'event_espresso'), |
|
200 | + false |
|
201 | + ), |
|
202 | + ], |
|
203 | + ]; |
|
204 | + $this->_model_relations = []; |
|
205 | + $this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation(); |
|
206 | + // this model is generally available for reading |
|
207 | + $restrictions = []; |
|
208 | + $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
209 | + $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
210 | + $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
211 | + $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
212 | + $this->_cap_restriction_generators = $restrictions; |
|
213 | + parent::__construct($element, $timezone); |
|
214 | + $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * @param bool $constants_only |
|
220 | - * @return array |
|
221 | - */ |
|
222 | - public function validTypeOptions(bool $constants_only = false): array |
|
223 | - { |
|
224 | - return $this->input_types->validTypeOptions($constants_only); |
|
225 | - } |
|
218 | + /** |
|
219 | + * @param bool $constants_only |
|
220 | + * @return array |
|
221 | + */ |
|
222 | + public function validTypeOptions(bool $constants_only = false): array |
|
223 | + { |
|
224 | + return $this->input_types->validTypeOptions($constants_only); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * @return EE_Form_Input[] |
|
230 | - * @throws EE_Error |
|
231 | - */ |
|
232 | - public function getFormInputsForSection(string $relation, string $related_UUID): array |
|
233 | - { |
|
234 | - $where_params = [$relation => $related_UUID]; |
|
235 | - $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
236 | - $query_params = $this->addOrderByQueryParams($query_params); |
|
237 | - return $this->get_all($query_params); |
|
238 | - } |
|
228 | + /** |
|
229 | + * @return EE_Form_Input[] |
|
230 | + * @throws EE_Error |
|
231 | + */ |
|
232 | + public function getFormInputsForSection(string $relation, string $related_UUID): array |
|
233 | + { |
|
234 | + $where_params = [$relation => $related_UUID]; |
|
235 | + $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
236 | + $query_params = $this->addOrderByQueryParams($query_params); |
|
237 | + return $this->get_all($query_params); |
|
238 | + } |
|
239 | 239 | |
240 | 240 | |
241 | - /** |
|
242 | - * @param array $query_params |
|
243 | - * @return array |
|
244 | - */ |
|
245 | - private function addDefaultWhereConditions(array $query_params): array |
|
246 | - { |
|
247 | - // might need to add a way to identify GQL requests for admin domains |
|
248 | - $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
249 | - $query_params['default_where_conditions'] = $admin_request |
|
250 | - ? EEM_Base::default_where_conditions_none |
|
251 | - : EEM_Base::default_where_conditions_all; |
|
252 | - return $query_params; |
|
253 | - } |
|
241 | + /** |
|
242 | + * @param array $query_params |
|
243 | + * @return array |
|
244 | + */ |
|
245 | + private function addDefaultWhereConditions(array $query_params): array |
|
246 | + { |
|
247 | + // might need to add a way to identify GQL requests for admin domains |
|
248 | + $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
249 | + $query_params['default_where_conditions'] = $admin_request |
|
250 | + ? EEM_Base::default_where_conditions_none |
|
251 | + : EEM_Base::default_where_conditions_all; |
|
252 | + return $query_params; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | - /** |
|
257 | - * form inputs should always be sorted in ascending order via the FIN_order field |
|
258 | - * |
|
259 | - * @param array $query_params |
|
260 | - * @return array |
|
261 | - */ |
|
262 | - private function addOrderByQueryParams(array $query_params): array |
|
263 | - { |
|
264 | - $query_params['order_by'] = ['FIN_order' => 'ASC']; |
|
265 | - return $query_params; |
|
266 | - } |
|
256 | + /** |
|
257 | + * form inputs should always be sorted in ascending order via the FIN_order field |
|
258 | + * |
|
259 | + * @param array $query_params |
|
260 | + * @return array |
|
261 | + */ |
|
262 | + private function addOrderByQueryParams(array $query_params): array |
|
263 | + { |
|
264 | + $query_params['order_by'] = ['FIN_order' => 'ASC']; |
|
265 | + return $query_params; |
|
266 | + } |
|
267 | 267 | } |
@@ -205,10 +205,10 @@ |
||
205 | 205 | $this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation(); |
206 | 206 | // this model is generally available for reading |
207 | 207 | $restrictions = []; |
208 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
209 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
210 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
211 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
208 | + $restrictions[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
209 | + $restrictions[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
210 | + $restrictions[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
211 | + $restrictions[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to'); |
|
212 | 212 | $this->_cap_restriction_generators = $restrictions; |
213 | 213 | parent::__construct($element, $timezone); |
214 | 214 | $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
@@ -13,132 +13,132 @@ |
||
13 | 13 | class EEM_WP_User extends EEM_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * private instance of the EEM_WP_User object |
|
18 | - * |
|
19 | - * @type EEM_WP_User |
|
20 | - */ |
|
21 | - protected static $_instance; |
|
16 | + /** |
|
17 | + * private instance of the EEM_WP_User object |
|
18 | + * |
|
19 | + * @type EEM_WP_User |
|
20 | + */ |
|
21 | + protected static $_instance; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * constructor |
|
26 | - * |
|
27 | - * @param null $timezone |
|
28 | - * @param ModelFieldFactory $model_field_factory |
|
29 | - * @throws EE_Error |
|
30 | - * @throws InvalidArgumentException |
|
31 | - */ |
|
32 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
33 | - { |
|
34 | - $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
35 | - $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
36 | - global $wpdb; |
|
37 | - $this->_tables = array( |
|
38 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
39 | - ); |
|
40 | - $this->_fields = array( |
|
41 | - 'WP_User' => array( |
|
42 | - 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
43 | - 'ID', |
|
44 | - esc_html__('WP_User ID', 'event_espresso') |
|
45 | - ), |
|
46 | - 'user_login' => $model_field_factory->createPlainTextField( |
|
47 | - 'user_login', |
|
48 | - esc_html__('User Login', 'event_espresso'), |
|
49 | - false |
|
50 | - ), |
|
51 | - 'user_pass' => $model_field_factory->createPlainTextField( |
|
52 | - 'user_pass', |
|
53 | - esc_html__('User Password', 'event_espresso'), |
|
54 | - false |
|
55 | - ), |
|
56 | - 'user_nicename' => $model_field_factory->createPlainTextField( |
|
57 | - 'user_nicename', |
|
58 | - esc_html__(' User Nice Name', 'event_espresso'), |
|
59 | - false |
|
60 | - ), |
|
61 | - 'user_email' => $model_field_factory->createEmailField( |
|
62 | - 'user_email', |
|
63 | - esc_html__('User Email', 'event_espresso'), |
|
64 | - false |
|
65 | - ), |
|
66 | - 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | - 'user_registered', |
|
68 | - esc_html__('Date User Registered', 'event_espresso'), |
|
69 | - $timezone |
|
70 | - ), |
|
71 | - 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | - 'user_activation_key', |
|
73 | - esc_html__('User Activation Key', 'event_espresso'), |
|
74 | - false |
|
75 | - ), |
|
76 | - 'user_status' => $model_field_factory->createIntegerField( |
|
77 | - 'user_status', |
|
78 | - esc_html__('User Status', 'event_espresso') |
|
79 | - ), |
|
80 | - 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | - 'display_name', |
|
82 | - esc_html__('Display Name', 'event_espresso'), |
|
83 | - false |
|
84 | - ), |
|
85 | - ), |
|
86 | - ); |
|
87 | - $this->_model_relations = array( |
|
88 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | - // all models are related to the change log |
|
90 | - // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | - 'Event' => new EE_Has_Many_Relation(), |
|
92 | - 'Message' => new EE_Has_Many_Relation(), |
|
93 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | - 'Price' => new EE_Has_Many_Relation(), |
|
95 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | - 'Question' => new EE_Has_Many_Relation(), |
|
97 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | - 'Venue' => new EE_Has_Many_Relation(), |
|
100 | - ); |
|
101 | - $this->foreign_key_aliases = [ |
|
102 | - 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | - 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | - 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | - 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | - 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | - 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | - 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | - 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | - ]; |
|
111 | - $this->_wp_core_model = true; |
|
112 | - $this->_caps_slug = 'users'; |
|
113 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | - $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | - $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | - } |
|
118 | - // @todo: account for create_users controls whether they can create users at all |
|
119 | - parent::__construct($timezone); |
|
120 | - } |
|
24 | + /** |
|
25 | + * constructor |
|
26 | + * |
|
27 | + * @param null $timezone |
|
28 | + * @param ModelFieldFactory $model_field_factory |
|
29 | + * @throws EE_Error |
|
30 | + * @throws InvalidArgumentException |
|
31 | + */ |
|
32 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
33 | + { |
|
34 | + $this->singular_item = esc_html__('WP_User', 'event_espresso'); |
|
35 | + $this->plural_item = esc_html__('WP_Users', 'event_espresso'); |
|
36 | + global $wpdb; |
|
37 | + $this->_tables = array( |
|
38 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
39 | + ); |
|
40 | + $this->_fields = array( |
|
41 | + 'WP_User' => array( |
|
42 | + 'ID' => $model_field_factory->createPrimaryKeyIntField( |
|
43 | + 'ID', |
|
44 | + esc_html__('WP_User ID', 'event_espresso') |
|
45 | + ), |
|
46 | + 'user_login' => $model_field_factory->createPlainTextField( |
|
47 | + 'user_login', |
|
48 | + esc_html__('User Login', 'event_espresso'), |
|
49 | + false |
|
50 | + ), |
|
51 | + 'user_pass' => $model_field_factory->createPlainTextField( |
|
52 | + 'user_pass', |
|
53 | + esc_html__('User Password', 'event_espresso'), |
|
54 | + false |
|
55 | + ), |
|
56 | + 'user_nicename' => $model_field_factory->createPlainTextField( |
|
57 | + 'user_nicename', |
|
58 | + esc_html__(' User Nice Name', 'event_espresso'), |
|
59 | + false |
|
60 | + ), |
|
61 | + 'user_email' => $model_field_factory->createEmailField( |
|
62 | + 'user_email', |
|
63 | + esc_html__('User Email', 'event_espresso'), |
|
64 | + false |
|
65 | + ), |
|
66 | + 'user_registered' => $model_field_factory->createDatetimeField( |
|
67 | + 'user_registered', |
|
68 | + esc_html__('Date User Registered', 'event_espresso'), |
|
69 | + $timezone |
|
70 | + ), |
|
71 | + 'user_activation_key' => $model_field_factory->createPlainTextField( |
|
72 | + 'user_activation_key', |
|
73 | + esc_html__('User Activation Key', 'event_espresso'), |
|
74 | + false |
|
75 | + ), |
|
76 | + 'user_status' => $model_field_factory->createIntegerField( |
|
77 | + 'user_status', |
|
78 | + esc_html__('User Status', 'event_espresso') |
|
79 | + ), |
|
80 | + 'display_name' => $model_field_factory->createPlainTextField( |
|
81 | + 'display_name', |
|
82 | + esc_html__('Display Name', 'event_espresso'), |
|
83 | + false |
|
84 | + ), |
|
85 | + ), |
|
86 | + ); |
|
87 | + $this->_model_relations = array( |
|
88 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
89 | + // all models are related to the change log |
|
90 | + // 'Change_Log' => new EE_Has_Many_Relation(), |
|
91 | + 'Event' => new EE_Has_Many_Relation(), |
|
92 | + 'Message' => new EE_Has_Many_Relation(), |
|
93 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
94 | + 'Price' => new EE_Has_Many_Relation(), |
|
95 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
96 | + 'Question' => new EE_Has_Many_Relation(), |
|
97 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
98 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
99 | + 'Venue' => new EE_Has_Many_Relation(), |
|
100 | + ); |
|
101 | + $this->foreign_key_aliases = [ |
|
102 | + 'Event.EVT_wp_user' => 'WP_User.ID', |
|
103 | + 'Payment_Method.PMD_wp_user' => 'WP_User.ID', |
|
104 | + 'Price.PRC_wp_user' => 'WP_User.ID', |
|
105 | + 'Price_Type.PRT_wp_user' => 'WP_User.ID', |
|
106 | + 'Question.QST_wp_user' => 'WP_User.ID', |
|
107 | + 'Question_Group.QSG_wp_user' => 'WP_User.ID', |
|
108 | + 'Ticket.VNU_wp_user' => 'WP_User.ID', |
|
109 | + 'Venue.TKT_wp_user' => 'WP_User.ID', |
|
110 | + ]; |
|
111 | + $this->_wp_core_model = true; |
|
112 | + $this->_caps_slug = 'users'; |
|
113 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list'; |
|
114 | + $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list'; |
|
115 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
116 | + $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User(); |
|
117 | + } |
|
118 | + // @todo: account for create_users controls whether they can create users at all |
|
119 | + parent::__construct($timezone); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | - * |
|
126 | - * @return string |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function wp_user_field_name() |
|
130 | - { |
|
131 | - return $this->primary_key_name(); |
|
132 | - } |
|
123 | + /** |
|
124 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
125 | + * |
|
126 | + * @return string |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function wp_user_field_name() |
|
130 | + { |
|
131 | + return $this->primary_key_name(); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | - * |
|
138 | - * @return boolean |
|
139 | - */ |
|
140 | - public function is_owned() |
|
141 | - { |
|
142 | - return true; |
|
143 | - } |
|
135 | + /** |
|
136 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
137 | + * |
|
138 | + * @return boolean |
|
139 | + */ |
|
140 | + public function is_owned() |
|
141 | + { |
|
142 | + return true; |
|
143 | + } |
|
144 | 144 | } |
@@ -28,449 +28,449 @@ |
||
28 | 28 | class EE_Form_Input extends EE_Base_Class |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @param array $props_n_values |
|
33 | - * @return EE_Form_Input |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - public static function new_instance(array $props_n_values = []): EE_Form_Input |
|
38 | - { |
|
39 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | - return $has_object |
|
41 | - ?: new self($props_n_values); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @param array $props_n_values |
|
47 | - * @return EE_Form_Input |
|
48 | - * @throws EE_Error |
|
49 | - * @throws ReflectionException |
|
50 | - */ |
|
51 | - public static function new_instance_from_db(array $props_n_values = []): EE_Form_Input |
|
52 | - { |
|
53 | - return new self($props_n_values); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Form Input UUID (universally unique identifier) |
|
59 | - * |
|
60 | - * @return string |
|
61 | - * @throws EE_Error |
|
62 | - * @throws ReflectionException |
|
63 | - */ |
|
64 | - public function UUID(): string |
|
65 | - { |
|
66 | - return $this->get('FIN_UUID'); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @param string $UUID |
|
72 | - * @throws EE_Error |
|
73 | - * @throws ReflectionException |
|
74 | - */ |
|
75 | - public function setUUID(string $UUID) |
|
76 | - { |
|
77 | - $this->set('FIN_UUID', $UUID); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Input label displayed in the admin to help differentiate input from others |
|
83 | - * |
|
84 | - * @return string |
|
85 | - * @throws EE_Error |
|
86 | - * @throws ReflectionException |
|
87 | - */ |
|
88 | - public function adminLabel(): string |
|
89 | - { |
|
90 | - return $this->get('FIN_adminLabel'); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $admin_label |
|
96 | - * @throws EE_Error |
|
97 | - * @throws ReflectionException |
|
98 | - */ |
|
99 | - public function setAdminLabel(string $admin_label) |
|
100 | - { |
|
101 | - $this->set('FIN_adminLabel', $admin_label); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Whether or not input is only displayed in the admin. If false, input will appear in public forms |
|
107 | - * |
|
108 | - * @return bool |
|
109 | - * @throws EE_Error |
|
110 | - * @throws ReflectionException |
|
111 | - */ |
|
112 | - public function adminOnly(): bool |
|
113 | - { |
|
114 | - return $this->get('FIN_adminOnly'); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @param bool $admin_only |
|
120 | - * @throws EE_Error |
|
121 | - * @throws ReflectionException |
|
122 | - */ |
|
123 | - public function setAdminOnly(bool $admin_only) |
|
124 | - { |
|
125 | - $this->set('FIN_adminOnly', $admin_only); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * UUID of parent form section this form input belongs to. |
|
131 | - * |
|
132 | - * @return string |
|
133 | - * @throws EE_Error |
|
134 | - * @throws ReflectionException |
|
135 | - */ |
|
136 | - public function belongsTo(): string |
|
137 | - { |
|
138 | - return $this->get('FIN_belongsTo'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param string $relation_UUID |
|
144 | - * @throws EE_Error |
|
145 | - * @throws ReflectionException |
|
146 | - */ |
|
147 | - public function setBelongsTo(string $relation_UUID) |
|
148 | - { |
|
149 | - $this->set('FIN_belongsTo', $relation_UUID); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * Custom HTML classes to be applied to this form input's help text. |
|
155 | - * |
|
156 | - * @return string |
|
157 | - * @throws EE_Error |
|
158 | - * @throws ReflectionException |
|
159 | - */ |
|
160 | - public function helpClass(): string |
|
161 | - { |
|
162 | - return $this->get('FIN_helpClass'); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * @param string $help_class |
|
168 | - * @throws EE_Error |
|
169 | - * @throws ReflectionException |
|
170 | - */ |
|
171 | - public function setHelpClass(string $help_class) |
|
172 | - { |
|
173 | - $this->set('FIN_helpClass', $help_class); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * Additional text displayed alongside a form input to assist users with completing the form. |
|
179 | - * |
|
180 | - * @return string |
|
181 | - * @throws EE_Error |
|
182 | - * @throws ReflectionException |
|
183 | - */ |
|
184 | - public function helpText(): string |
|
185 | - { |
|
186 | - return $this->get('FIN_helpText'); |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * @param string $help_text |
|
192 | - * @throws EE_Error |
|
193 | - * @throws ReflectionException |
|
194 | - */ |
|
195 | - public function setHelpText(string $help_text) |
|
196 | - { |
|
197 | - $this->set('FIN_helpText', $help_text); |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * HTML classes to be applied to this form input's container. |
|
203 | - * |
|
204 | - * @return string |
|
205 | - * @throws EE_Error |
|
206 | - * @throws ReflectionException |
|
207 | - */ |
|
208 | - public function htmlClass(): string |
|
209 | - { |
|
210 | - return $this->get('FIN_htmlClass'); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * HTML classes to be applied to this form input's container. |
|
216 | - * |
|
217 | - * @param string $html_class |
|
218 | - * @throws EE_Error |
|
219 | - * @throws ReflectionException |
|
220 | - */ |
|
221 | - public function setHtmlClass(string $html_class) |
|
222 | - { |
|
223 | - $this->set('FIN_htmlClass', $html_class); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * Maximum numeric value or maximum characters allowed for form input answer. |
|
229 | - * |
|
230 | - * @return int |
|
231 | - * @throws EE_Error |
|
232 | - * @throws ReflectionException |
|
233 | - */ |
|
234 | - public function max(): int |
|
235 | - { |
|
236 | - return $this->get('FIN_max'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param int $max |
|
242 | - * @throws EE_Error |
|
243 | - * @throws ReflectionException |
|
244 | - */ |
|
245 | - public function setMax(int $max) |
|
246 | - { |
|
247 | - $this->set('FIN_max', $max); |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * Minimum numeric value or minimum characters allowed for form input answer. |
|
254 | - * |
|
255 | - * @return int |
|
256 | - * @throws EE_Error |
|
257 | - * @throws ReflectionException |
|
258 | - */ |
|
259 | - public function min(): int |
|
260 | - { |
|
261 | - return $this->get('FIN_min'); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * @param int $min |
|
267 | - * @throws EE_Error |
|
268 | - * @throws ReflectionException |
|
269 | - */ |
|
270 | - public function setMin(int $min) |
|
271 | - { |
|
272 | - $this->set('FIN_min', $min); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * Order in which form input appears in a form. |
|
279 | - * |
|
280 | - * @return int |
|
281 | - * @throws EE_Error |
|
282 | - * @throws ReflectionException |
|
283 | - */ |
|
284 | - public function order(): int |
|
285 | - { |
|
286 | - return $this->get('FIN_order'); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Order in which form input appears in a form. |
|
292 | - * |
|
293 | - * @param int $order |
|
294 | - * @throws EE_Error |
|
295 | - * @throws ReflectionException |
|
296 | - */ |
|
297 | - public function setOrder(int $order) |
|
298 | - { |
|
299 | - $this->set('FIN_order', $order); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * Example text displayed within an input to assist users with completing the form. |
|
305 | - * |
|
306 | - * @return string |
|
307 | - * @throws EE_Error |
|
308 | - * @throws ReflectionException |
|
309 | - */ |
|
310 | - public function placeholder(): string |
|
311 | - { |
|
312 | - return $this->get('FIN_placeholder'); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param string $placeholder |
|
318 | - * @throws EE_Error |
|
319 | - * @throws ReflectionException |
|
320 | - */ |
|
321 | - public function setPlaceholder(string $placeholder) |
|
322 | - { |
|
323 | - $this->set('FIN_placeholder', $placeholder); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * Input label displayed on public forms, ie: the actual question text. |
|
329 | - * |
|
330 | - * @return string |
|
331 | - * @throws EE_Error |
|
332 | - * @throws ReflectionException |
|
333 | - */ |
|
334 | - public function publicLabel(): string |
|
335 | - { |
|
336 | - return $this->get('FIN_publicLabel'); |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * @param string $publicLabel |
|
342 | - * @throws EE_Error |
|
343 | - * @throws ReflectionException |
|
344 | - */ |
|
345 | - public function setPublicLabel(string $publicLabel) |
|
346 | - { |
|
347 | - $this->set('FIN_publicLabel', $publicLabel); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * Whether or not the input must be supplied with a value in order to complete the form. |
|
353 | - * |
|
354 | - * @return bool |
|
355 | - * @throws EE_Error |
|
356 | - * @throws ReflectionException |
|
357 | - */ |
|
358 | - public function required(): bool |
|
359 | - { |
|
360 | - return $this->get('FIN_required'); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * @param bool $required |
|
366 | - * @throws EE_Error |
|
367 | - * @throws ReflectionException |
|
368 | - */ |
|
369 | - public function setRequired(bool $required) |
|
370 | - { |
|
371 | - $this->set('FIN_required', $required); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Custom validation text displayed alongside a required form input to assist users with completing the form. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - * @throws EE_Error |
|
380 | - * @throws ReflectionException |
|
381 | - */ |
|
382 | - public function requiredText(): string |
|
383 | - { |
|
384 | - return $this->get('FIN_requiredText'); |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * @param string $requiredText |
|
390 | - * @throws EE_Error |
|
391 | - * @throws ReflectionException |
|
392 | - */ |
|
393 | - public function setRequiredText(string $requiredText) |
|
394 | - { |
|
395 | - $this->set('FIN_requiredText', $requiredText); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - /** |
|
400 | - * Whether form input is active, archived, trashed, or used as a default on new forms. |
|
401 | - * Values correspond to the EEM_Form_Input::STATUS_* constants. |
|
402 | - * |
|
403 | - * @return string |
|
404 | - * @throws EE_Error |
|
405 | - * @throws ReflectionException |
|
406 | - */ |
|
407 | - public function status(): string |
|
408 | - { |
|
409 | - return $this->get('FIN_status'); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * Whether form input is active, archived, trashed, or used as a default on new forms. |
|
415 | - * Values correspond to the EEM_Form_Input::STATUS_* constants. |
|
416 | - * |
|
417 | - * @param string $status |
|
418 | - * @throws EE_Error |
|
419 | - * @throws ReflectionException |
|
420 | - */ |
|
421 | - public function setStatus(string $status) |
|
422 | - { |
|
423 | - $this->set('FIN_status', $status); |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * Form input type. |
|
429 | - * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants. |
|
430 | - * |
|
431 | - * @return string |
|
432 | - * @throws EE_Error |
|
433 | - * @throws ReflectionException |
|
434 | - */ |
|
435 | - public function type(): string |
|
436 | - { |
|
437 | - return $this->get('FIN_type'); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @param string $type |
|
443 | - * @throws EE_Error |
|
444 | - * @throws ReflectionException |
|
445 | - */ |
|
446 | - public function setType(string $type) |
|
447 | - { |
|
448 | - $this->set('FIN_type', $type); |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * ID of the WP User that created this form input. |
|
454 | - * |
|
455 | - * @return int |
|
456 | - * @throws EE_Error |
|
457 | - * @throws ReflectionException |
|
458 | - */ |
|
459 | - public function wpUser(): int |
|
460 | - { |
|
461 | - return $this->get('FIN_wpUser'); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * returns the id the wordpress user who created this question |
|
467 | - * |
|
468 | - * @param int $wp_user |
|
469 | - * @throws EE_Error |
|
470 | - * @throws ReflectionException |
|
471 | - */ |
|
472 | - public function setWpUser(int $wp_user) |
|
473 | - { |
|
474 | - $this->set('FIN_wpUser', $wp_user); |
|
475 | - } |
|
31 | + /** |
|
32 | + * @param array $props_n_values |
|
33 | + * @return EE_Form_Input |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + public static function new_instance(array $props_n_values = []): EE_Form_Input |
|
38 | + { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | + return $has_object |
|
41 | + ?: new self($props_n_values); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @param array $props_n_values |
|
47 | + * @return EE_Form_Input |
|
48 | + * @throws EE_Error |
|
49 | + * @throws ReflectionException |
|
50 | + */ |
|
51 | + public static function new_instance_from_db(array $props_n_values = []): EE_Form_Input |
|
52 | + { |
|
53 | + return new self($props_n_values); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Form Input UUID (universally unique identifier) |
|
59 | + * |
|
60 | + * @return string |
|
61 | + * @throws EE_Error |
|
62 | + * @throws ReflectionException |
|
63 | + */ |
|
64 | + public function UUID(): string |
|
65 | + { |
|
66 | + return $this->get('FIN_UUID'); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @param string $UUID |
|
72 | + * @throws EE_Error |
|
73 | + * @throws ReflectionException |
|
74 | + */ |
|
75 | + public function setUUID(string $UUID) |
|
76 | + { |
|
77 | + $this->set('FIN_UUID', $UUID); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Input label displayed in the admin to help differentiate input from others |
|
83 | + * |
|
84 | + * @return string |
|
85 | + * @throws EE_Error |
|
86 | + * @throws ReflectionException |
|
87 | + */ |
|
88 | + public function adminLabel(): string |
|
89 | + { |
|
90 | + return $this->get('FIN_adminLabel'); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $admin_label |
|
96 | + * @throws EE_Error |
|
97 | + * @throws ReflectionException |
|
98 | + */ |
|
99 | + public function setAdminLabel(string $admin_label) |
|
100 | + { |
|
101 | + $this->set('FIN_adminLabel', $admin_label); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Whether or not input is only displayed in the admin. If false, input will appear in public forms |
|
107 | + * |
|
108 | + * @return bool |
|
109 | + * @throws EE_Error |
|
110 | + * @throws ReflectionException |
|
111 | + */ |
|
112 | + public function adminOnly(): bool |
|
113 | + { |
|
114 | + return $this->get('FIN_adminOnly'); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @param bool $admin_only |
|
120 | + * @throws EE_Error |
|
121 | + * @throws ReflectionException |
|
122 | + */ |
|
123 | + public function setAdminOnly(bool $admin_only) |
|
124 | + { |
|
125 | + $this->set('FIN_adminOnly', $admin_only); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * UUID of parent form section this form input belongs to. |
|
131 | + * |
|
132 | + * @return string |
|
133 | + * @throws EE_Error |
|
134 | + * @throws ReflectionException |
|
135 | + */ |
|
136 | + public function belongsTo(): string |
|
137 | + { |
|
138 | + return $this->get('FIN_belongsTo'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param string $relation_UUID |
|
144 | + * @throws EE_Error |
|
145 | + * @throws ReflectionException |
|
146 | + */ |
|
147 | + public function setBelongsTo(string $relation_UUID) |
|
148 | + { |
|
149 | + $this->set('FIN_belongsTo', $relation_UUID); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * Custom HTML classes to be applied to this form input's help text. |
|
155 | + * |
|
156 | + * @return string |
|
157 | + * @throws EE_Error |
|
158 | + * @throws ReflectionException |
|
159 | + */ |
|
160 | + public function helpClass(): string |
|
161 | + { |
|
162 | + return $this->get('FIN_helpClass'); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * @param string $help_class |
|
168 | + * @throws EE_Error |
|
169 | + * @throws ReflectionException |
|
170 | + */ |
|
171 | + public function setHelpClass(string $help_class) |
|
172 | + { |
|
173 | + $this->set('FIN_helpClass', $help_class); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * Additional text displayed alongside a form input to assist users with completing the form. |
|
179 | + * |
|
180 | + * @return string |
|
181 | + * @throws EE_Error |
|
182 | + * @throws ReflectionException |
|
183 | + */ |
|
184 | + public function helpText(): string |
|
185 | + { |
|
186 | + return $this->get('FIN_helpText'); |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * @param string $help_text |
|
192 | + * @throws EE_Error |
|
193 | + * @throws ReflectionException |
|
194 | + */ |
|
195 | + public function setHelpText(string $help_text) |
|
196 | + { |
|
197 | + $this->set('FIN_helpText', $help_text); |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * HTML classes to be applied to this form input's container. |
|
203 | + * |
|
204 | + * @return string |
|
205 | + * @throws EE_Error |
|
206 | + * @throws ReflectionException |
|
207 | + */ |
|
208 | + public function htmlClass(): string |
|
209 | + { |
|
210 | + return $this->get('FIN_htmlClass'); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * HTML classes to be applied to this form input's container. |
|
216 | + * |
|
217 | + * @param string $html_class |
|
218 | + * @throws EE_Error |
|
219 | + * @throws ReflectionException |
|
220 | + */ |
|
221 | + public function setHtmlClass(string $html_class) |
|
222 | + { |
|
223 | + $this->set('FIN_htmlClass', $html_class); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * Maximum numeric value or maximum characters allowed for form input answer. |
|
229 | + * |
|
230 | + * @return int |
|
231 | + * @throws EE_Error |
|
232 | + * @throws ReflectionException |
|
233 | + */ |
|
234 | + public function max(): int |
|
235 | + { |
|
236 | + return $this->get('FIN_max'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param int $max |
|
242 | + * @throws EE_Error |
|
243 | + * @throws ReflectionException |
|
244 | + */ |
|
245 | + public function setMax(int $max) |
|
246 | + { |
|
247 | + $this->set('FIN_max', $max); |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * Minimum numeric value or minimum characters allowed for form input answer. |
|
254 | + * |
|
255 | + * @return int |
|
256 | + * @throws EE_Error |
|
257 | + * @throws ReflectionException |
|
258 | + */ |
|
259 | + public function min(): int |
|
260 | + { |
|
261 | + return $this->get('FIN_min'); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * @param int $min |
|
267 | + * @throws EE_Error |
|
268 | + * @throws ReflectionException |
|
269 | + */ |
|
270 | + public function setMin(int $min) |
|
271 | + { |
|
272 | + $this->set('FIN_min', $min); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * Order in which form input appears in a form. |
|
279 | + * |
|
280 | + * @return int |
|
281 | + * @throws EE_Error |
|
282 | + * @throws ReflectionException |
|
283 | + */ |
|
284 | + public function order(): int |
|
285 | + { |
|
286 | + return $this->get('FIN_order'); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Order in which form input appears in a form. |
|
292 | + * |
|
293 | + * @param int $order |
|
294 | + * @throws EE_Error |
|
295 | + * @throws ReflectionException |
|
296 | + */ |
|
297 | + public function setOrder(int $order) |
|
298 | + { |
|
299 | + $this->set('FIN_order', $order); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * Example text displayed within an input to assist users with completing the form. |
|
305 | + * |
|
306 | + * @return string |
|
307 | + * @throws EE_Error |
|
308 | + * @throws ReflectionException |
|
309 | + */ |
|
310 | + public function placeholder(): string |
|
311 | + { |
|
312 | + return $this->get('FIN_placeholder'); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param string $placeholder |
|
318 | + * @throws EE_Error |
|
319 | + * @throws ReflectionException |
|
320 | + */ |
|
321 | + public function setPlaceholder(string $placeholder) |
|
322 | + { |
|
323 | + $this->set('FIN_placeholder', $placeholder); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * Input label displayed on public forms, ie: the actual question text. |
|
329 | + * |
|
330 | + * @return string |
|
331 | + * @throws EE_Error |
|
332 | + * @throws ReflectionException |
|
333 | + */ |
|
334 | + public function publicLabel(): string |
|
335 | + { |
|
336 | + return $this->get('FIN_publicLabel'); |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * @param string $publicLabel |
|
342 | + * @throws EE_Error |
|
343 | + * @throws ReflectionException |
|
344 | + */ |
|
345 | + public function setPublicLabel(string $publicLabel) |
|
346 | + { |
|
347 | + $this->set('FIN_publicLabel', $publicLabel); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * Whether or not the input must be supplied with a value in order to complete the form. |
|
353 | + * |
|
354 | + * @return bool |
|
355 | + * @throws EE_Error |
|
356 | + * @throws ReflectionException |
|
357 | + */ |
|
358 | + public function required(): bool |
|
359 | + { |
|
360 | + return $this->get('FIN_required'); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * @param bool $required |
|
366 | + * @throws EE_Error |
|
367 | + * @throws ReflectionException |
|
368 | + */ |
|
369 | + public function setRequired(bool $required) |
|
370 | + { |
|
371 | + $this->set('FIN_required', $required); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Custom validation text displayed alongside a required form input to assist users with completing the form. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + * @throws EE_Error |
|
380 | + * @throws ReflectionException |
|
381 | + */ |
|
382 | + public function requiredText(): string |
|
383 | + { |
|
384 | + return $this->get('FIN_requiredText'); |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * @param string $requiredText |
|
390 | + * @throws EE_Error |
|
391 | + * @throws ReflectionException |
|
392 | + */ |
|
393 | + public function setRequiredText(string $requiredText) |
|
394 | + { |
|
395 | + $this->set('FIN_requiredText', $requiredText); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + /** |
|
400 | + * Whether form input is active, archived, trashed, or used as a default on new forms. |
|
401 | + * Values correspond to the EEM_Form_Input::STATUS_* constants. |
|
402 | + * |
|
403 | + * @return string |
|
404 | + * @throws EE_Error |
|
405 | + * @throws ReflectionException |
|
406 | + */ |
|
407 | + public function status(): string |
|
408 | + { |
|
409 | + return $this->get('FIN_status'); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * Whether form input is active, archived, trashed, or used as a default on new forms. |
|
415 | + * Values correspond to the EEM_Form_Input::STATUS_* constants. |
|
416 | + * |
|
417 | + * @param string $status |
|
418 | + * @throws EE_Error |
|
419 | + * @throws ReflectionException |
|
420 | + */ |
|
421 | + public function setStatus(string $status) |
|
422 | + { |
|
423 | + $this->set('FIN_status', $status); |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * Form input type. |
|
429 | + * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants. |
|
430 | + * |
|
431 | + * @return string |
|
432 | + * @throws EE_Error |
|
433 | + * @throws ReflectionException |
|
434 | + */ |
|
435 | + public function type(): string |
|
436 | + { |
|
437 | + return $this->get('FIN_type'); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @param string $type |
|
443 | + * @throws EE_Error |
|
444 | + * @throws ReflectionException |
|
445 | + */ |
|
446 | + public function setType(string $type) |
|
447 | + { |
|
448 | + $this->set('FIN_type', $type); |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * ID of the WP User that created this form input. |
|
454 | + * |
|
455 | + * @return int |
|
456 | + * @throws EE_Error |
|
457 | + * @throws ReflectionException |
|
458 | + */ |
|
459 | + public function wpUser(): int |
|
460 | + { |
|
461 | + return $this->get('FIN_wpUser'); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * returns the id the wordpress user who created this question |
|
467 | + * |
|
468 | + * @param int $wp_user |
|
469 | + * @throws EE_Error |
|
470 | + * @throws ReflectionException |
|
471 | + */ |
|
472 | + public function setWpUser(int $wp_user) |
|
473 | + { |
|
474 | + $this->set('FIN_wpUser', $wp_user); |
|
475 | + } |
|
476 | 476 | } |
@@ -19,225 +19,225 @@ |
||
19 | 19 | class EE_Form_Section extends EE_Base_Class |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param array $props_n_values |
|
24 | - * @return EE_Form_Section |
|
25 | - * @throws EE_Error |
|
26 | - * @throws ReflectionException |
|
27 | - */ |
|
28 | - public static function new_instance(array $props_n_values = []): EE_Form_Section |
|
29 | - { |
|
30 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
31 | - return $has_object |
|
32 | - ?: new self($props_n_values); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @param array $props_n_values |
|
38 | - * @return EE_Form_Section |
|
39 | - * @throws EE_Error |
|
40 | - * @throws ReflectionException |
|
41 | - */ |
|
42 | - public static function new_instance_from_db(array $props_n_values = []): EE_Form_Section |
|
43 | - { |
|
44 | - return new self($props_n_values); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Form Section UUID (universally unique identifier) |
|
50 | - * |
|
51 | - * @return string |
|
52 | - * @throws EE_Error |
|
53 | - * @throws ReflectionException |
|
54 | - */ |
|
55 | - public function UUID(): string |
|
56 | - { |
|
57 | - return $this->get('FSC_UUID'); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param string $UUID |
|
63 | - * @throws EE_Error |
|
64 | - * @throws ReflectionException |
|
65 | - */ |
|
66 | - public function setUUID(string $UUID) |
|
67 | - { |
|
68 | - $this->set('FSC_UUID', $UUID); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * Form user types that this form section should be presented to. |
|
74 | - * Values correspond to the EEM_Form_Section::APPLIES_TO_* constants. |
|
75 | - * |
|
76 | - * @return string |
|
77 | - * @throws EE_Error |
|
78 | - * @throws ReflectionException |
|
79 | - */ |
|
80 | - public function appliesTo(): string |
|
81 | - { |
|
82 | - return $this->get('FSC_appliesTo'); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param string $user_type |
|
88 | - * @throws EE_Error |
|
89 | - * @throws ReflectionException |
|
90 | - */ |
|
91 | - public function setAppliesTo(string $user_type) |
|
92 | - { |
|
93 | - $this->set('FSC_appliesTo', $user_type); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * UUID or ID of related entity this form section belongs to. |
|
99 | - * |
|
100 | - * @return string |
|
101 | - * @throws EE_Error |
|
102 | - * @throws ReflectionException |
|
103 | - */ |
|
104 | - public function belongsTo(): string |
|
105 | - { |
|
106 | - return $this->get('FSC_belongsTo'); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @param string $relation_UUID |
|
112 | - * @throws EE_Error |
|
113 | - * @throws ReflectionException |
|
114 | - */ |
|
115 | - public function setBelongsTo(string $relation_UUID) |
|
116 | - { |
|
117 | - $this->set('FSC_belongsTo', $relation_UUID); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * HTML classes to be applied to this form section's container. |
|
123 | - * |
|
124 | - * @return string |
|
125 | - * @throws EE_Error |
|
126 | - * @throws ReflectionException |
|
127 | - */ |
|
128 | - public function htmlClass(): string |
|
129 | - { |
|
130 | - return $this->get('FSC_htmlClass'); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param string $html_class |
|
136 | - * @throws EE_Error |
|
137 | - * @throws ReflectionException |
|
138 | - */ |
|
139 | - public function setHtmlClass(string $html_class) |
|
140 | - { |
|
141 | - $this->set('FSC_htmlClass', $html_class); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Order in which form section appears in a form. |
|
147 | - * |
|
148 | - * @return int |
|
149 | - * @throws EE_Error |
|
150 | - * @throws ReflectionException |
|
151 | - */ |
|
152 | - public function order(): int |
|
153 | - { |
|
154 | - return $this->get('FSC_order'); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @param int $order |
|
160 | - * @throws EE_Error |
|
161 | - * @throws ReflectionException |
|
162 | - */ |
|
163 | - public function setOrder(int $order) |
|
164 | - { |
|
165 | - $this->set('FSC_order', $order); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * Related model type. |
|
171 | - * |
|
172 | - * @return string |
|
173 | - * @throws EE_Error |
|
174 | - * @throws ReflectionException |
|
175 | - */ |
|
176 | - public function relation(): string |
|
177 | - { |
|
178 | - return $this->get('FSC_relation'); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @param string $relation |
|
184 | - * @throws EE_Error |
|
185 | - * @throws ReflectionException |
|
186 | - */ |
|
187 | - public function setRelation(string $relation) |
|
188 | - { |
|
189 | - $this->set('FSC_relation', $relation); |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Whether form section is active, archived, trashed, or used as a default on new forms. |
|
195 | - * Values correspond to the EEM_Form_Section::STATUS_* constants. |
|
196 | - * |
|
197 | - * @return string |
|
198 | - * @throws EE_Error |
|
199 | - * @throws ReflectionException |
|
200 | - */ |
|
201 | - public function status(): string |
|
202 | - { |
|
203 | - return $this->get('FSC_status'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * Whether form section is active, archived, trashed, or used as a default on new forms. |
|
209 | - * Values correspond to the EEM_Form_Section::STATUS_* constants. |
|
210 | - * |
|
211 | - * @param string $status |
|
212 | - * @throws EE_Error |
|
213 | - * @throws ReflectionException |
|
214 | - */ |
|
215 | - public function setStatus(string $status) |
|
216 | - { |
|
217 | - $this->set('FSC_status', $status); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * returns the id the wordpress user who created this question |
|
223 | - * |
|
224 | - * @return int |
|
225 | - * @throws EE_Error |
|
226 | - * @throws ReflectionException |
|
227 | - */ |
|
228 | - public function wpUser(): int |
|
229 | - { |
|
230 | - return $this->get('FSC_wpUser'); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * @param int $wp_user |
|
236 | - * @throws EE_Error |
|
237 | - * @throws ReflectionException |
|
238 | - */ |
|
239 | - public function setWpUser(int $wp_user) |
|
240 | - { |
|
241 | - $this->set('FSC_wpUser', $wp_user); |
|
242 | - } |
|
22 | + /** |
|
23 | + * @param array $props_n_values |
|
24 | + * @return EE_Form_Section |
|
25 | + * @throws EE_Error |
|
26 | + * @throws ReflectionException |
|
27 | + */ |
|
28 | + public static function new_instance(array $props_n_values = []): EE_Form_Section |
|
29 | + { |
|
30 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
31 | + return $has_object |
|
32 | + ?: new self($props_n_values); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @param array $props_n_values |
|
38 | + * @return EE_Form_Section |
|
39 | + * @throws EE_Error |
|
40 | + * @throws ReflectionException |
|
41 | + */ |
|
42 | + public static function new_instance_from_db(array $props_n_values = []): EE_Form_Section |
|
43 | + { |
|
44 | + return new self($props_n_values); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Form Section UUID (universally unique identifier) |
|
50 | + * |
|
51 | + * @return string |
|
52 | + * @throws EE_Error |
|
53 | + * @throws ReflectionException |
|
54 | + */ |
|
55 | + public function UUID(): string |
|
56 | + { |
|
57 | + return $this->get('FSC_UUID'); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param string $UUID |
|
63 | + * @throws EE_Error |
|
64 | + * @throws ReflectionException |
|
65 | + */ |
|
66 | + public function setUUID(string $UUID) |
|
67 | + { |
|
68 | + $this->set('FSC_UUID', $UUID); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * Form user types that this form section should be presented to. |
|
74 | + * Values correspond to the EEM_Form_Section::APPLIES_TO_* constants. |
|
75 | + * |
|
76 | + * @return string |
|
77 | + * @throws EE_Error |
|
78 | + * @throws ReflectionException |
|
79 | + */ |
|
80 | + public function appliesTo(): string |
|
81 | + { |
|
82 | + return $this->get('FSC_appliesTo'); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param string $user_type |
|
88 | + * @throws EE_Error |
|
89 | + * @throws ReflectionException |
|
90 | + */ |
|
91 | + public function setAppliesTo(string $user_type) |
|
92 | + { |
|
93 | + $this->set('FSC_appliesTo', $user_type); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * UUID or ID of related entity this form section belongs to. |
|
99 | + * |
|
100 | + * @return string |
|
101 | + * @throws EE_Error |
|
102 | + * @throws ReflectionException |
|
103 | + */ |
|
104 | + public function belongsTo(): string |
|
105 | + { |
|
106 | + return $this->get('FSC_belongsTo'); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @param string $relation_UUID |
|
112 | + * @throws EE_Error |
|
113 | + * @throws ReflectionException |
|
114 | + */ |
|
115 | + public function setBelongsTo(string $relation_UUID) |
|
116 | + { |
|
117 | + $this->set('FSC_belongsTo', $relation_UUID); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * HTML classes to be applied to this form section's container. |
|
123 | + * |
|
124 | + * @return string |
|
125 | + * @throws EE_Error |
|
126 | + * @throws ReflectionException |
|
127 | + */ |
|
128 | + public function htmlClass(): string |
|
129 | + { |
|
130 | + return $this->get('FSC_htmlClass'); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param string $html_class |
|
136 | + * @throws EE_Error |
|
137 | + * @throws ReflectionException |
|
138 | + */ |
|
139 | + public function setHtmlClass(string $html_class) |
|
140 | + { |
|
141 | + $this->set('FSC_htmlClass', $html_class); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Order in which form section appears in a form. |
|
147 | + * |
|
148 | + * @return int |
|
149 | + * @throws EE_Error |
|
150 | + * @throws ReflectionException |
|
151 | + */ |
|
152 | + public function order(): int |
|
153 | + { |
|
154 | + return $this->get('FSC_order'); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @param int $order |
|
160 | + * @throws EE_Error |
|
161 | + * @throws ReflectionException |
|
162 | + */ |
|
163 | + public function setOrder(int $order) |
|
164 | + { |
|
165 | + $this->set('FSC_order', $order); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * Related model type. |
|
171 | + * |
|
172 | + * @return string |
|
173 | + * @throws EE_Error |
|
174 | + * @throws ReflectionException |
|
175 | + */ |
|
176 | + public function relation(): string |
|
177 | + { |
|
178 | + return $this->get('FSC_relation'); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @param string $relation |
|
184 | + * @throws EE_Error |
|
185 | + * @throws ReflectionException |
|
186 | + */ |
|
187 | + public function setRelation(string $relation) |
|
188 | + { |
|
189 | + $this->set('FSC_relation', $relation); |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Whether form section is active, archived, trashed, or used as a default on new forms. |
|
195 | + * Values correspond to the EEM_Form_Section::STATUS_* constants. |
|
196 | + * |
|
197 | + * @return string |
|
198 | + * @throws EE_Error |
|
199 | + * @throws ReflectionException |
|
200 | + */ |
|
201 | + public function status(): string |
|
202 | + { |
|
203 | + return $this->get('FSC_status'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * Whether form section is active, archived, trashed, or used as a default on new forms. |
|
209 | + * Values correspond to the EEM_Form_Section::STATUS_* constants. |
|
210 | + * |
|
211 | + * @param string $status |
|
212 | + * @throws EE_Error |
|
213 | + * @throws ReflectionException |
|
214 | + */ |
|
215 | + public function setStatus(string $status) |
|
216 | + { |
|
217 | + $this->set('FSC_status', $status); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * returns the id the wordpress user who created this question |
|
223 | + * |
|
224 | + * @return int |
|
225 | + * @throws EE_Error |
|
226 | + * @throws ReflectionException |
|
227 | + */ |
|
228 | + public function wpUser(): int |
|
229 | + { |
|
230 | + return $this->get('FSC_wpUser'); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * @param int $wp_user |
|
236 | + * @throws EE_Error |
|
237 | + * @throws ReflectionException |
|
238 | + */ |
|
239 | + public function setWpUser(int $wp_user) |
|
240 | + { |
|
241 | + $this->set('FSC_wpUser', $wp_user); |
|
242 | + } |
|
243 | 243 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
44 | - * @param array $registrations |
|
44 | + * @param EE_Registration[] $registrations |
|
45 | 45 | * @return array |
46 | 46 | * @throws EE_Error |
47 | 47 | * @throws ReflectionException |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
56 | 56 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
57 | 57 | if ($registration->ticket()->ID() !== $prev_ticket) { |
58 | - $item_name = $registration->ticket()->name(); |
|
59 | - $item_name .= $registration->ticket()->description() !== '' |
|
60 | - ? ' - ' . $registration->ticket()->description() |
|
58 | + $item_name = $registration->ticket()->name(); |
|
59 | + $item_name .= $registration->ticket()->description() !== '' |
|
60 | + ? ' - '.$registration->ticket()->description() |
|
61 | 61 | : ''; |
62 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] |
|
62 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] |
|
63 | 63 | = new EE_Form_Section_HTML( |
64 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
64 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
65 | 65 | ); |
66 | 66 | $prev_ticket = $registration->ticket()->ID(); |
67 | 67 | } |
68 | 68 | |
69 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] |
|
69 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] |
|
70 | 70 | = new EE_Checkbox_Multi_Input( |
71 | 71 | [ |
72 | 72 | $registration->ID() => sprintf( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ), |
76 | 76 | ], |
77 | 77 | [ |
78 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
78 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
79 | 79 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
80 | 80 | 'display_html_label_text' => false, |
81 | 81 | ] |
@@ -12,76 +12,76 @@ |
||
12 | 12 | |
13 | 13 | class LegacyCopyAttendeeInfoForm extends EE_Form_Section_Proper |
14 | 14 | { |
15 | - /** |
|
16 | - * LegacyCopyAttendeeInfoForm constructor. |
|
17 | - * |
|
18 | - * @param EE_Registration[] $registrations |
|
19 | - * @param string $slug |
|
20 | - * @throws EE_Error |
|
21 | - * @throws ReflectionException |
|
22 | - */ |
|
23 | - public function __construct(array $registrations, string $slug) |
|
24 | - { |
|
25 | - parent::__construct( |
|
26 | - [ |
|
27 | - 'subsections' => $this->copyAttendeeInfoInputs($registrations), |
|
28 | - 'layout_strategy' => new EE_Template_Layout( |
|
29 | - [ |
|
30 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
31 | - . $slug |
|
32 | - . '/copy_attendee_info.template.php', |
|
33 | - 'begin_template_file' => null, |
|
34 | - 'input_template_file' => null, |
|
35 | - 'subsection_template_file' => null, |
|
36 | - 'end_template_file' => null, |
|
37 | - ] |
|
38 | - ), |
|
39 | - ]); |
|
40 | - } |
|
15 | + /** |
|
16 | + * LegacyCopyAttendeeInfoForm constructor. |
|
17 | + * |
|
18 | + * @param EE_Registration[] $registrations |
|
19 | + * @param string $slug |
|
20 | + * @throws EE_Error |
|
21 | + * @throws ReflectionException |
|
22 | + */ |
|
23 | + public function __construct(array $registrations, string $slug) |
|
24 | + { |
|
25 | + parent::__construct( |
|
26 | + [ |
|
27 | + 'subsections' => $this->copyAttendeeInfoInputs($registrations), |
|
28 | + 'layout_strategy' => new EE_Template_Layout( |
|
29 | + [ |
|
30 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
31 | + . $slug |
|
32 | + . '/copy_attendee_info.template.php', |
|
33 | + 'begin_template_file' => null, |
|
34 | + 'input_template_file' => null, |
|
35 | + 'subsection_template_file' => null, |
|
36 | + 'end_template_file' => null, |
|
37 | + ] |
|
38 | + ), |
|
39 | + ]); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param array $registrations |
|
45 | - * @return array |
|
46 | - * @throws EE_Error |
|
47 | - * @throws ReflectionException |
|
48 | - */ |
|
49 | - private function copyAttendeeInfoInputs(array $registrations): array |
|
50 | - { |
|
51 | - $copy_attendee_info_inputs = []; |
|
52 | - $prev_ticket = null; |
|
53 | - foreach ($registrations as $registration) { |
|
54 | - // for all attendees other than the primary attendee |
|
55 | - if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
56 | - // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
57 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
58 | - $item_name = $registration->ticket()->name(); |
|
59 | - $item_name .= $registration->ticket()->description() !== '' |
|
60 | - ? ' - ' . $registration->ticket()->description() |
|
61 | - : ''; |
|
62 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] |
|
63 | - = new EE_Form_Section_HTML( |
|
64 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
65 | - ); |
|
66 | - $prev_ticket = $registration->ticket()->ID(); |
|
67 | - } |
|
43 | + /** |
|
44 | + * @param array $registrations |
|
45 | + * @return array |
|
46 | + * @throws EE_Error |
|
47 | + * @throws ReflectionException |
|
48 | + */ |
|
49 | + private function copyAttendeeInfoInputs(array $registrations): array |
|
50 | + { |
|
51 | + $copy_attendee_info_inputs = []; |
|
52 | + $prev_ticket = null; |
|
53 | + foreach ($registrations as $registration) { |
|
54 | + // for all attendees other than the primary attendee |
|
55 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
56 | + // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
57 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
58 | + $item_name = $registration->ticket()->name(); |
|
59 | + $item_name .= $registration->ticket()->description() !== '' |
|
60 | + ? ' - ' . $registration->ticket()->description() |
|
61 | + : ''; |
|
62 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] |
|
63 | + = new EE_Form_Section_HTML( |
|
64 | + '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
65 | + ); |
|
66 | + $prev_ticket = $registration->ticket()->ID(); |
|
67 | + } |
|
68 | 68 | |
69 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] |
|
70 | - = new EE_Checkbox_Multi_Input( |
|
71 | - [ |
|
72 | - $registration->ID() => sprintf( |
|
73 | - esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
74 | - $registration->count() |
|
75 | - ), |
|
76 | - ], |
|
77 | - [ |
|
78 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
79 | - 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
80 | - 'display_html_label_text' => false, |
|
81 | - ] |
|
82 | - ); |
|
83 | - } |
|
84 | - } |
|
85 | - return $copy_attendee_info_inputs; |
|
86 | - } |
|
69 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] |
|
70 | + = new EE_Checkbox_Multi_Input( |
|
71 | + [ |
|
72 | + $registration->ID() => sprintf( |
|
73 | + esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
74 | + $registration->count() |
|
75 | + ), |
|
76 | + ], |
|
77 | + [ |
|
78 | + 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
79 | + 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
80 | + 'display_html_label_text' => false, |
|
81 | + ] |
|
82 | + ); |
|
83 | + } |
|
84 | + } |
|
85 | + return $copy_attendee_info_inputs; |
|
86 | + } |
|
87 | 87 | } |
@@ -12,97 +12,97 @@ |
||
12 | 12 | |
13 | 13 | class StateOptions |
14 | 14 | { |
15 | - /** |
|
16 | - * the action being performed on the current step |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - public $action = ''; |
|
15 | + /** |
|
16 | + * the action being performed on the current step |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + public $action = ''; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var EEM_State |
|
24 | - */ |
|
25 | - public $state_model; |
|
22 | + /** |
|
23 | + * @var EEM_State |
|
24 | + */ |
|
25 | + public $state_model; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var [][] |
|
29 | - */ |
|
30 | - private $state_options = []; |
|
27 | + /** |
|
28 | + * @var [][] |
|
29 | + */ |
|
30 | + private $state_options = []; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * CountryOptions constructor. |
|
35 | - * |
|
36 | - * @param string $action |
|
37 | - * @param EEM_State $state_model |
|
38 | - */ |
|
39 | - public function __construct(string $action, EEM_State $state_model) |
|
40 | - { |
|
41 | - $this->action = $action; |
|
42 | - $this->state_model = $state_model; |
|
43 | - add_filter( |
|
44 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
45 | - [$this, 'forLegacyFormInput'], |
|
46 | - 10, |
|
47 | - 4 |
|
48 | - ); |
|
49 | - } |
|
33 | + /** |
|
34 | + * CountryOptions constructor. |
|
35 | + * |
|
36 | + * @param string $action |
|
37 | + * @param EEM_State $state_model |
|
38 | + */ |
|
39 | + public function __construct(string $action, EEM_State $state_model) |
|
40 | + { |
|
41 | + $this->action = $action; |
|
42 | + $this->state_model = $state_model; |
|
43 | + add_filter( |
|
44 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
45 | + [$this, 'forLegacyFormInput'], |
|
46 | + 10, |
|
47 | + 4 |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Gets the list of states for the form input |
|
54 | - * |
|
55 | - * @param array|null $states_list deprecated prop from an old hook |
|
56 | - * @param EE_Question|null $question |
|
57 | - * @param EE_Registration|null $registration |
|
58 | - * @param EE_Answer|null $answer |
|
59 | - * @return array 2d keys are state IDs, values are their names |
|
60 | - * @throws EE_Error |
|
61 | - * @throws ReflectionException |
|
62 | - */ |
|
63 | - public function forLegacyFormInput( |
|
64 | - array $states_list = null, |
|
65 | - EE_Question $question = null, |
|
66 | - EE_Registration $registration = null, |
|
67 | - EE_Answer $answer = null |
|
68 | - ): array { |
|
69 | - if (! isset($this->state_options[ $this->action ])) { |
|
70 | - $this->generateLegacyStateOptions($question, $registration, $answer); |
|
71 | - } |
|
72 | - return $this->state_options[ $this->action ]; |
|
73 | - } |
|
52 | + /** |
|
53 | + * Gets the list of states for the form input |
|
54 | + * |
|
55 | + * @param array|null $states_list deprecated prop from an old hook |
|
56 | + * @param EE_Question|null $question |
|
57 | + * @param EE_Registration|null $registration |
|
58 | + * @param EE_Answer|null $answer |
|
59 | + * @return array 2d keys are state IDs, values are their names |
|
60 | + * @throws EE_Error |
|
61 | + * @throws ReflectionException |
|
62 | + */ |
|
63 | + public function forLegacyFormInput( |
|
64 | + array $states_list = null, |
|
65 | + EE_Question $question = null, |
|
66 | + EE_Registration $registration = null, |
|
67 | + EE_Answer $answer = null |
|
68 | + ): array { |
|
69 | + if (! isset($this->state_options[ $this->action ])) { |
|
70 | + $this->generateLegacyStateOptions($question, $registration, $answer); |
|
71 | + } |
|
72 | + return $this->state_options[ $this->action ]; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * @param EE_Question|null $question |
|
78 | - * @param EE_Registration|null $registration |
|
79 | - * @param EE_Answer|null $answer |
|
80 | - * @throws EE_Error |
|
81 | - * @throws ReflectionException |
|
82 | - */ |
|
83 | - private function generateLegacyStateOptions( |
|
84 | - EE_Question $question = null, |
|
85 | - EE_Registration $registration = null, |
|
86 | - EE_Answer $answer = null |
|
87 | - ) { |
|
88 | - $state_options = ['' => ['' => '']]; |
|
89 | - $states = $this->action === 'process_reg_step' |
|
90 | - ? $this->state_model->get_all_states() |
|
91 | - : $this->state_model->get_all_active_states(); |
|
92 | - if (! empty($states)) { |
|
93 | - foreach ($states as $state) { |
|
94 | - if ($state instanceof EE_State) { |
|
95 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - $this->state_options[ $this->action ] = apply_filters( |
|
100 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
101 | - $state_options, |
|
102 | - $this, |
|
103 | - $registration, |
|
104 | - $question, |
|
105 | - $answer |
|
106 | - ); |
|
107 | - } |
|
76 | + /** |
|
77 | + * @param EE_Question|null $question |
|
78 | + * @param EE_Registration|null $registration |
|
79 | + * @param EE_Answer|null $answer |
|
80 | + * @throws EE_Error |
|
81 | + * @throws ReflectionException |
|
82 | + */ |
|
83 | + private function generateLegacyStateOptions( |
|
84 | + EE_Question $question = null, |
|
85 | + EE_Registration $registration = null, |
|
86 | + EE_Answer $answer = null |
|
87 | + ) { |
|
88 | + $state_options = ['' => ['' => '']]; |
|
89 | + $states = $this->action === 'process_reg_step' |
|
90 | + ? $this->state_model->get_all_states() |
|
91 | + : $this->state_model->get_all_active_states(); |
|
92 | + if (! empty($states)) { |
|
93 | + foreach ($states as $state) { |
|
94 | + if ($state instanceof EE_State) { |
|
95 | + $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + $this->state_options[ $this->action ] = apply_filters( |
|
100 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
101 | + $state_options, |
|
102 | + $this, |
|
103 | + $registration, |
|
104 | + $question, |
|
105 | + $answer |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | EE_Registration $registration = null, |
67 | 67 | EE_Answer $answer = null |
68 | 68 | ): array { |
69 | - if (! isset($this->state_options[ $this->action ])) { |
|
69 | + if ( ! isset($this->state_options[$this->action])) { |
|
70 | 70 | $this->generateLegacyStateOptions($question, $registration, $answer); |
71 | 71 | } |
72 | - return $this->state_options[ $this->action ]; |
|
72 | + return $this->state_options[$this->action]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | $states = $this->action === 'process_reg_step' |
90 | 90 | ? $this->state_model->get_all_states() |
91 | 91 | : $this->state_model->get_all_active_states(); |
92 | - if (! empty($states)) { |
|
92 | + if ( ! empty($states)) { |
|
93 | 93 | foreach ($states as $state) { |
94 | 94 | if ($state instanceof EE_State) { |
95 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
95 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | - $this->state_options[ $this->action ] = apply_filters( |
|
99 | + $this->state_options[$this->action] = apply_filters( |
|
100 | 100 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
101 | 101 | $state_options, |
102 | 102 | $this, |
@@ -13,109 +13,109 @@ |
||
13 | 13 | |
14 | 14 | class CountryOptions |
15 | 15 | { |
16 | - /** |
|
17 | - * the action being performed on the current step |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $action = ''; |
|
16 | + /** |
|
17 | + * the action being performed on the current step |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $action = ''; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var EEM_Answer |
|
25 | - */ |
|
26 | - public $answer_model; |
|
23 | + /** |
|
24 | + * @var EEM_Answer |
|
25 | + */ |
|
26 | + public $answer_model; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var EEM_Country |
|
30 | - */ |
|
31 | - public $country_model; |
|
28 | + /** |
|
29 | + * @var EEM_Country |
|
30 | + */ |
|
31 | + public $country_model; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var [][] |
|
35 | - */ |
|
36 | - private $country_options = []; |
|
33 | + /** |
|
34 | + * @var [][] |
|
35 | + */ |
|
36 | + private $country_options = []; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * CountryOptions constructor. |
|
41 | - * |
|
42 | - * @param string $action |
|
43 | - * @param EEM_Answer $answer_model |
|
44 | - * @param EEM_Country $country_model |
|
45 | - */ |
|
46 | - public function __construct(string $action, EEM_Answer $answer_model, EEM_Country $country_model) |
|
47 | - { |
|
48 | - $this->action = $action; |
|
49 | - $this->answer_model = $answer_model; |
|
50 | - $this->country_model = $country_model; |
|
51 | - add_filter( |
|
52 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
53 | - [$this, 'forLegacyFormInput'], |
|
54 | - 10, |
|
55 | - 4 |
|
56 | - ); |
|
57 | - } |
|
39 | + /** |
|
40 | + * CountryOptions constructor. |
|
41 | + * |
|
42 | + * @param string $action |
|
43 | + * @param EEM_Answer $answer_model |
|
44 | + * @param EEM_Country $country_model |
|
45 | + */ |
|
46 | + public function __construct(string $action, EEM_Answer $answer_model, EEM_Country $country_model) |
|
47 | + { |
|
48 | + $this->action = $action; |
|
49 | + $this->answer_model = $answer_model; |
|
50 | + $this->country_model = $country_model; |
|
51 | + add_filter( |
|
52 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
53 | + [$this, 'forLegacyFormInput'], |
|
54 | + 10, |
|
55 | + 4 |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Gets the list of countries for the form input |
|
62 | - * |
|
63 | - * @param array|null $countries_list deprecated prop from an old hook |
|
64 | - * @param EE_Question|null $question |
|
65 | - * @param EE_Registration|null $registration |
|
66 | - * @param EE_Answer|null $answer deprecated prop from an old hook |
|
67 | - * @return array 2d keys are country IDs, values are their names |
|
68 | - * @throws EE_Error |
|
69 | - * @throws ReflectionException |
|
70 | - */ |
|
71 | - public function forLegacyFormInput( |
|
72 | - array $countries_list = null, |
|
73 | - EE_Question $question = null, |
|
74 | - EE_Registration $registration = null, |
|
75 | - EE_Answer $answer = null |
|
76 | - ): array { |
|
77 | - if (! isset($this->country_options[ $this->action ])) { |
|
78 | - $this->generateLegacyCountryOptions($question, $registration); |
|
79 | - } |
|
80 | - return $this->country_options[ $this->action ]; |
|
81 | - } |
|
60 | + /** |
|
61 | + * Gets the list of countries for the form input |
|
62 | + * |
|
63 | + * @param array|null $countries_list deprecated prop from an old hook |
|
64 | + * @param EE_Question|null $question |
|
65 | + * @param EE_Registration|null $registration |
|
66 | + * @param EE_Answer|null $answer deprecated prop from an old hook |
|
67 | + * @return array 2d keys are country IDs, values are their names |
|
68 | + * @throws EE_Error |
|
69 | + * @throws ReflectionException |
|
70 | + */ |
|
71 | + public function forLegacyFormInput( |
|
72 | + array $countries_list = null, |
|
73 | + EE_Question $question = null, |
|
74 | + EE_Registration $registration = null, |
|
75 | + EE_Answer $answer = null |
|
76 | + ): array { |
|
77 | + if (! isset($this->country_options[ $this->action ])) { |
|
78 | + $this->generateLegacyCountryOptions($question, $registration); |
|
79 | + } |
|
80 | + return $this->country_options[ $this->action ]; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param EE_Question|null $question |
|
86 | - * @param EE_Registration|null $registration |
|
87 | - * @throws EE_Error |
|
88 | - * @throws ReflectionException |
|
89 | - */ |
|
90 | - private function generateLegacyCountryOptions(EE_Question $question = null, EE_Registration $registration = null) |
|
91 | - { |
|
92 | - // get possibly cached list of countries |
|
93 | - $countries = $this->action === 'process_reg_step' |
|
94 | - ? $this->country_model->get_all_countries() |
|
95 | - : $this->country_model->get_all_active_countries(); |
|
96 | - // start with an empty option |
|
97 | - $country_options = ['' => '']; |
|
98 | - if (! empty($countries)) { |
|
99 | - foreach ($countries as $country) { |
|
100 | - if ($country instanceof EE_Country) { |
|
101 | - $country_options[ $country->ID() ] = $country->name(); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
106 | - $answer = $this->answer_model->get_one( |
|
107 | - [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
108 | - ); |
|
109 | - } else { |
|
110 | - $answer = EE_Answer::new_instance(); |
|
111 | - } |
|
112 | - $this->country_options[ $this->action ] = apply_filters( |
|
113 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
114 | - $country_options, |
|
115 | - $this, |
|
116 | - $registration, |
|
117 | - $question, |
|
118 | - $answer |
|
119 | - ); |
|
120 | - } |
|
84 | + /** |
|
85 | + * @param EE_Question|null $question |
|
86 | + * @param EE_Registration|null $registration |
|
87 | + * @throws EE_Error |
|
88 | + * @throws ReflectionException |
|
89 | + */ |
|
90 | + private function generateLegacyCountryOptions(EE_Question $question = null, EE_Registration $registration = null) |
|
91 | + { |
|
92 | + // get possibly cached list of countries |
|
93 | + $countries = $this->action === 'process_reg_step' |
|
94 | + ? $this->country_model->get_all_countries() |
|
95 | + : $this->country_model->get_all_active_countries(); |
|
96 | + // start with an empty option |
|
97 | + $country_options = ['' => '']; |
|
98 | + if (! empty($countries)) { |
|
99 | + foreach ($countries as $country) { |
|
100 | + if ($country instanceof EE_Country) { |
|
101 | + $country_options[ $country->ID() ] = $country->name(); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
106 | + $answer = $this->answer_model->get_one( |
|
107 | + [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
108 | + ); |
|
109 | + } else { |
|
110 | + $answer = EE_Answer::new_instance(); |
|
111 | + } |
|
112 | + $this->country_options[ $this->action ] = apply_filters( |
|
113 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
114 | + $country_options, |
|
115 | + $this, |
|
116 | + $registration, |
|
117 | + $question, |
|
118 | + $answer |
|
119 | + ); |
|
120 | + } |
|
121 | 121 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | EE_Registration $registration = null, |
75 | 75 | EE_Answer $answer = null |
76 | 76 | ): array { |
77 | - if (! isset($this->country_options[ $this->action ])) { |
|
77 | + if ( ! isset($this->country_options[$this->action])) { |
|
78 | 78 | $this->generateLegacyCountryOptions($question, $registration); |
79 | 79 | } |
80 | - return $this->country_options[ $this->action ]; |
|
80 | + return $this->country_options[$this->action]; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | : $this->country_model->get_all_active_countries(); |
96 | 96 | // start with an empty option |
97 | 97 | $country_options = ['' => '']; |
98 | - if (! empty($countries)) { |
|
98 | + if ( ! empty($countries)) { |
|
99 | 99 | foreach ($countries as $country) { |
100 | 100 | if ($country instanceof EE_Country) { |
101 | - $country_options[ $country->ID() ] = $country->name(); |
|
101 | + $country_options[$country->ID()] = $country->name(); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } else { |
110 | 110 | $answer = EE_Answer::new_instance(); |
111 | 111 | } |
112 | - $this->country_options[ $this->action ] = apply_filters( |
|
112 | + $this->country_options[$this->action] = apply_filters( |
|
113 | 113 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
114 | 114 | $country_options, |
115 | 115 | $this, |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | parent::__construct( |
17 | 17 | EEH_Template::locate_template( |
18 | - SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php', |
|
18 | + SPCO_REG_STEPS_PATH.$slug.'/_auto_copy_attendee_info.template.php', |
|
19 | 19 | apply_filters( |
20 | 20 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
21 | 21 | [] |
@@ -8,21 +8,21 @@ |
||
8 | 8 | class LegacyAutoCopyAttendeeInfoForm extends EE_Form_Section_HTML |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * LegacyCopyAttendeeInfoForm constructor. |
|
13 | - */ |
|
14 | - public function __construct(string $slug) |
|
15 | - { |
|
16 | - parent::__construct( |
|
17 | - EEH_Template::locate_template( |
|
18 | - SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php', |
|
19 | - apply_filters( |
|
20 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
21 | - [] |
|
22 | - ), |
|
23 | - true, |
|
24 | - true |
|
25 | - ) |
|
26 | - ); |
|
27 | - } |
|
11 | + /** |
|
12 | + * LegacyCopyAttendeeInfoForm constructor. |
|
13 | + */ |
|
14 | + public function __construct(string $slug) |
|
15 | + { |
|
16 | + parent::__construct( |
|
17 | + EEH_Template::locate_template( |
|
18 | + SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php', |
|
19 | + apply_filters( |
|
20 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
21 | + [] |
|
22 | + ), |
|
23 | + true, |
|
24 | + true |
|
25 | + ) |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | } |