@@ -5,59 +5,59 @@ |
||
5 | 5 | class Select |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
10 | - */ |
|
11 | - public const TYPE_SELECT = 'select'; |
|
12 | - |
|
13 | - /** |
|
14 | - * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
15 | - */ |
|
16 | - public const TYPE_SELECT_MULTI = 'select-multi'; |
|
17 | - |
|
18 | - // CUSTOM EE SELECT TYPES |
|
19 | - |
|
20 | - /** |
|
21 | - * indicates that input is an HTML dropdown (select input) |
|
22 | - * populated with names of countries that are enabled for the site |
|
23 | - */ |
|
24 | - public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
25 | - |
|
26 | - /** |
|
27 | - * indicates that the input is an HTML dropdown (select input) |
|
28 | - * populated with names of states for the countries that are enabled for the site |
|
29 | - */ |
|
30 | - public const TYPE_SELECT_STATE = 'select-state'; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $valid_type_options; |
|
37 | - |
|
38 | - |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - $this->valid_type_options = apply_filters( |
|
42 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
43 | - [ |
|
44 | - Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
45 | - Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
46 | - Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
47 | - Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
48 | - ] |
|
49 | - ); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param bool $constants_only |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function validTypeOptions(bool $constants_only = false): array |
|
58 | - { |
|
59 | - return $constants_only |
|
60 | - ? array_keys($this->valid_type_options) |
|
61 | - : $this->valid_type_options; |
|
62 | - } |
|
8 | + /** |
|
9 | + * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
10 | + */ |
|
11 | + public const TYPE_SELECT = 'select'; |
|
12 | + |
|
13 | + /** |
|
14 | + * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
15 | + */ |
|
16 | + public const TYPE_SELECT_MULTI = 'select-multi'; |
|
17 | + |
|
18 | + // CUSTOM EE SELECT TYPES |
|
19 | + |
|
20 | + /** |
|
21 | + * indicates that input is an HTML dropdown (select input) |
|
22 | + * populated with names of countries that are enabled for the site |
|
23 | + */ |
|
24 | + public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
25 | + |
|
26 | + /** |
|
27 | + * indicates that the input is an HTML dropdown (select input) |
|
28 | + * populated with names of states for the countries that are enabled for the site |
|
29 | + */ |
|
30 | + public const TYPE_SELECT_STATE = 'select-state'; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $valid_type_options; |
|
37 | + |
|
38 | + |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + $this->valid_type_options = apply_filters( |
|
42 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
43 | + [ |
|
44 | + Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
45 | + Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
46 | + Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
47 | + Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
48 | + ] |
|
49 | + ); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param bool $constants_only |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function validTypeOptions(bool $constants_only = false): array |
|
58 | + { |
|
59 | + return $constants_only |
|
60 | + ? array_keys($this->valid_type_options) |
|
61 | + : $this->valid_type_options; |
|
62 | + } |
|
63 | 63 | } |
@@ -5,109 +5,109 @@ |
||
5 | 5 | class Phone |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * indicates that the HTML input type is 'tel' |
|
10 | - */ |
|
11 | - public const INPUT_TYPE = 'tel'; |
|
8 | + /** |
|
9 | + * indicates that the HTML input type is 'tel' |
|
10 | + */ |
|
11 | + public const INPUT_TYPE = 'tel'; |
|
12 | 12 | |
13 | - /** |
|
14 | - * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
15 | - * ########## |
|
16 | - * ###-###-#### |
|
17 | - * ### ### #### |
|
18 | - * (###)-###-#### |
|
19 | - * (###) ###-#### |
|
20 | - * |
|
21 | - * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
22 | - * +1 (###) ###-#### |
|
23 | - */ |
|
24 | - public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
13 | + /** |
|
14 | + * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
15 | + * ########## |
|
16 | + * ###-###-#### |
|
17 | + * ### ### #### |
|
18 | + * (###)-###-#### |
|
19 | + * (###) ###-#### |
|
20 | + * |
|
21 | + * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
22 | + * +1 (###) ###-#### |
|
23 | + */ |
|
24 | + public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
28 | - * (###) #### #### |
|
29 | - * (####) ### #### |
|
30 | - * (#####) ## #### |
|
31 | - * |
|
32 | - * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
33 | - * +44 (###) #### #### |
|
34 | - */ |
|
35 | - public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
26 | + /** |
|
27 | + * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
28 | + * (###) #### #### |
|
29 | + * (####) ### #### |
|
30 | + * (#####) ## #### |
|
31 | + * |
|
32 | + * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
33 | + * +44 (###) #### #### |
|
34 | + */ |
|
35 | + public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
36 | 36 | |
37 | - /** |
|
38 | - * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
39 | - * 0# ## ## ## ## |
|
40 | - * 0### ## ## ## |
|
41 | - * |
|
42 | - * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
43 | - * +33 # ## ## ## ## |
|
44 | - * 0033 # ## ## ## ## |
|
45 | - */ |
|
46 | - public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
37 | + /** |
|
38 | + * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
39 | + * 0# ## ## ## ## |
|
40 | + * 0### ## ## ## |
|
41 | + * |
|
42 | + * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
43 | + * +33 # ## ## ## ## |
|
44 | + * 0033 # ## ## ## ## |
|
45 | + */ |
|
46 | + public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
47 | 47 | |
48 | - /** |
|
49 | - * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
50 | - * (0##) ####-#### |
|
51 | - * (0###) ####-#### |
|
52 | - * (0####) ###-#### |
|
53 | - * (03####) ##-#### |
|
54 | - * |
|
55 | - * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
56 | - * +49 (0##) ####-#### |
|
57 | - */ |
|
58 | - public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
48 | + /** |
|
49 | + * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
50 | + * (0##) ####-#### |
|
51 | + * (0###) ####-#### |
|
52 | + * (0####) ###-#### |
|
53 | + * (03####) ##-#### |
|
54 | + * |
|
55 | + * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
56 | + * +49 (0##) ####-#### |
|
57 | + */ |
|
58 | + public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var array |
|
62 | - */ |
|
63 | - private $regex_patterns; |
|
60 | + /** |
|
61 | + * @var array |
|
62 | + */ |
|
63 | + private $regex_patterns; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $valid_type_options; |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $valid_type_options; |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Phone constructor. |
|
73 | - */ |
|
74 | - public function __construct() |
|
75 | - { |
|
76 | - $this->regex_patterns = (array) apply_filters( |
|
77 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
78 | - [ |
|
79 | - 'de_DE' => Phone::PATTERN_DE, |
|
80 | - 'fr_FR' => Phone::PATTERN_FR, |
|
81 | - 'en_UK' => Phone::PATTERN_UK, |
|
82 | - 'en_US' => Phone::PATTERN_US, |
|
83 | - ] |
|
84 | - ); |
|
85 | - $this->valid_type_options = apply_filters( |
|
86 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
87 | - [ |
|
88 | - Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
89 | - ] |
|
90 | - ); |
|
91 | - } |
|
71 | + /** |
|
72 | + * Phone constructor. |
|
73 | + */ |
|
74 | + public function __construct() |
|
75 | + { |
|
76 | + $this->regex_patterns = (array) apply_filters( |
|
77 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
78 | + [ |
|
79 | + 'de_DE' => Phone::PATTERN_DE, |
|
80 | + 'fr_FR' => Phone::PATTERN_FR, |
|
81 | + 'en_UK' => Phone::PATTERN_UK, |
|
82 | + 'en_US' => Phone::PATTERN_US, |
|
83 | + ] |
|
84 | + ); |
|
85 | + $this->valid_type_options = apply_filters( |
|
86 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
87 | + [ |
|
88 | + Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
89 | + ] |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function regexPatterns(): array |
|
98 | - { |
|
99 | - return $this->regex_patterns; |
|
100 | - } |
|
94 | + /** |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function regexPatterns(): array |
|
98 | + { |
|
99 | + return $this->regex_patterns; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @param bool $constants_only |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - public function validTypeOptions(bool $constants_only = false): array |
|
108 | - { |
|
109 | - return $constants_only |
|
110 | - ? array_keys($this->valid_type_options) |
|
111 | - : $this->valid_type_options; |
|
112 | - } |
|
103 | + /** |
|
104 | + * @param bool $constants_only |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + public function validTypeOptions(bool $constants_only = false): array |
|
108 | + { |
|
109 | + return $constants_only |
|
110 | + ? array_keys($this->valid_type_options) |
|
111 | + : $this->valid_type_options; |
|
112 | + } |
|
113 | 113 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | */ |
74 | 74 | public function __construct() |
75 | 75 | { |
76 | - $this->regex_patterns = (array) apply_filters( |
|
76 | + $this->regex_patterns = (array) apply_filters( |
|
77 | 77 | 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
78 | 78 | [ |
79 | 79 | 'de_DE' => Phone::PATTERN_DE, |
@@ -139,7 +139,7 @@ |
||
139 | 139 | bool $nullable = false, |
140 | 140 | string $default_value = EE_Datetime_Field::now |
141 | 141 | ): EE_Datetime_Field { |
142 | - return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
142 | + return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value, ]); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |
@@ -46,618 +46,618 @@ |
||
46 | 46 | */ |
47 | 47 | class ModelFieldFactory |
48 | 48 | { |
49 | - /** |
|
50 | - * @var LoaderInterface $loader |
|
51 | - */ |
|
52 | - private $loader; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * ModelFieldFactory constructor. |
|
57 | - * |
|
58 | - * @param LoaderInterface $loader |
|
59 | - */ |
|
60 | - public function __construct(LoaderInterface $loader) |
|
61 | - { |
|
62 | - $this->loader = $loader; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $table_column |
|
68 | - * @param string $nice_name |
|
69 | - * @param bool $nullable |
|
70 | - * @param null $default_value |
|
71 | - * @return EE_All_Caps_Text_Field |
|
72 | - */ |
|
73 | - public function createAllCapsTextField( |
|
74 | - string $table_column, |
|
75 | - string $nice_name, |
|
76 | - bool $nullable, |
|
77 | - $default_value = null |
|
78 | - ): EE_All_Caps_Text_Field { |
|
79 | - return $this->loader->getNew( |
|
80 | - 'EE_All_Caps_Text_Field', |
|
81 | - [$table_column, $nice_name, $nullable, $default_value] |
|
82 | - ); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param string $table_column |
|
88 | - * @param string $nice_name |
|
89 | - * @param bool $nullable |
|
90 | - * @param null $default_value |
|
91 | - * @param string $model_name |
|
92 | - * @return EE_Any_Foreign_Model_Name_Field |
|
93 | - */ |
|
94 | - public function createAnyForeignModelNameField( |
|
95 | - string $table_column, |
|
96 | - string $nice_name, |
|
97 | - bool $nullable, |
|
98 | - $default_value = null, |
|
99 | - string $model_name = '' |
|
100 | - ): EE_Any_Foreign_Model_Name_Field { |
|
101 | - return $this->loader->getNew( |
|
102 | - 'EE_Any_Foreign_Model_Name_Field', |
|
103 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
104 | - ); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $table_column |
|
110 | - * @param string $nice_name |
|
111 | - * @param bool $nullable |
|
112 | - * @param null $default_value |
|
113 | - * @return EE_Boolean_Field |
|
114 | - */ |
|
115 | - public function createBooleanField( |
|
116 | - string $table_column, |
|
117 | - string $nice_name, |
|
118 | - bool $nullable, |
|
119 | - $default_value = null |
|
120 | - ): EE_Boolean_Field { |
|
121 | - return $this->loader->getNew( |
|
122 | - 'EE_Boolean_Field', |
|
123 | - [$table_column, $nice_name, $nullable, $default_value] |
|
124 | - ); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param string $table_column |
|
130 | - * @param string $nice_name |
|
131 | - * @param bool $nullable |
|
132 | - * @param string $default_value |
|
133 | - * @return EE_Datetime_Field |
|
134 | - */ |
|
135 | - public function createDatetimeField( |
|
136 | - string $table_column, |
|
137 | - string $nice_name, |
|
138 | - bool $nullable = false, |
|
139 | - string $default_value = EE_Datetime_Field::now |
|
140 | - ): EE_Datetime_Field { |
|
141 | - return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * @param string $table_column |
|
147 | - * @param string $nice_name |
|
148 | - * @param bool $nullable |
|
149 | - * @param null $default_value |
|
150 | - * @return EE_DB_Only_Float_Field |
|
151 | - */ |
|
152 | - public function createDbOnlyFloatField( |
|
153 | - string $table_column, |
|
154 | - string $nice_name, |
|
155 | - bool $nullable, |
|
156 | - $default_value = null |
|
157 | - ): EE_DB_Only_Float_Field { |
|
158 | - return $this->loader->getNew( |
|
159 | - 'EE_DB_Only_Float_Field', |
|
160 | - [$table_column, $nice_name, $nullable, $default_value] |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param string $table_column |
|
167 | - * @param string $nice_name |
|
168 | - * @param bool $nullable |
|
169 | - * @param null $default_value |
|
170 | - * @return EE_DB_Only_Int_Field |
|
171 | - */ |
|
172 | - public function createDbOnlyIntField( |
|
173 | - string $table_column, |
|
174 | - string $nice_name, |
|
175 | - bool $nullable, |
|
176 | - $default_value = null |
|
177 | - ): EE_DB_Only_Int_Field { |
|
178 | - return $this->loader->getNew( |
|
179 | - 'EE_DB_Only_Int_Field', |
|
180 | - [$table_column, $nice_name, $nullable, $default_value] |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $table_column |
|
187 | - * @param string $nice_name |
|
188 | - * @param bool $nullable |
|
189 | - * @param null $default_value |
|
190 | - * @return EE_DB_Only_Text_Field |
|
191 | - */ |
|
192 | - public function createDbOnlyTextField( |
|
193 | - string $table_column, |
|
194 | - string $nice_name, |
|
195 | - bool $nullable, |
|
196 | - $default_value = null |
|
197 | - ): EE_DB_Only_Text_Field { |
|
198 | - return $this->loader->getNew( |
|
199 | - 'EE_DB_Only_Text_Field', |
|
200 | - [$table_column, $nice_name, $nullable, $default_value] |
|
201 | - ); |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * @param string $table_column |
|
207 | - * @param string $nice_name |
|
208 | - * @param bool $nullable |
|
209 | - * @param string|null $default_value |
|
210 | - * @return EE_Email_Field |
|
211 | - */ |
|
212 | - public function createEmailField( |
|
213 | - string $table_column, |
|
214 | - string $nice_name, |
|
215 | - bool $nullable = true, |
|
216 | - string $default_value = '' |
|
217 | - ): EE_Email_Field { |
|
218 | - return $this->loader->getNew( |
|
219 | - 'EE_Email_Field', |
|
220 | - [$table_column, $nice_name, $nullable, $default_value] |
|
221 | - ); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * @param string $table_column |
|
227 | - * @param string $nice_name |
|
228 | - * @param bool $nullable |
|
229 | - * @param null $default_value |
|
230 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
231 | - * values are how they should be displayed |
|
232 | - * @return EE_Enum_Integer_Field |
|
233 | - */ |
|
234 | - public function createEnumIntegerField( |
|
235 | - string $table_column, |
|
236 | - string $nice_name, |
|
237 | - bool $nullable, |
|
238 | - $default_value = null, |
|
239 | - array $allowed_enum_values = [] |
|
240 | - ): EE_Enum_Integer_Field { |
|
241 | - return $this->loader->getNew( |
|
242 | - 'EE_Enum_Integer_Field', |
|
243 | - [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
244 | - ); |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @param string $table_column |
|
250 | - * @param string $nice_name |
|
251 | - * @param bool $nullable |
|
252 | - * @param null $default_value |
|
253 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
254 | - * values are how they should be displayed |
|
255 | - * @return EE_Enum_Text_Field |
|
256 | - */ |
|
257 | - public function createEnumTextField( |
|
258 | - string $table_column, |
|
259 | - string $nice_name, |
|
260 | - bool $nullable, |
|
261 | - $default_value, |
|
262 | - array $allowed_enum_values |
|
263 | - ): EE_Enum_Text_Field { |
|
264 | - return $this->loader->getNew( |
|
265 | - 'EE_Enum_Text_Field', |
|
266 | - [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
267 | - ); |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * @param string $table_column |
|
273 | - * @param string $nice_name |
|
274 | - * @param bool $nullable |
|
275 | - * @param null $default_value |
|
276 | - * @return EE_Float_Field |
|
277 | - */ |
|
278 | - public function createFloatField( |
|
279 | - string $table_column, |
|
280 | - string $nice_name, |
|
281 | - bool $nullable, |
|
282 | - $default_value = null |
|
283 | - ): EE_Float_Field { |
|
284 | - return $this->loader->getNew( |
|
285 | - 'EE_Float_Field', |
|
286 | - [$table_column, $nice_name, $nullable, $default_value] |
|
287 | - ); |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * @param string $table_column |
|
293 | - * @param string $nice_name |
|
294 | - * @param bool $nullable |
|
295 | - * @param null $default_value |
|
296 | - * @param string $model_name |
|
297 | - * @return EE_Foreign_Key_Int_Field |
|
298 | - */ |
|
299 | - public function createForeignKeyIntField( |
|
300 | - string $table_column, |
|
301 | - string $nice_name, |
|
302 | - bool $nullable, |
|
303 | - $default_value, |
|
304 | - string $model_name |
|
305 | - ): EE_Foreign_Key_Int_Field { |
|
306 | - return $this->loader->getNew( |
|
307 | - 'EE_Foreign_Key_Int_Field', |
|
308 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
309 | - ); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * @param string $table_column |
|
315 | - * @param string $nice_name |
|
316 | - * @param bool $nullable |
|
317 | - * @param null $default_value |
|
318 | - * @param string $model_name |
|
319 | - * @return EE_Foreign_Key_String_Field |
|
320 | - */ |
|
321 | - public function createForeignKeyStringField( |
|
322 | - string $table_column, |
|
323 | - string $nice_name, |
|
324 | - bool $nullable, |
|
325 | - $default_value, |
|
326 | - string $model_name |
|
327 | - ): EE_Foreign_Key_String_Field { |
|
328 | - return $this->loader->getNew( |
|
329 | - 'EE_Foreign_Key_String_Field', |
|
330 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
331 | - ); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $table_column |
|
337 | - * @param string $nice_name |
|
338 | - * @param bool $nullable |
|
339 | - * @param null $default_value |
|
340 | - * @return EE_Full_HTML_Field |
|
341 | - */ |
|
342 | - public function createFullHtmlField( |
|
343 | - string $table_column, |
|
344 | - string $nice_name, |
|
345 | - bool $nullable, |
|
346 | - $default_value = null |
|
347 | - ): EE_Full_HTML_Field { |
|
348 | - return $this->loader->getNew( |
|
349 | - 'EE_Full_HTML_Field', |
|
350 | - [$table_column, $nice_name, $nullable, $default_value] |
|
351 | - ); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * @param string $table_column |
|
357 | - * @param string $nice_name |
|
358 | - * @param bool $nullable |
|
359 | - * @param null $default_value |
|
360 | - * @return EE_Infinite_Integer_Field |
|
361 | - */ |
|
362 | - public function createInfiniteIntegerField( |
|
363 | - string $table_column, |
|
364 | - string $nice_name, |
|
365 | - bool $nullable, |
|
366 | - $default_value = null |
|
367 | - ): EE_Infinite_Integer_Field { |
|
368 | - return $this->loader->getNew( |
|
369 | - 'EE_Infinite_Integer_Field', |
|
370 | - [$table_column, $nice_name, $nullable, $default_value] |
|
371 | - ); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * @param string $table_column |
|
377 | - * @param string $nice_name |
|
378 | - * @param bool $nullable |
|
379 | - * @param integer $default_value |
|
380 | - * @return EE_Integer_Field |
|
381 | - */ |
|
382 | - public function createIntegerField( |
|
383 | - string $table_column, |
|
384 | - string $nice_name, |
|
385 | - bool $nullable = false, |
|
386 | - int $default_value = 0 |
|
387 | - ): EE_Integer_Field { |
|
388 | - return $this->loader->getNew( |
|
389 | - 'EE_Integer_Field', |
|
390 | - [$table_column, $nice_name, $nullable, $default_value] |
|
391 | - ); |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - /** |
|
396 | - * @param string $table_column |
|
397 | - * @param string $nice_name |
|
398 | - * @param bool $nullable |
|
399 | - * @param null $default_value |
|
400 | - * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
401 | - */ |
|
402 | - public function createMaybeSerializedSimpleHtmlField( |
|
403 | - string $table_column, |
|
404 | - string $nice_name, |
|
405 | - bool $nullable, |
|
406 | - $default_value = null |
|
407 | - ): EE_Maybe_Serialized_Simple_HTML_Field { |
|
408 | - return $this->loader->getNew( |
|
409 | - 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
410 | - [$table_column, $nice_name, $nullable, $default_value] |
|
411 | - ); |
|
412 | - } |
|
413 | - |
|
414 | - |
|
415 | - /** |
|
416 | - * @param string $table_column |
|
417 | - * @param string $nice_name |
|
418 | - * @param bool $nullable |
|
419 | - * @param null $default_value |
|
420 | - * @return EE_Maybe_Serialized_Text_Field |
|
421 | - */ |
|
422 | - public function createMaybeSerializedTextField( |
|
423 | - string $table_column, |
|
424 | - string $nice_name, |
|
425 | - bool $nullable, |
|
426 | - $default_value = null |
|
427 | - ): EE_Maybe_Serialized_Text_Field { |
|
428 | - return $this->loader->getNew( |
|
429 | - 'EE_Maybe_Serialized_Text_Field', |
|
430 | - [$table_column, $nice_name, $nullable, $default_value] |
|
431 | - ); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * @param string $table_column |
|
437 | - * @param string $nice_name |
|
438 | - * @param bool $nullable |
|
439 | - * @param null $default_value |
|
440 | - * @return EE_Money_Field |
|
441 | - */ |
|
442 | - public function createMoneyField( |
|
443 | - string $table_column, |
|
444 | - string $nice_name, |
|
445 | - bool $nullable, |
|
446 | - $default_value = null |
|
447 | - ): EE_Money_Field { |
|
448 | - return $this->loader->getNew( |
|
449 | - 'EE_Money_Field', |
|
450 | - [$table_column, $nice_name, $nullable, $default_value] |
|
451 | - ); |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * @param string $table_column |
|
457 | - * @param string $nice_name |
|
458 | - * @param bool $nullable |
|
459 | - * @param string $default_value |
|
460 | - * @return EE_Plain_Text_Field |
|
461 | - */ |
|
462 | - public function createPlainTextField( |
|
463 | - string $table_column, |
|
464 | - string $nice_name, |
|
465 | - bool $nullable = true, |
|
466 | - string $default_value = '' |
|
467 | - ): EE_Plain_Text_Field { |
|
468 | - return $this->loader->getNew( |
|
469 | - 'EE_Plain_Text_Field', |
|
470 | - [$table_column, $nice_name, $nullable, $default_value] |
|
471 | - ); |
|
472 | - } |
|
473 | - |
|
474 | - |
|
475 | - /** |
|
476 | - * @param string $table_column |
|
477 | - * @param string $nice_name |
|
478 | - * @param bool $nullable |
|
479 | - * @param null $default_value |
|
480 | - * @return EE_Post_Content_Field |
|
481 | - */ |
|
482 | - public function createPostContentField( |
|
483 | - string $table_column, |
|
484 | - string $nice_name, |
|
485 | - bool $nullable, |
|
486 | - $default_value = null |
|
487 | - ): EE_Post_Content_Field { |
|
488 | - return $this->loader->getNew( |
|
489 | - 'EE_Post_Content_Field', |
|
490 | - [$table_column, $nice_name, $nullable, $default_value] |
|
491 | - ); |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - /** |
|
496 | - * @param string $table_column |
|
497 | - * @param string $nice_name |
|
498 | - * @return EE_Primary_Key_Int_Field |
|
499 | - */ |
|
500 | - public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field |
|
501 | - { |
|
502 | - return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]); |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - /** |
|
507 | - * @param string $table_column |
|
508 | - * @param string $nice_name |
|
509 | - * @return EE_Primary_Key_String_Field |
|
510 | - */ |
|
511 | - public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field |
|
512 | - { |
|
513 | - return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]); |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * @param string $table_column |
|
519 | - * @param string $nice_name |
|
520 | - * @param bool $nullable |
|
521 | - * @param null $default_value |
|
522 | - * @return EE_Serialized_Text_Field |
|
523 | - */ |
|
524 | - public function createSerializedTextField( |
|
525 | - string $table_column, |
|
526 | - string $nice_name, |
|
527 | - bool $nullable, |
|
528 | - $default_value = null |
|
529 | - ): EE_Serialized_Text_Field { |
|
530 | - return $this->loader->getNew( |
|
531 | - 'EE_Serialized_Text_Field', |
|
532 | - [$table_column, $nice_name, $nullable, $default_value] |
|
533 | - ); |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * @param string $table_column |
|
539 | - * @param string $nice_name |
|
540 | - * @param bool $nullable |
|
541 | - * @param null $default_value |
|
542 | - * @return EE_Simple_HTML_Field |
|
543 | - */ |
|
544 | - public function createSimpleHtmlField( |
|
545 | - string $table_column, |
|
546 | - string $nice_name, |
|
547 | - bool $nullable, |
|
548 | - $default_value = null |
|
549 | - ): EE_Simple_HTML_Field { |
|
550 | - return $this->loader->getNew( |
|
551 | - 'EE_Simple_HTML_Field', |
|
552 | - [$table_column, $nice_name, $nullable, $default_value] |
|
553 | - ); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * @param string $table_column |
|
559 | - * @param string $nice_name |
|
560 | - * @param bool $nullable |
|
561 | - * @param null $default_value |
|
562 | - * @return EE_Slug_Field |
|
563 | - */ |
|
564 | - public function createSlugField( |
|
565 | - string $table_column, |
|
566 | - string $nice_name, |
|
567 | - bool $nullable = false, |
|
568 | - $default_value = null |
|
569 | - ): EE_Slug_Field { |
|
570 | - return $this->loader->getNew( |
|
571 | - 'EE_Slug_Field', |
|
572 | - [$table_column, $nice_name, $nullable, $default_value] |
|
573 | - ); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * @param string $table_column |
|
579 | - * @param string $nice_name |
|
580 | - * @param bool $nullable |
|
581 | - * @param null $default_value |
|
582 | - * @return EE_Trashed_Flag_Field |
|
583 | - */ |
|
584 | - public function createTrashedFlagField( |
|
585 | - string $table_column, |
|
586 | - string $nice_name, |
|
587 | - bool $nullable, |
|
588 | - $default_value = null |
|
589 | - ): EE_Trashed_Flag_Field { |
|
590 | - return $this->loader->getNew( |
|
591 | - 'EE_Trashed_Flag_Field', |
|
592 | - [$table_column, $nice_name, $nullable, $default_value] |
|
593 | - ); |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * @param string $table_column |
|
599 | - * @param string $nice_name |
|
600 | - * @param bool $nullable |
|
601 | - * @param mixed $default_value |
|
602 | - * @param array $values If additional statuses are to be used other than the default WP statuses, |
|
603 | - * then they can be registered via this property. |
|
604 | - * The format of the array should be as follows: |
|
605 | - * [ |
|
606 | - * 'status_reference' => [ |
|
607 | - * 'label' => __('Status Reference Label', 'event_espresso'), |
|
608 | - * // whether status is shown on the frontend of the site |
|
609 | - * 'public' => true, |
|
610 | - * // whether status is excluded from wp searches |
|
611 | - * 'exclude_from_search' => false, |
|
612 | - * // whether status is included in queries |
|
613 | - * for the admin 'all' view in list table views. |
|
614 | - * 'show_in_admin_all_list' => true, |
|
615 | - * // show in the list of statuses with post counts |
|
616 | - * // at the top of the admin list tables (i.e. Status Reference(2) ) |
|
617 | - * 'show_in_admin_status_list' => true, |
|
618 | - * // the text to display on the admin screen |
|
619 | - * // ( or you won't see your status count ) |
|
620 | - * 'label_count' => _n_noop( |
|
621 | - * 'Status Reference <span class="count">(%s)</span>', |
|
622 | - * 'Status References <span class="count">(%s)</span>' |
|
623 | - * ), |
|
624 | - * ] |
|
625 | - * ] |
|
626 | - * @return EE_WP_Post_Status_Field |
|
627 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
628 | - */ |
|
629 | - public function createWpPostStatusField( |
|
630 | - string $table_column, |
|
631 | - string $nice_name, |
|
632 | - bool $nullable, |
|
633 | - $default_value = null, |
|
634 | - array $values = [] |
|
635 | - ): EE_WP_Post_Status_Field { |
|
636 | - return $this->loader->getNew( |
|
637 | - 'EE_WP_Post_Status_Field', |
|
638 | - [$table_column, $nice_name, $nullable, $default_value, $values] |
|
639 | - ); |
|
640 | - } |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * @param string $post_type |
|
645 | - * @return EE_WP_Post_Type_Field |
|
646 | - */ |
|
647 | - public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field |
|
648 | - { |
|
649 | - return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]); |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * @param string $table_column |
|
655 | - * @param string $nice_name |
|
656 | - * @param bool $nullable |
|
657 | - * @return EE_WP_User_Field |
|
658 | - */ |
|
659 | - public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field |
|
660 | - { |
|
661 | - return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]); |
|
662 | - } |
|
49 | + /** |
|
50 | + * @var LoaderInterface $loader |
|
51 | + */ |
|
52 | + private $loader; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * ModelFieldFactory constructor. |
|
57 | + * |
|
58 | + * @param LoaderInterface $loader |
|
59 | + */ |
|
60 | + public function __construct(LoaderInterface $loader) |
|
61 | + { |
|
62 | + $this->loader = $loader; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $table_column |
|
68 | + * @param string $nice_name |
|
69 | + * @param bool $nullable |
|
70 | + * @param null $default_value |
|
71 | + * @return EE_All_Caps_Text_Field |
|
72 | + */ |
|
73 | + public function createAllCapsTextField( |
|
74 | + string $table_column, |
|
75 | + string $nice_name, |
|
76 | + bool $nullable, |
|
77 | + $default_value = null |
|
78 | + ): EE_All_Caps_Text_Field { |
|
79 | + return $this->loader->getNew( |
|
80 | + 'EE_All_Caps_Text_Field', |
|
81 | + [$table_column, $nice_name, $nullable, $default_value] |
|
82 | + ); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param string $table_column |
|
88 | + * @param string $nice_name |
|
89 | + * @param bool $nullable |
|
90 | + * @param null $default_value |
|
91 | + * @param string $model_name |
|
92 | + * @return EE_Any_Foreign_Model_Name_Field |
|
93 | + */ |
|
94 | + public function createAnyForeignModelNameField( |
|
95 | + string $table_column, |
|
96 | + string $nice_name, |
|
97 | + bool $nullable, |
|
98 | + $default_value = null, |
|
99 | + string $model_name = '' |
|
100 | + ): EE_Any_Foreign_Model_Name_Field { |
|
101 | + return $this->loader->getNew( |
|
102 | + 'EE_Any_Foreign_Model_Name_Field', |
|
103 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
104 | + ); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $table_column |
|
110 | + * @param string $nice_name |
|
111 | + * @param bool $nullable |
|
112 | + * @param null $default_value |
|
113 | + * @return EE_Boolean_Field |
|
114 | + */ |
|
115 | + public function createBooleanField( |
|
116 | + string $table_column, |
|
117 | + string $nice_name, |
|
118 | + bool $nullable, |
|
119 | + $default_value = null |
|
120 | + ): EE_Boolean_Field { |
|
121 | + return $this->loader->getNew( |
|
122 | + 'EE_Boolean_Field', |
|
123 | + [$table_column, $nice_name, $nullable, $default_value] |
|
124 | + ); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param string $table_column |
|
130 | + * @param string $nice_name |
|
131 | + * @param bool $nullable |
|
132 | + * @param string $default_value |
|
133 | + * @return EE_Datetime_Field |
|
134 | + */ |
|
135 | + public function createDatetimeField( |
|
136 | + string $table_column, |
|
137 | + string $nice_name, |
|
138 | + bool $nullable = false, |
|
139 | + string $default_value = EE_Datetime_Field::now |
|
140 | + ): EE_Datetime_Field { |
|
141 | + return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * @param string $table_column |
|
147 | + * @param string $nice_name |
|
148 | + * @param bool $nullable |
|
149 | + * @param null $default_value |
|
150 | + * @return EE_DB_Only_Float_Field |
|
151 | + */ |
|
152 | + public function createDbOnlyFloatField( |
|
153 | + string $table_column, |
|
154 | + string $nice_name, |
|
155 | + bool $nullable, |
|
156 | + $default_value = null |
|
157 | + ): EE_DB_Only_Float_Field { |
|
158 | + return $this->loader->getNew( |
|
159 | + 'EE_DB_Only_Float_Field', |
|
160 | + [$table_column, $nice_name, $nullable, $default_value] |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param string $table_column |
|
167 | + * @param string $nice_name |
|
168 | + * @param bool $nullable |
|
169 | + * @param null $default_value |
|
170 | + * @return EE_DB_Only_Int_Field |
|
171 | + */ |
|
172 | + public function createDbOnlyIntField( |
|
173 | + string $table_column, |
|
174 | + string $nice_name, |
|
175 | + bool $nullable, |
|
176 | + $default_value = null |
|
177 | + ): EE_DB_Only_Int_Field { |
|
178 | + return $this->loader->getNew( |
|
179 | + 'EE_DB_Only_Int_Field', |
|
180 | + [$table_column, $nice_name, $nullable, $default_value] |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $table_column |
|
187 | + * @param string $nice_name |
|
188 | + * @param bool $nullable |
|
189 | + * @param null $default_value |
|
190 | + * @return EE_DB_Only_Text_Field |
|
191 | + */ |
|
192 | + public function createDbOnlyTextField( |
|
193 | + string $table_column, |
|
194 | + string $nice_name, |
|
195 | + bool $nullable, |
|
196 | + $default_value = null |
|
197 | + ): EE_DB_Only_Text_Field { |
|
198 | + return $this->loader->getNew( |
|
199 | + 'EE_DB_Only_Text_Field', |
|
200 | + [$table_column, $nice_name, $nullable, $default_value] |
|
201 | + ); |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * @param string $table_column |
|
207 | + * @param string $nice_name |
|
208 | + * @param bool $nullable |
|
209 | + * @param string|null $default_value |
|
210 | + * @return EE_Email_Field |
|
211 | + */ |
|
212 | + public function createEmailField( |
|
213 | + string $table_column, |
|
214 | + string $nice_name, |
|
215 | + bool $nullable = true, |
|
216 | + string $default_value = '' |
|
217 | + ): EE_Email_Field { |
|
218 | + return $this->loader->getNew( |
|
219 | + 'EE_Email_Field', |
|
220 | + [$table_column, $nice_name, $nullable, $default_value] |
|
221 | + ); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * @param string $table_column |
|
227 | + * @param string $nice_name |
|
228 | + * @param bool $nullable |
|
229 | + * @param null $default_value |
|
230 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
231 | + * values are how they should be displayed |
|
232 | + * @return EE_Enum_Integer_Field |
|
233 | + */ |
|
234 | + public function createEnumIntegerField( |
|
235 | + string $table_column, |
|
236 | + string $nice_name, |
|
237 | + bool $nullable, |
|
238 | + $default_value = null, |
|
239 | + array $allowed_enum_values = [] |
|
240 | + ): EE_Enum_Integer_Field { |
|
241 | + return $this->loader->getNew( |
|
242 | + 'EE_Enum_Integer_Field', |
|
243 | + [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
244 | + ); |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @param string $table_column |
|
250 | + * @param string $nice_name |
|
251 | + * @param bool $nullable |
|
252 | + * @param null $default_value |
|
253 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
254 | + * values are how they should be displayed |
|
255 | + * @return EE_Enum_Text_Field |
|
256 | + */ |
|
257 | + public function createEnumTextField( |
|
258 | + string $table_column, |
|
259 | + string $nice_name, |
|
260 | + bool $nullable, |
|
261 | + $default_value, |
|
262 | + array $allowed_enum_values |
|
263 | + ): EE_Enum_Text_Field { |
|
264 | + return $this->loader->getNew( |
|
265 | + 'EE_Enum_Text_Field', |
|
266 | + [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
267 | + ); |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * @param string $table_column |
|
273 | + * @param string $nice_name |
|
274 | + * @param bool $nullable |
|
275 | + * @param null $default_value |
|
276 | + * @return EE_Float_Field |
|
277 | + */ |
|
278 | + public function createFloatField( |
|
279 | + string $table_column, |
|
280 | + string $nice_name, |
|
281 | + bool $nullable, |
|
282 | + $default_value = null |
|
283 | + ): EE_Float_Field { |
|
284 | + return $this->loader->getNew( |
|
285 | + 'EE_Float_Field', |
|
286 | + [$table_column, $nice_name, $nullable, $default_value] |
|
287 | + ); |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * @param string $table_column |
|
293 | + * @param string $nice_name |
|
294 | + * @param bool $nullable |
|
295 | + * @param null $default_value |
|
296 | + * @param string $model_name |
|
297 | + * @return EE_Foreign_Key_Int_Field |
|
298 | + */ |
|
299 | + public function createForeignKeyIntField( |
|
300 | + string $table_column, |
|
301 | + string $nice_name, |
|
302 | + bool $nullable, |
|
303 | + $default_value, |
|
304 | + string $model_name |
|
305 | + ): EE_Foreign_Key_Int_Field { |
|
306 | + return $this->loader->getNew( |
|
307 | + 'EE_Foreign_Key_Int_Field', |
|
308 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
309 | + ); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * @param string $table_column |
|
315 | + * @param string $nice_name |
|
316 | + * @param bool $nullable |
|
317 | + * @param null $default_value |
|
318 | + * @param string $model_name |
|
319 | + * @return EE_Foreign_Key_String_Field |
|
320 | + */ |
|
321 | + public function createForeignKeyStringField( |
|
322 | + string $table_column, |
|
323 | + string $nice_name, |
|
324 | + bool $nullable, |
|
325 | + $default_value, |
|
326 | + string $model_name |
|
327 | + ): EE_Foreign_Key_String_Field { |
|
328 | + return $this->loader->getNew( |
|
329 | + 'EE_Foreign_Key_String_Field', |
|
330 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
331 | + ); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param string $table_column |
|
337 | + * @param string $nice_name |
|
338 | + * @param bool $nullable |
|
339 | + * @param null $default_value |
|
340 | + * @return EE_Full_HTML_Field |
|
341 | + */ |
|
342 | + public function createFullHtmlField( |
|
343 | + string $table_column, |
|
344 | + string $nice_name, |
|
345 | + bool $nullable, |
|
346 | + $default_value = null |
|
347 | + ): EE_Full_HTML_Field { |
|
348 | + return $this->loader->getNew( |
|
349 | + 'EE_Full_HTML_Field', |
|
350 | + [$table_column, $nice_name, $nullable, $default_value] |
|
351 | + ); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * @param string $table_column |
|
357 | + * @param string $nice_name |
|
358 | + * @param bool $nullable |
|
359 | + * @param null $default_value |
|
360 | + * @return EE_Infinite_Integer_Field |
|
361 | + */ |
|
362 | + public function createInfiniteIntegerField( |
|
363 | + string $table_column, |
|
364 | + string $nice_name, |
|
365 | + bool $nullable, |
|
366 | + $default_value = null |
|
367 | + ): EE_Infinite_Integer_Field { |
|
368 | + return $this->loader->getNew( |
|
369 | + 'EE_Infinite_Integer_Field', |
|
370 | + [$table_column, $nice_name, $nullable, $default_value] |
|
371 | + ); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * @param string $table_column |
|
377 | + * @param string $nice_name |
|
378 | + * @param bool $nullable |
|
379 | + * @param integer $default_value |
|
380 | + * @return EE_Integer_Field |
|
381 | + */ |
|
382 | + public function createIntegerField( |
|
383 | + string $table_column, |
|
384 | + string $nice_name, |
|
385 | + bool $nullable = false, |
|
386 | + int $default_value = 0 |
|
387 | + ): EE_Integer_Field { |
|
388 | + return $this->loader->getNew( |
|
389 | + 'EE_Integer_Field', |
|
390 | + [$table_column, $nice_name, $nullable, $default_value] |
|
391 | + ); |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + /** |
|
396 | + * @param string $table_column |
|
397 | + * @param string $nice_name |
|
398 | + * @param bool $nullable |
|
399 | + * @param null $default_value |
|
400 | + * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
401 | + */ |
|
402 | + public function createMaybeSerializedSimpleHtmlField( |
|
403 | + string $table_column, |
|
404 | + string $nice_name, |
|
405 | + bool $nullable, |
|
406 | + $default_value = null |
|
407 | + ): EE_Maybe_Serialized_Simple_HTML_Field { |
|
408 | + return $this->loader->getNew( |
|
409 | + 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
410 | + [$table_column, $nice_name, $nullable, $default_value] |
|
411 | + ); |
|
412 | + } |
|
413 | + |
|
414 | + |
|
415 | + /** |
|
416 | + * @param string $table_column |
|
417 | + * @param string $nice_name |
|
418 | + * @param bool $nullable |
|
419 | + * @param null $default_value |
|
420 | + * @return EE_Maybe_Serialized_Text_Field |
|
421 | + */ |
|
422 | + public function createMaybeSerializedTextField( |
|
423 | + string $table_column, |
|
424 | + string $nice_name, |
|
425 | + bool $nullable, |
|
426 | + $default_value = null |
|
427 | + ): EE_Maybe_Serialized_Text_Field { |
|
428 | + return $this->loader->getNew( |
|
429 | + 'EE_Maybe_Serialized_Text_Field', |
|
430 | + [$table_column, $nice_name, $nullable, $default_value] |
|
431 | + ); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * @param string $table_column |
|
437 | + * @param string $nice_name |
|
438 | + * @param bool $nullable |
|
439 | + * @param null $default_value |
|
440 | + * @return EE_Money_Field |
|
441 | + */ |
|
442 | + public function createMoneyField( |
|
443 | + string $table_column, |
|
444 | + string $nice_name, |
|
445 | + bool $nullable, |
|
446 | + $default_value = null |
|
447 | + ): EE_Money_Field { |
|
448 | + return $this->loader->getNew( |
|
449 | + 'EE_Money_Field', |
|
450 | + [$table_column, $nice_name, $nullable, $default_value] |
|
451 | + ); |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * @param string $table_column |
|
457 | + * @param string $nice_name |
|
458 | + * @param bool $nullable |
|
459 | + * @param string $default_value |
|
460 | + * @return EE_Plain_Text_Field |
|
461 | + */ |
|
462 | + public function createPlainTextField( |
|
463 | + string $table_column, |
|
464 | + string $nice_name, |
|
465 | + bool $nullable = true, |
|
466 | + string $default_value = '' |
|
467 | + ): EE_Plain_Text_Field { |
|
468 | + return $this->loader->getNew( |
|
469 | + 'EE_Plain_Text_Field', |
|
470 | + [$table_column, $nice_name, $nullable, $default_value] |
|
471 | + ); |
|
472 | + } |
|
473 | + |
|
474 | + |
|
475 | + /** |
|
476 | + * @param string $table_column |
|
477 | + * @param string $nice_name |
|
478 | + * @param bool $nullable |
|
479 | + * @param null $default_value |
|
480 | + * @return EE_Post_Content_Field |
|
481 | + */ |
|
482 | + public function createPostContentField( |
|
483 | + string $table_column, |
|
484 | + string $nice_name, |
|
485 | + bool $nullable, |
|
486 | + $default_value = null |
|
487 | + ): EE_Post_Content_Field { |
|
488 | + return $this->loader->getNew( |
|
489 | + 'EE_Post_Content_Field', |
|
490 | + [$table_column, $nice_name, $nullable, $default_value] |
|
491 | + ); |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + /** |
|
496 | + * @param string $table_column |
|
497 | + * @param string $nice_name |
|
498 | + * @return EE_Primary_Key_Int_Field |
|
499 | + */ |
|
500 | + public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field |
|
501 | + { |
|
502 | + return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]); |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + /** |
|
507 | + * @param string $table_column |
|
508 | + * @param string $nice_name |
|
509 | + * @return EE_Primary_Key_String_Field |
|
510 | + */ |
|
511 | + public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field |
|
512 | + { |
|
513 | + return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]); |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * @param string $table_column |
|
519 | + * @param string $nice_name |
|
520 | + * @param bool $nullable |
|
521 | + * @param null $default_value |
|
522 | + * @return EE_Serialized_Text_Field |
|
523 | + */ |
|
524 | + public function createSerializedTextField( |
|
525 | + string $table_column, |
|
526 | + string $nice_name, |
|
527 | + bool $nullable, |
|
528 | + $default_value = null |
|
529 | + ): EE_Serialized_Text_Field { |
|
530 | + return $this->loader->getNew( |
|
531 | + 'EE_Serialized_Text_Field', |
|
532 | + [$table_column, $nice_name, $nullable, $default_value] |
|
533 | + ); |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * @param string $table_column |
|
539 | + * @param string $nice_name |
|
540 | + * @param bool $nullable |
|
541 | + * @param null $default_value |
|
542 | + * @return EE_Simple_HTML_Field |
|
543 | + */ |
|
544 | + public function createSimpleHtmlField( |
|
545 | + string $table_column, |
|
546 | + string $nice_name, |
|
547 | + bool $nullable, |
|
548 | + $default_value = null |
|
549 | + ): EE_Simple_HTML_Field { |
|
550 | + return $this->loader->getNew( |
|
551 | + 'EE_Simple_HTML_Field', |
|
552 | + [$table_column, $nice_name, $nullable, $default_value] |
|
553 | + ); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * @param string $table_column |
|
559 | + * @param string $nice_name |
|
560 | + * @param bool $nullable |
|
561 | + * @param null $default_value |
|
562 | + * @return EE_Slug_Field |
|
563 | + */ |
|
564 | + public function createSlugField( |
|
565 | + string $table_column, |
|
566 | + string $nice_name, |
|
567 | + bool $nullable = false, |
|
568 | + $default_value = null |
|
569 | + ): EE_Slug_Field { |
|
570 | + return $this->loader->getNew( |
|
571 | + 'EE_Slug_Field', |
|
572 | + [$table_column, $nice_name, $nullable, $default_value] |
|
573 | + ); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * @param string $table_column |
|
579 | + * @param string $nice_name |
|
580 | + * @param bool $nullable |
|
581 | + * @param null $default_value |
|
582 | + * @return EE_Trashed_Flag_Field |
|
583 | + */ |
|
584 | + public function createTrashedFlagField( |
|
585 | + string $table_column, |
|
586 | + string $nice_name, |
|
587 | + bool $nullable, |
|
588 | + $default_value = null |
|
589 | + ): EE_Trashed_Flag_Field { |
|
590 | + return $this->loader->getNew( |
|
591 | + 'EE_Trashed_Flag_Field', |
|
592 | + [$table_column, $nice_name, $nullable, $default_value] |
|
593 | + ); |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * @param string $table_column |
|
599 | + * @param string $nice_name |
|
600 | + * @param bool $nullable |
|
601 | + * @param mixed $default_value |
|
602 | + * @param array $values If additional statuses are to be used other than the default WP statuses, |
|
603 | + * then they can be registered via this property. |
|
604 | + * The format of the array should be as follows: |
|
605 | + * [ |
|
606 | + * 'status_reference' => [ |
|
607 | + * 'label' => __('Status Reference Label', 'event_espresso'), |
|
608 | + * // whether status is shown on the frontend of the site |
|
609 | + * 'public' => true, |
|
610 | + * // whether status is excluded from wp searches |
|
611 | + * 'exclude_from_search' => false, |
|
612 | + * // whether status is included in queries |
|
613 | + * for the admin 'all' view in list table views. |
|
614 | + * 'show_in_admin_all_list' => true, |
|
615 | + * // show in the list of statuses with post counts |
|
616 | + * // at the top of the admin list tables (i.e. Status Reference(2) ) |
|
617 | + * 'show_in_admin_status_list' => true, |
|
618 | + * // the text to display on the admin screen |
|
619 | + * // ( or you won't see your status count ) |
|
620 | + * 'label_count' => _n_noop( |
|
621 | + * 'Status Reference <span class="count">(%s)</span>', |
|
622 | + * 'Status References <span class="count">(%s)</span>' |
|
623 | + * ), |
|
624 | + * ] |
|
625 | + * ] |
|
626 | + * @return EE_WP_Post_Status_Field |
|
627 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
628 | + */ |
|
629 | + public function createWpPostStatusField( |
|
630 | + string $table_column, |
|
631 | + string $nice_name, |
|
632 | + bool $nullable, |
|
633 | + $default_value = null, |
|
634 | + array $values = [] |
|
635 | + ): EE_WP_Post_Status_Field { |
|
636 | + return $this->loader->getNew( |
|
637 | + 'EE_WP_Post_Status_Field', |
|
638 | + [$table_column, $nice_name, $nullable, $default_value, $values] |
|
639 | + ); |
|
640 | + } |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * @param string $post_type |
|
645 | + * @return EE_WP_Post_Type_Field |
|
646 | + */ |
|
647 | + public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field |
|
648 | + { |
|
649 | + return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]); |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * @param string $table_column |
|
655 | + * @param string $nice_name |
|
656 | + * @param bool $nullable |
|
657 | + * @return EE_WP_User_Field |
|
658 | + */ |
|
659 | + public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field |
|
660 | + { |
|
661 | + return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]); |
|
662 | + } |
|
663 | 663 | } |
@@ -16,113 +16,113 @@ |
||
16 | 16 | class RegFormAttendeeFactory |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var CommandBusInterface |
|
21 | - */ |
|
22 | - public $command_bus; |
|
19 | + /** |
|
20 | + * @var CommandBusInterface |
|
21 | + */ |
|
22 | + public $command_bus; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var RegistrantData |
|
26 | - */ |
|
27 | - private $registrant_data; |
|
24 | + /** |
|
25 | + * @var RegistrantData |
|
26 | + */ |
|
27 | + private $registrant_data; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * RegFormAttendeeFactory constructor. |
|
32 | - * |
|
33 | - * @param CommandBusInterface $command_bus |
|
34 | - * @param RegistrantData $registrant_data |
|
35 | - */ |
|
36 | - public function __construct(CommandBusInterface $command_bus, RegistrantData $registrant_data) |
|
37 | - { |
|
38 | - $this->command_bus = $command_bus; |
|
39 | - $this->registrant_data = $registrant_data; |
|
40 | - } |
|
30 | + /** |
|
31 | + * RegFormAttendeeFactory constructor. |
|
32 | + * |
|
33 | + * @param CommandBusInterface $command_bus |
|
34 | + * @param RegistrantData $registrant_data |
|
35 | + */ |
|
36 | + public function __construct(CommandBusInterface $command_bus, RegistrantData $registrant_data) |
|
37 | + { |
|
38 | + $this->command_bus = $command_bus; |
|
39 | + $this->registrant_data = $registrant_data; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param EE_Registration $registration |
|
45 | - * @param string $reg_url_link |
|
46 | - * @return bool |
|
47 | - * @throws EE_Error |
|
48 | - * @throws ReflectionException |
|
49 | - */ |
|
50 | - public function create(EE_Registration $registration, string $reg_url_link): bool |
|
51 | - { |
|
52 | - // this registration does not require additional attendee information ? |
|
53 | - if ( |
|
54 | - $this->registrant_data->copyPrimary() |
|
55 | - && $this->registrant_data->attendeeCount() > 1 |
|
56 | - && $this->registrant_data->primaryRegistrantIsValid() |
|
57 | - ) { |
|
58 | - // just copy the primary registrant |
|
59 | - $attendee = $this->registrant_data->primaryRegistrant(); |
|
60 | - } else { |
|
61 | - // ensure critical details are set for additional attendees |
|
62 | - // raw form data was already set during call to processRegFormData() |
|
63 | - $this->registrant_data->ensureCriticalRegistrantDataIsSet($reg_url_link); |
|
64 | - // execute create attendee command (which may return an existing attendee) |
|
65 | - $attendee = $this->command_bus->execute( |
|
66 | - new CreateAttendeeCommand( |
|
67 | - $this->registrant_data->getRegistrantData($reg_url_link), |
|
68 | - $registration |
|
69 | - ) |
|
70 | - ); |
|
71 | - // who's #1 ? |
|
72 | - if ($this->registrant_data->currentRegistrantIsPrimary()) { |
|
73 | - $this->registrant_data->setPrimaryRegistrant($attendee); |
|
74 | - } |
|
75 | - } |
|
76 | - // add relation to registration, set attendee ID, and cache attendee |
|
77 | - $this->associateAttendeeWithRegistration($registration, $attendee); |
|
78 | - return $this->isValidAttendee($registration, $reg_url_link); |
|
79 | - } |
|
43 | + /** |
|
44 | + * @param EE_Registration $registration |
|
45 | + * @param string $reg_url_link |
|
46 | + * @return bool |
|
47 | + * @throws EE_Error |
|
48 | + * @throws ReflectionException |
|
49 | + */ |
|
50 | + public function create(EE_Registration $registration, string $reg_url_link): bool |
|
51 | + { |
|
52 | + // this registration does not require additional attendee information ? |
|
53 | + if ( |
|
54 | + $this->registrant_data->copyPrimary() |
|
55 | + && $this->registrant_data->attendeeCount() > 1 |
|
56 | + && $this->registrant_data->primaryRegistrantIsValid() |
|
57 | + ) { |
|
58 | + // just copy the primary registrant |
|
59 | + $attendee = $this->registrant_data->primaryRegistrant(); |
|
60 | + } else { |
|
61 | + // ensure critical details are set for additional attendees |
|
62 | + // raw form data was already set during call to processRegFormData() |
|
63 | + $this->registrant_data->ensureCriticalRegistrantDataIsSet($reg_url_link); |
|
64 | + // execute create attendee command (which may return an existing attendee) |
|
65 | + $attendee = $this->command_bus->execute( |
|
66 | + new CreateAttendeeCommand( |
|
67 | + $this->registrant_data->getRegistrantData($reg_url_link), |
|
68 | + $registration |
|
69 | + ) |
|
70 | + ); |
|
71 | + // who's #1 ? |
|
72 | + if ($this->registrant_data->currentRegistrantIsPrimary()) { |
|
73 | + $this->registrant_data->setPrimaryRegistrant($attendee); |
|
74 | + } |
|
75 | + } |
|
76 | + // add relation to registration, set attendee ID, and cache attendee |
|
77 | + $this->associateAttendeeWithRegistration($registration, $attendee); |
|
78 | + return $this->isValidAttendee($registration, $reg_url_link); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param EE_Registration $registration |
|
84 | - * @param string $reg_url_link |
|
85 | - * @return bool |
|
86 | - * @throws EE_Error |
|
87 | - */ |
|
88 | - private function isValidAttendee(EE_Registration $registration, string $reg_url_link): bool |
|
89 | - { |
|
90 | - if ($registration->attendee() instanceof EE_Attendee) { |
|
91 | - return true; |
|
92 | - } |
|
93 | - EE_Error::add_error( |
|
94 | - sprintf( |
|
95 | - esc_html_x( |
|
96 | - 'Registration %s has an invalid or missing Attendee object.', |
|
97 | - 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - $reg_url_link |
|
101 | - ), |
|
102 | - __FILE__, |
|
103 | - __FUNCTION__, |
|
104 | - __LINE__ |
|
105 | - ); |
|
106 | - return false; |
|
107 | - } |
|
82 | + /** |
|
83 | + * @param EE_Registration $registration |
|
84 | + * @param string $reg_url_link |
|
85 | + * @return bool |
|
86 | + * @throws EE_Error |
|
87 | + */ |
|
88 | + private function isValidAttendee(EE_Registration $registration, string $reg_url_link): bool |
|
89 | + { |
|
90 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
91 | + return true; |
|
92 | + } |
|
93 | + EE_Error::add_error( |
|
94 | + sprintf( |
|
95 | + esc_html_x( |
|
96 | + 'Registration %s has an invalid or missing Attendee object.', |
|
97 | + 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + $reg_url_link |
|
101 | + ), |
|
102 | + __FILE__, |
|
103 | + __FUNCTION__, |
|
104 | + __LINE__ |
|
105 | + ); |
|
106 | + return false; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * @param EE_Registration $registration |
|
112 | - * @param EE_Attendee $attendee |
|
113 | - * @return void |
|
114 | - * @throws EE_Error |
|
115 | - * @throws InvalidArgumentException |
|
116 | - * @throws ReflectionException |
|
117 | - * @throws RuntimeException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - */ |
|
121 | - private function associateAttendeeWithRegistration(EE_Registration $registration, EE_Attendee $attendee) |
|
122 | - { |
|
123 | - // add relation to attendee |
|
124 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
125 | - $registration->set_attendee_id($attendee->ID()); |
|
126 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
127 | - } |
|
110 | + /** |
|
111 | + * @param EE_Registration $registration |
|
112 | + * @param EE_Attendee $attendee |
|
113 | + * @return void |
|
114 | + * @throws EE_Error |
|
115 | + * @throws InvalidArgumentException |
|
116 | + * @throws ReflectionException |
|
117 | + * @throws RuntimeException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + */ |
|
121 | + private function associateAttendeeWithRegistration(EE_Registration $registration, EE_Attendee $attendee) |
|
122 | + { |
|
123 | + // add relation to attendee |
|
124 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
125 | + $registration->set_attendee_id($attendee->ID()); |
|
126 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
127 | + } |
|
128 | 128 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $registration, |
57 | 57 | $question->system_ID() |
58 | 58 | ); |
59 | - $answer = $answer_value === null |
|
59 | + $answer = $answer_value === null |
|
60 | 60 | ? $this->answer_model->get_one( |
61 | 61 | [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
62 | 62 | ) |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | } |
76 | 76 | // verify instance |
77 | 77 | if ($answer instanceof EE_Answer) { |
78 | - if (! empty($answer_value)) { |
|
78 | + if ( ! empty($answer_value)) { |
|
79 | 79 | $answer->set('ANS_value', $answer_value); |
80 | 80 | } |
81 | 81 | $answer->cache('Question', $question); |
82 | 82 | // remember system ID had a bug where sometimes it could be null |
83 | 83 | $answer_cache_id = $question->is_system_question() |
84 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
85 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
84 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
85 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
86 | 86 | $registration->cache('Answer', $answer, $answer_cache_id); |
87 | 87 | } |
88 | 88 | return $this->generateQuestionInput($registration, $question, $answer); |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | EE_Question $question, |
106 | 106 | $answer |
107 | 107 | ): EE_Form_Input_Base { |
108 | - $identifier = $question->is_system_question() |
|
108 | + $identifier = $question->is_system_question() |
|
109 | 109 | ? $question->system_ID() |
110 | 110 | : $question->ID(); |
111 | 111 | $callback = $this->addRequiredQuestion; |
112 | 112 | $callback($identifier, $question->required()); |
113 | - $input_constructor_args = [ |
|
114 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
115 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
116 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
117 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
113 | + $input_constructor_args = [ |
|
114 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
115 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
116 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
117 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
118 | 118 | 'html_label_class' => 'ee-reg-qstn', |
119 | 119 | ]; |
120 | 120 | $input_constructor_args['html_label_id'] .= '-lbl'; |
121 | 121 | if ($answer instanceof EE_Answer && $answer->ID()) { |
122 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
123 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
124 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
122 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
123 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
124 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
125 | 125 | } |
126 | 126 | return $question->generate_form_input( |
127 | 127 | $registration, |
@@ -16,118 +16,118 @@ |
||
16 | 16 | class RegFormQuestionFactory |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var callable |
|
21 | - */ |
|
22 | - protected $addRequiredQuestion; |
|
19 | + /** |
|
20 | + * @var callable |
|
21 | + */ |
|
22 | + protected $addRequiredQuestion; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var EEM_Answer |
|
26 | - */ |
|
27 | - public $answer_model; |
|
24 | + /** |
|
25 | + * @var EEM_Answer |
|
26 | + */ |
|
27 | + public $answer_model; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param callable $addRequiredQuestion |
|
32 | - * @param EEM_Answer $answer_model |
|
33 | - */ |
|
34 | - public function __construct(callable $addRequiredQuestion, EEM_Answer $answer_model) |
|
35 | - { |
|
36 | - $this->addRequiredQuestion = $addRequiredQuestion; |
|
37 | - $this->answer_model = $answer_model; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param callable $addRequiredQuestion |
|
32 | + * @param EEM_Answer $answer_model |
|
33 | + */ |
|
34 | + public function __construct(callable $addRequiredQuestion, EEM_Answer $answer_model) |
|
35 | + { |
|
36 | + $this->addRequiredQuestion = $addRequiredQuestion; |
|
37 | + $this->answer_model = $answer_model; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param EE_Registration $registration |
|
43 | - * @param EE_Question $question |
|
44 | - * @return EE_Form_Input_Base |
|
45 | - * @throws EE_Error |
|
46 | - * @throws InvalidArgumentException |
|
47 | - * @throws InvalidDataTypeException |
|
48 | - * @throws InvalidInterfaceException |
|
49 | - * @throws ReflectionException |
|
50 | - */ |
|
51 | - public function create( |
|
52 | - EE_Registration $registration, |
|
53 | - EE_Question $question |
|
54 | - ): EE_Form_Input_Base { |
|
55 | - // if this question was for an attendee detail, then check for that answer |
|
56 | - $answer_value = $this->answer_model->get_attendee_property_answer_value( |
|
57 | - $registration, |
|
58 | - $question->system_ID() |
|
59 | - ); |
|
60 | - $answer = $answer_value === null |
|
61 | - ? $this->answer_model->get_one( |
|
62 | - [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
63 | - ) |
|
64 | - : null; |
|
65 | - // if NOT returning to edit an existing registration |
|
66 | - // OR if this question is for an attendee property |
|
67 | - // OR we still don't have an EE_Answer object |
|
68 | - if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
69 | - // create an EE_Answer object for storing everything in |
|
70 | - $answer = EE_Answer::new_instance( |
|
71 | - [ |
|
72 | - 'QST_ID' => $question->ID(), |
|
73 | - 'REG_ID' => $registration->ID(), |
|
74 | - ] |
|
75 | - ); |
|
76 | - } |
|
77 | - // verify instance |
|
78 | - if ($answer instanceof EE_Answer) { |
|
79 | - if (! empty($answer_value)) { |
|
80 | - $answer->set('ANS_value', $answer_value); |
|
81 | - } |
|
82 | - $answer->cache('Question', $question); |
|
83 | - // remember system ID had a bug where sometimes it could be null |
|
84 | - $answer_cache_id = $question->is_system_question() |
|
85 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
86 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
87 | - $registration->cache('Answer', $answer, $answer_cache_id); |
|
88 | - } |
|
89 | - return $this->generateQuestionInput($registration, $question, $answer); |
|
90 | - } |
|
41 | + /** |
|
42 | + * @param EE_Registration $registration |
|
43 | + * @param EE_Question $question |
|
44 | + * @return EE_Form_Input_Base |
|
45 | + * @throws EE_Error |
|
46 | + * @throws InvalidArgumentException |
|
47 | + * @throws InvalidDataTypeException |
|
48 | + * @throws InvalidInterfaceException |
|
49 | + * @throws ReflectionException |
|
50 | + */ |
|
51 | + public function create( |
|
52 | + EE_Registration $registration, |
|
53 | + EE_Question $question |
|
54 | + ): EE_Form_Input_Base { |
|
55 | + // if this question was for an attendee detail, then check for that answer |
|
56 | + $answer_value = $this->answer_model->get_attendee_property_answer_value( |
|
57 | + $registration, |
|
58 | + $question->system_ID() |
|
59 | + ); |
|
60 | + $answer = $answer_value === null |
|
61 | + ? $this->answer_model->get_one( |
|
62 | + [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
63 | + ) |
|
64 | + : null; |
|
65 | + // if NOT returning to edit an existing registration |
|
66 | + // OR if this question is for an attendee property |
|
67 | + // OR we still don't have an EE_Answer object |
|
68 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
69 | + // create an EE_Answer object for storing everything in |
|
70 | + $answer = EE_Answer::new_instance( |
|
71 | + [ |
|
72 | + 'QST_ID' => $question->ID(), |
|
73 | + 'REG_ID' => $registration->ID(), |
|
74 | + ] |
|
75 | + ); |
|
76 | + } |
|
77 | + // verify instance |
|
78 | + if ($answer instanceof EE_Answer) { |
|
79 | + if (! empty($answer_value)) { |
|
80 | + $answer->set('ANS_value', $answer_value); |
|
81 | + } |
|
82 | + $answer->cache('Question', $question); |
|
83 | + // remember system ID had a bug where sometimes it could be null |
|
84 | + $answer_cache_id = $question->is_system_question() |
|
85 | + ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
86 | + : $question->ID() . '-' . $registration->reg_url_link(); |
|
87 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
88 | + } |
|
89 | + return $this->generateQuestionInput($registration, $question, $answer); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @param EE_Registration $registration |
|
95 | - * @param EE_Question $question |
|
96 | - * @param $answer |
|
97 | - * @return EE_Form_Input_Base |
|
98 | - * @throws EE_Error |
|
99 | - * @throws InvalidArgumentException |
|
100 | - * @throws ReflectionException |
|
101 | - * @throws InvalidDataTypeException |
|
102 | - * @throws InvalidInterfaceException |
|
103 | - */ |
|
104 | - private function generateQuestionInput( |
|
105 | - EE_Registration $registration, |
|
106 | - EE_Question $question, |
|
107 | - $answer |
|
108 | - ): EE_Form_Input_Base { |
|
109 | - $identifier = $question->is_system_question() |
|
110 | - ? $question->system_ID() |
|
111 | - : $question->ID(); |
|
112 | - $callback = $this->addRequiredQuestion; |
|
113 | - $callback($identifier, $question->required()); |
|
114 | - $input_constructor_args = [ |
|
115 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
116 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
117 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
118 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
119 | - 'html_label_class' => 'ee-reg-qstn', |
|
120 | - ]; |
|
121 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
122 | - if ($answer instanceof EE_Answer && $answer->ID()) { |
|
123 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
124 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
125 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
126 | - } |
|
127 | - return $question->generate_form_input( |
|
128 | - $registration, |
|
129 | - $answer, |
|
130 | - $input_constructor_args |
|
131 | - ); |
|
132 | - } |
|
93 | + /** |
|
94 | + * @param EE_Registration $registration |
|
95 | + * @param EE_Question $question |
|
96 | + * @param $answer |
|
97 | + * @return EE_Form_Input_Base |
|
98 | + * @throws EE_Error |
|
99 | + * @throws InvalidArgumentException |
|
100 | + * @throws ReflectionException |
|
101 | + * @throws InvalidDataTypeException |
|
102 | + * @throws InvalidInterfaceException |
|
103 | + */ |
|
104 | + private function generateQuestionInput( |
|
105 | + EE_Registration $registration, |
|
106 | + EE_Question $question, |
|
107 | + $answer |
|
108 | + ): EE_Form_Input_Base { |
|
109 | + $identifier = $question->is_system_question() |
|
110 | + ? $question->system_ID() |
|
111 | + : $question->ID(); |
|
112 | + $callback = $this->addRequiredQuestion; |
|
113 | + $callback($identifier, $question->required()); |
|
114 | + $input_constructor_args = [ |
|
115 | + 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
116 | + 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
117 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
118 | + 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
119 | + 'html_label_class' => 'ee-reg-qstn', |
|
120 | + ]; |
|
121 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
122 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
123 | + $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
124 | + $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
125 | + $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
126 | + } |
|
127 | + return $question->generate_form_input( |
|
128 | + $registration, |
|
129 | + $answer, |
|
130 | + $input_constructor_args |
|
131 | + ); |
|
132 | + } |
|
133 | 133 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $input_value |
68 | 68 | ): bool { |
69 | 69 | // check for critical inputs |
70 | - if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
70 | + if ( ! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $form_input, |
76 | 76 | $input_value |
77 | 77 | ); |
78 | - if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
78 | + if ( ! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
79 | 79 | EE_Error::add_error( |
80 | 80 | sprintf( |
81 | 81 | esc_html_x( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
138 | 138 | */ |
139 | 139 | $answer_cache_id = $this->checkout_reg_url_link |
140 | - ? $form_input . '-' . $reg_url_link |
|
140 | + ? $form_input.'-'.$reg_url_link |
|
141 | 141 | : $form_input; |
142 | 142 | $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
143 | 143 | $answer_is_obj = $registrant_answer instanceof EE_Answer; |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | break; |
157 | 157 | |
158 | 158 | default: |
159 | - $ATT_input = 'ATT_' . $form_input; |
|
159 | + $ATT_input = 'ATT_'.$form_input; |
|
160 | 160 | $attendee_property = $this->attendee_model->has_field($ATT_input); |
161 | 161 | $form_input = $attendee_property |
162 | - ? 'ATT_' . $form_input |
|
162 | + ? 'ATT_'.$form_input |
|
163 | 163 | : $form_input; |
164 | 164 | } |
165 | 165 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | ): bool { |
202 | 202 | if (empty($input_value)) { |
203 | 203 | // if the form input isn't marked as being required, then just return |
204 | - if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) { |
|
204 | + if ( ! isset($this->required_questions[$form_input]) || ! $this->required_questions[$form_input]) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 | switch ($form_input) { |
@@ -14,223 +14,223 @@ |
||
14 | 14 | class RegFormInputHandler |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var EEM_Attendee |
|
19 | - */ |
|
20 | - private $attendee_model; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - private $checkout_reg_url_link; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var RegistrantData |
|
29 | - */ |
|
30 | - private $registrant_data; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - private $required_questions; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * RegFormHandler constructor. |
|
40 | - */ |
|
41 | - public function __construct( |
|
42 | - string $checkout_reg_url_link, |
|
43 | - array $required_questions, |
|
44 | - EEM_Attendee $attendee_model, |
|
45 | - RegistrantData $registrant_data |
|
46 | - ) { |
|
47 | - $this->attendee_model = $attendee_model; |
|
48 | - $this->checkout_reg_url_link = $checkout_reg_url_link; |
|
49 | - $this->registrant_data = $registrant_data; |
|
50 | - $this->required_questions = $required_questions; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @param EE_Registration $registration |
|
56 | - * @param string $reg_url_link |
|
57 | - * @param int|string $form_input |
|
58 | - * @param float|int|string $input_value |
|
59 | - * @return bool |
|
60 | - * @throws EE_Error |
|
61 | - * @throws ReflectionException |
|
62 | - */ |
|
63 | - public function processFormInput( |
|
64 | - EE_Registration $registration, |
|
65 | - string $reg_url_link, |
|
66 | - $form_input, |
|
67 | - $input_value |
|
68 | - ): bool { |
|
69 | - // check for critical inputs |
|
70 | - if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
71 | - return false; |
|
72 | - } |
|
73 | - $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
74 | - $reg_url_link, |
|
75 | - $form_input, |
|
76 | - $input_value |
|
77 | - ); |
|
78 | - if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
79 | - EE_Error::add_error( |
|
80 | - sprintf( |
|
81 | - esc_html_x( |
|
82 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
83 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
84 | - 'event_espresso' |
|
85 | - ), |
|
86 | - $form_input, |
|
87 | - $input_value |
|
88 | - ), |
|
89 | - __FILE__, |
|
90 | - __FUNCTION__, |
|
91 | - __LINE__ |
|
92 | - ); |
|
93 | - return false; |
|
94 | - } |
|
95 | - return true; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @param EE_Registration $registration |
|
101 | - * @param string $reg_url_link |
|
102 | - * @param int|string $form_input |
|
103 | - * @param float|int|string $input_value |
|
104 | - * @return bool |
|
105 | - * @throws EE_Error |
|
106 | - * @throws InvalidArgumentException |
|
107 | - * @throws InvalidDataTypeException |
|
108 | - * @throws InvalidInterfaceException |
|
109 | - * @throws ReflectionException |
|
110 | - */ |
|
111 | - private function saveRegistrationFormInput( |
|
112 | - EE_Registration $registration, |
|
113 | - string $reg_url_link, |
|
114 | - $form_input = '', |
|
115 | - $input_value = '' |
|
116 | - ): bool { |
|
117 | - // If email_confirm is sent it's not saved |
|
118 | - if ((string) $form_input === 'email_confirm') { |
|
119 | - return true; |
|
120 | - } |
|
121 | - // allow for plugins to hook in and do their own processing of the form input. |
|
122 | - // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
123 | - if ( |
|
124 | - apply_filters( |
|
125 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
126 | - false, |
|
127 | - $registration, |
|
128 | - $form_input, |
|
129 | - $input_value, |
|
130 | - $this |
|
131 | - ) |
|
132 | - ) { |
|
133 | - return true; |
|
134 | - } |
|
135 | - /* |
|
17 | + /** |
|
18 | + * @var EEM_Attendee |
|
19 | + */ |
|
20 | + private $attendee_model; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + private $checkout_reg_url_link; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var RegistrantData |
|
29 | + */ |
|
30 | + private $registrant_data; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + private $required_questions; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * RegFormHandler constructor. |
|
40 | + */ |
|
41 | + public function __construct( |
|
42 | + string $checkout_reg_url_link, |
|
43 | + array $required_questions, |
|
44 | + EEM_Attendee $attendee_model, |
|
45 | + RegistrantData $registrant_data |
|
46 | + ) { |
|
47 | + $this->attendee_model = $attendee_model; |
|
48 | + $this->checkout_reg_url_link = $checkout_reg_url_link; |
|
49 | + $this->registrant_data = $registrant_data; |
|
50 | + $this->required_questions = $required_questions; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @param EE_Registration $registration |
|
56 | + * @param string $reg_url_link |
|
57 | + * @param int|string $form_input |
|
58 | + * @param float|int|string $input_value |
|
59 | + * @return bool |
|
60 | + * @throws EE_Error |
|
61 | + * @throws ReflectionException |
|
62 | + */ |
|
63 | + public function processFormInput( |
|
64 | + EE_Registration $registration, |
|
65 | + string $reg_url_link, |
|
66 | + $form_input, |
|
67 | + $input_value |
|
68 | + ): bool { |
|
69 | + // check for critical inputs |
|
70 | + if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) { |
|
71 | + return false; |
|
72 | + } |
|
73 | + $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData( |
|
74 | + $reg_url_link, |
|
75 | + $form_input, |
|
76 | + $input_value |
|
77 | + ); |
|
78 | + if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) { |
|
79 | + EE_Error::add_error( |
|
80 | + sprintf( |
|
81 | + esc_html_x( |
|
82 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
83 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
84 | + 'event_espresso' |
|
85 | + ), |
|
86 | + $form_input, |
|
87 | + $input_value |
|
88 | + ), |
|
89 | + __FILE__, |
|
90 | + __FUNCTION__, |
|
91 | + __LINE__ |
|
92 | + ); |
|
93 | + return false; |
|
94 | + } |
|
95 | + return true; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @param EE_Registration $registration |
|
101 | + * @param string $reg_url_link |
|
102 | + * @param int|string $form_input |
|
103 | + * @param float|int|string $input_value |
|
104 | + * @return bool |
|
105 | + * @throws EE_Error |
|
106 | + * @throws InvalidArgumentException |
|
107 | + * @throws InvalidDataTypeException |
|
108 | + * @throws InvalidInterfaceException |
|
109 | + * @throws ReflectionException |
|
110 | + */ |
|
111 | + private function saveRegistrationFormInput( |
|
112 | + EE_Registration $registration, |
|
113 | + string $reg_url_link, |
|
114 | + $form_input = '', |
|
115 | + $input_value = '' |
|
116 | + ): bool { |
|
117 | + // If email_confirm is sent it's not saved |
|
118 | + if ((string) $form_input === 'email_confirm') { |
|
119 | + return true; |
|
120 | + } |
|
121 | + // allow for plugins to hook in and do their own processing of the form input. |
|
122 | + // For plugins to bypass normal processing here, they just need to return a truthy value. |
|
123 | + if ( |
|
124 | + apply_filters( |
|
125 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
126 | + false, |
|
127 | + $registration, |
|
128 | + $form_input, |
|
129 | + $input_value, |
|
130 | + $this |
|
131 | + ) |
|
132 | + ) { |
|
133 | + return true; |
|
134 | + } |
|
135 | + /* |
|
136 | 136 | * $answer_cache_id is the key used to find the EE_Answer we want |
137 | 137 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
138 | 138 | */ |
139 | - $answer_cache_id = $this->checkout_reg_url_link |
|
140 | - ? $form_input . '-' . $reg_url_link |
|
141 | - : $form_input; |
|
142 | - $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
143 | - $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
144 | - // rename form_inputs if they are EE_Attendee properties |
|
145 | - switch ((string) $form_input) { |
|
146 | - case 'state': |
|
147 | - case 'STA_ID': |
|
148 | - $attendee_property = true; |
|
149 | - $form_input = 'STA_ID'; |
|
150 | - break; |
|
151 | - |
|
152 | - case 'country': |
|
153 | - case 'CNT_ISO': |
|
154 | - $attendee_property = true; |
|
155 | - $form_input = 'CNT_ISO'; |
|
156 | - break; |
|
157 | - |
|
158 | - default: |
|
159 | - $ATT_input = 'ATT_' . $form_input; |
|
160 | - $attendee_property = $this->attendee_model->has_field($ATT_input); |
|
161 | - $form_input = $attendee_property |
|
162 | - ? 'ATT_' . $form_input |
|
163 | - : $form_input; |
|
164 | - } |
|
165 | - |
|
166 | - // if this form input has a corresponding attendee property |
|
167 | - if ($attendee_property) { |
|
168 | - $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value); |
|
169 | - if ($answer_is_obj) { |
|
170 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
171 | - $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
172 | - $registrant_answer->delete_permanently(); |
|
173 | - } |
|
174 | - return true; |
|
175 | - } |
|
176 | - if ($answer_is_obj) { |
|
177 | - // save this data to the answer object |
|
178 | - $registrant_answer->set_value($input_value); |
|
179 | - $result = $registrant_answer->save(); |
|
180 | - return $result !== false; |
|
181 | - } |
|
182 | - foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
183 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
184 | - $answer->set_value($input_value); |
|
185 | - $result = $answer->save(); |
|
186 | - return $result !== false; |
|
187 | - } |
|
188 | - } |
|
189 | - return false; |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * @param int|string $form_input |
|
195 | - * @param float|int|string $input_value |
|
196 | - * @return boolean |
|
197 | - */ |
|
198 | - private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
199 | - $form_input = '', |
|
200 | - $input_value = '' |
|
201 | - ): bool { |
|
202 | - if (empty($input_value)) { |
|
203 | - // if the form input isn't marked as being required, then just return |
|
204 | - if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) { |
|
205 | - return true; |
|
206 | - } |
|
207 | - switch ($form_input) { |
|
208 | - case 'fname': |
|
209 | - EE_Error::add_error( |
|
210 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
211 | - __FILE__, |
|
212 | - __FUNCTION__, |
|
213 | - __LINE__ |
|
214 | - ); |
|
215 | - return false; |
|
216 | - case 'lname': |
|
217 | - EE_Error::add_error( |
|
218 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
219 | - __FILE__, |
|
220 | - __FUNCTION__, |
|
221 | - __LINE__ |
|
222 | - ); |
|
223 | - return false; |
|
224 | - case 'email': |
|
225 | - EE_Error::add_error( |
|
226 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
227 | - __FILE__, |
|
228 | - __FUNCTION__, |
|
229 | - __LINE__ |
|
230 | - ); |
|
231 | - return false; |
|
232 | - } |
|
233 | - } |
|
234 | - return true; |
|
235 | - } |
|
139 | + $answer_cache_id = $this->checkout_reg_url_link |
|
140 | + ? $form_input . '-' . $reg_url_link |
|
141 | + : $form_input; |
|
142 | + $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id); |
|
143 | + $answer_is_obj = $registrant_answer instanceof EE_Answer; |
|
144 | + // rename form_inputs if they are EE_Attendee properties |
|
145 | + switch ((string) $form_input) { |
|
146 | + case 'state': |
|
147 | + case 'STA_ID': |
|
148 | + $attendee_property = true; |
|
149 | + $form_input = 'STA_ID'; |
|
150 | + break; |
|
151 | + |
|
152 | + case 'country': |
|
153 | + case 'CNT_ISO': |
|
154 | + $attendee_property = true; |
|
155 | + $form_input = 'CNT_ISO'; |
|
156 | + break; |
|
157 | + |
|
158 | + default: |
|
159 | + $ATT_input = 'ATT_' . $form_input; |
|
160 | + $attendee_property = $this->attendee_model->has_field($ATT_input); |
|
161 | + $form_input = $attendee_property |
|
162 | + ? 'ATT_' . $form_input |
|
163 | + : $form_input; |
|
164 | + } |
|
165 | + |
|
166 | + // if this form input has a corresponding attendee property |
|
167 | + if ($attendee_property) { |
|
168 | + $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value); |
|
169 | + if ($answer_is_obj) { |
|
170 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
171 | + $registration->_remove_relation_to($registrant_answer, 'Answer'); |
|
172 | + $registrant_answer->delete_permanently(); |
|
173 | + } |
|
174 | + return true; |
|
175 | + } |
|
176 | + if ($answer_is_obj) { |
|
177 | + // save this data to the answer object |
|
178 | + $registrant_answer->set_value($input_value); |
|
179 | + $result = $registrant_answer->save(); |
|
180 | + return $result !== false; |
|
181 | + } |
|
182 | + foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) { |
|
183 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
184 | + $answer->set_value($input_value); |
|
185 | + $result = $answer->save(); |
|
186 | + return $result !== false; |
|
187 | + } |
|
188 | + } |
|
189 | + return false; |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * @param int|string $form_input |
|
195 | + * @param float|int|string $input_value |
|
196 | + * @return boolean |
|
197 | + */ |
|
198 | + private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail( |
|
199 | + $form_input = '', |
|
200 | + $input_value = '' |
|
201 | + ): bool { |
|
202 | + if (empty($input_value)) { |
|
203 | + // if the form input isn't marked as being required, then just return |
|
204 | + if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) { |
|
205 | + return true; |
|
206 | + } |
|
207 | + switch ($form_input) { |
|
208 | + case 'fname': |
|
209 | + EE_Error::add_error( |
|
210 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
211 | + __FILE__, |
|
212 | + __FUNCTION__, |
|
213 | + __LINE__ |
|
214 | + ); |
|
215 | + return false; |
|
216 | + case 'lname': |
|
217 | + EE_Error::add_error( |
|
218 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
219 | + __FILE__, |
|
220 | + __FUNCTION__, |
|
221 | + __LINE__ |
|
222 | + ); |
|
223 | + return false; |
|
224 | + case 'email': |
|
225 | + EE_Error::add_error( |
|
226 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
227 | + __FILE__, |
|
228 | + __FUNCTION__, |
|
229 | + __LINE__ |
|
230 | + ); |
|
231 | + return false; |
|
232 | + } |
|
233 | + } |
|
234 | + return true; |
|
235 | + } |
|
236 | 236 | } |
@@ -9,39 +9,39 @@ |
||
9 | 9 | |
10 | 10 | class PrivacyConsentCheckboxForm extends EE_Form_Section_Proper |
11 | 11 | { |
12 | - /** |
|
13 | - * @param string $reg_step_slug |
|
14 | - * @param string $consent_checkbox_label_text |
|
15 | - * @throws EE_Error |
|
16 | - */ |
|
17 | - public function __construct(string $reg_step_slug, string $consent_checkbox_label_text) |
|
18 | - { |
|
19 | - parent::__construct( |
|
20 | - [ |
|
21 | - 'layout_strategy' => |
|
22 | - new EE_Template_Layout( |
|
23 | - [ |
|
24 | - 'input_template_file' => SPCO_REG_STEPS_PATH |
|
25 | - . $reg_step_slug |
|
26 | - . '/privacy_consent.template.php', |
|
27 | - ] |
|
28 | - ), |
|
29 | - 'subsections' => [ |
|
30 | - 'consent' => new EE_Checkbox_Multi_Input( |
|
31 | - [ |
|
32 | - 'consent' => $consent_checkbox_label_text, |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'required' => true, |
|
36 | - 'required_validation_error_message' => esc_html__( |
|
37 | - 'You must consent to these terms in order to register.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - 'html_label_text' => '', |
|
41 | - ] |
|
42 | - ), |
|
43 | - ], |
|
44 | - ] |
|
45 | - ); |
|
46 | - } |
|
12 | + /** |
|
13 | + * @param string $reg_step_slug |
|
14 | + * @param string $consent_checkbox_label_text |
|
15 | + * @throws EE_Error |
|
16 | + */ |
|
17 | + public function __construct(string $reg_step_slug, string $consent_checkbox_label_text) |
|
18 | + { |
|
19 | + parent::__construct( |
|
20 | + [ |
|
21 | + 'layout_strategy' => |
|
22 | + new EE_Template_Layout( |
|
23 | + [ |
|
24 | + 'input_template_file' => SPCO_REG_STEPS_PATH |
|
25 | + . $reg_step_slug |
|
26 | + . '/privacy_consent.template.php', |
|
27 | + ] |
|
28 | + ), |
|
29 | + 'subsections' => [ |
|
30 | + 'consent' => new EE_Checkbox_Multi_Input( |
|
31 | + [ |
|
32 | + 'consent' => $consent_checkbox_label_text, |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'required' => true, |
|
36 | + 'required_validation_error_message' => esc_html__( |
|
37 | + 'You must consent to these terms in order to register.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + 'html_label_text' => '', |
|
41 | + ] |
|
42 | + ), |
|
43 | + ], |
|
44 | + ] |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function __construct() |
71 | 71 | { |
72 | - $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | + $this->primary_registrant_data = ['line_item_id' => null, ]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | public function initializeRegistrantData(EE_Registration $registration): void |
81 | 81 | { |
82 | 82 | $reg_url_link = $registration->reg_url_link(); |
83 | - $this->registrations[ $reg_url_link ] = $registration; |
|
84 | - $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
85 | - $this->registrant_data[ $reg_url_link ] = []; |
|
83 | + $this->registrations[$reg_url_link] = $registration; |
|
84 | + $this->registrant_answers[$reg_url_link] = $registration->answers(); |
|
85 | + $this->registrant_data[$reg_url_link] = []; |
|
86 | 86 | $this->attendee_counter++; |
87 | 87 | } |
88 | 88 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getRegistrant(string $reg_url_link): ?EE_Registration |
122 | 122 | { |
123 | - return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | + return $this->registrations[$reg_url_link] ?? null; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getRegistrantData(string $reg_url_link): ?array |
132 | 132 | { |
133 | - return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | + return $this->registrant_data[$reg_url_link] ?? null; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
143 | 143 | { |
144 | - $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | + $this->registrant_data[$reg_url_link][$key] = $value; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | } |
178 | 178 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
179 | 179 | if ( |
180 | - ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | - || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
180 | + ! isset($this->registrant_data[$reg_url_link][$critical_attendee_detail]) |
|
181 | + || empty($this->registrant_data[$reg_url_link][$critical_attendee_detail]) |
|
182 | 182 | ) { |
183 | - $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
183 | + $this->registrant_data[$reg_url_link][$critical_attendee_detail] = $this->primary_registrant->get( |
|
184 | 184 | $critical_attendee_detail |
185 | 185 | ); |
186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
196 | 196 | { |
197 | - $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
197 | + $this->registrant_data[$reg_url_link] = $registrant_data; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function addRequiredQuestion(string $identifier, string $required_question): void |
215 | 215 | { |
216 | - $this->required_questions[ $identifier ] = $required_question; |
|
216 | + $this->required_questions[$identifier] = $required_question; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function registrantAnswers(string $reg_url_link): array |
224 | 224 | { |
225 | - return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
225 | + return $this->registrant_answers[$reg_url_link] ?? []; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
235 | 235 | { |
236 | - $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
236 | + $this->registrant_answers[$reg_url_link][$identifier] = $answer; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
246 | 246 | { |
247 | - return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
247 | + return $this->registrant_answers[$reg_url_link][$identifier] ?? null; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function addPrimaryRegistrantDataValue(string $key, $value): void |
278 | 278 | { |
279 | - $this->primary_registrant_data[ $key ] = $value; |
|
279 | + $this->primary_registrant_data[$key] = $value; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getPrimaryRegistrantDataValue(string $key) |
288 | 288 | { |
289 | - return $this->primary_registrant_data[ $key ] ?? null; |
|
289 | + return $this->primary_registrant_data[$key] ?? null; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
360 | 360 | { |
361 | 361 | // store a bit of data about the primary attendee |
362 | - if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | - $this->primary_registrant_data[ $form_input ] = $input_value; |
|
362 | + if ( ! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | + $this->primary_registrant_data[$form_input] = $input_value; |
|
364 | 364 | return $input_value; |
365 | 365 | } |
366 | 366 | // or copy value from primary if incoming value is not set |
@@ -18,355 +18,355 @@ |
||
18 | 18 | */ |
19 | 19 | class RegistrantData |
20 | 20 | { |
21 | - /** |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - private $attendee_counter = 0; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - private $registrant_data = []; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
34 | - private $copy_primary = false; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - private $required_questions = []; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var EE_Registration[] |
|
43 | - */ |
|
44 | - private $registrations = []; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var EE_Answer[][] |
|
48 | - */ |
|
49 | - private $registrant_answers = []; |
|
50 | - |
|
51 | - /** |
|
52 | - * array for tracking reg form data for the primary registrant |
|
53 | - * |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - private $primary_registrant_data; |
|
57 | - |
|
58 | - /** |
|
59 | - * the attendee object created for the primary registrant |
|
60 | - * |
|
61 | - * @var EE_Attendee |
|
62 | - */ |
|
63 | - private $primary_registrant; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * RegistrantData constructor. |
|
68 | - */ |
|
69 | - public function __construct() |
|
70 | - { |
|
71 | - $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @param EE_Registration $registration |
|
77 | - * @throws EE_Error |
|
78 | - */ |
|
79 | - public function initializeRegistrantData(EE_Registration $registration): void |
|
80 | - { |
|
81 | - $reg_url_link = $registration->reg_url_link(); |
|
82 | - $this->registrations[ $reg_url_link ] = $registration; |
|
83 | - $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
84 | - $this->registrant_data[ $reg_url_link ] = []; |
|
85 | - $this->attendee_counter++; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - public function attendeeCount(): int |
|
93 | - { |
|
94 | - return $this->attendee_counter; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - public function copyPrimary(): bool |
|
102 | - { |
|
103 | - return $this->copy_primary; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param bool $copy_primary |
|
109 | - */ |
|
110 | - public function setCopyPrimary(bool $copy_primary): void |
|
111 | - { |
|
112 | - $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $reg_url_link |
|
118 | - * @return array|null |
|
119 | - */ |
|
120 | - public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
121 | - { |
|
122 | - return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param string $reg_url_link |
|
128 | - * @return array|null |
|
129 | - */ |
|
130 | - public function getRegistrantData(string $reg_url_link): ?array |
|
131 | - { |
|
132 | - return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @param string $reg_url_link |
|
138 | - * @param string $key |
|
139 | - * @param mixed $value |
|
140 | - */ |
|
141 | - public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
142 | - { |
|
143 | - $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
149 | - * |
|
150 | - * @param string $reg_url_link |
|
151 | - * @throws EE_Error |
|
152 | - * @throws ReflectionException |
|
153 | - */ |
|
154 | - public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
155 | - { |
|
156 | - if ($this->currentRegistrantIsPrimary()) { |
|
157 | - return; |
|
158 | - } |
|
159 | - // bare minimum critical details include first name, last name, email address |
|
160 | - $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
161 | - // add address info to critical details? |
|
162 | - if ( |
|
163 | - apply_filters( |
|
164 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
165 | - false |
|
166 | - ) |
|
167 | - ) { |
|
168 | - $critical_attendee_details += [ |
|
169 | - 'ATT_address', |
|
170 | - 'ATT_address2', |
|
171 | - 'ATT_city', |
|
172 | - 'STA_ID', |
|
173 | - 'CNT_ISO', |
|
174 | - 'ATT_zip', |
|
175 | - 'ATT_phone', |
|
176 | - ]; |
|
177 | - } |
|
178 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
179 | - if ( |
|
180 | - ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | - || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | - ) { |
|
183 | - $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
184 | - $critical_attendee_detail |
|
185 | - ); |
|
186 | - } |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param string $reg_url_link |
|
193 | - * @param array $registrant_data |
|
194 | - */ |
|
195 | - public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
196 | - { |
|
197 | - $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * @return array |
|
203 | - */ |
|
204 | - public function getRequiredQuestions(): array |
|
205 | - { |
|
206 | - return $this->required_questions; |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * @param string $identifier |
|
212 | - * @param string $required_question |
|
213 | - */ |
|
214 | - public function addRequiredQuestion(string $identifier, string $required_question): void |
|
215 | - { |
|
216 | - $this->required_questions[ $identifier ] = $required_question; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * @return EE_Answer[] |
|
222 | - */ |
|
223 | - public function registrantAnswers(string $reg_url_link): array |
|
224 | - { |
|
225 | - return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * @param string $reg_url_link |
|
231 | - * @param string $identifier the answer cache ID |
|
232 | - * @param EE_Answer $answer |
|
233 | - */ |
|
234 | - public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
235 | - { |
|
236 | - $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $reg_url_link |
|
242 | - * @param string $identifier |
|
243 | - * @return EE_Answer|null |
|
244 | - */ |
|
245 | - public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
246 | - { |
|
247 | - return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param string $reg_url_link |
|
254 | - * @param string $identifier |
|
255 | - * @return bool |
|
256 | - */ |
|
257 | - public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
258 | - { |
|
259 | - $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
260 | - return $registrant_answer instanceof EE_Answer; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - public function primaryRegistrantData(): array |
|
268 | - { |
|
269 | - return $this->primary_registrant_data; |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * @param string $key |
|
275 | - * @param mixed $value |
|
276 | - */ |
|
277 | - public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
278 | - { |
|
279 | - $this->primary_registrant_data[ $key ] = $value; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * @param string $key |
|
285 | - * @return mixed |
|
286 | - */ |
|
287 | - public function getPrimaryRegistrantDataValue(string $key) |
|
288 | - { |
|
289 | - return $this->primary_registrant_data[ $key ] ?? null; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @param array $primary_registrant_data |
|
295 | - */ |
|
296 | - public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
297 | - { |
|
298 | - $this->primary_registrant_data = $primary_registrant_data; |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * @return EE_Attendee |
|
304 | - */ |
|
305 | - public function primaryRegistrant(): EE_Attendee |
|
306 | - { |
|
307 | - return $this->primary_registrant; |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * @return bool |
|
313 | - */ |
|
314 | - public function primaryRegistrantIsValid(): bool |
|
315 | - { |
|
316 | - return $this->primary_registrant instanceof EE_Attendee; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * @param EE_Attendee $primary_registrant |
|
322 | - */ |
|
323 | - public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
324 | - { |
|
325 | - $this->primary_registrant = $primary_registrant; |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * @param string $reg_url_link |
|
331 | - * @return bool |
|
332 | - */ |
|
333 | - public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
334 | - { |
|
335 | - return $this->attendeeCount() === 1 |
|
336 | - || ( |
|
337 | - $this->attendeeCount() === 1 |
|
338 | - && $reg_url_link !== '' |
|
339 | - && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
340 | - ); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * @return bool |
|
346 | - */ |
|
347 | - public function currentRegistrantIsNotPrimary(): bool |
|
348 | - { |
|
349 | - return $this->attendeeCount() > 1; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * @param string $reg_url_link |
|
355 | - * @param string $form_input |
|
356 | - * @param mixed $input_value |
|
357 | - * @return mixed|null |
|
358 | - */ |
|
359 | - public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
360 | - { |
|
361 | - // store a bit of data about the primary attendee |
|
362 | - if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | - $this->primary_registrant_data[ $form_input ] = $input_value; |
|
364 | - return $input_value; |
|
365 | - } |
|
366 | - // or copy value from primary if incoming value is not set |
|
367 | - if ($input_value === null && $this->copyPrimary()) { |
|
368 | - $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
369 | - } |
|
370 | - return $input_value; |
|
371 | - } |
|
21 | + /** |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + private $attendee_counter = 0; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + private $registrant_data = []; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | + private $copy_primary = false; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + private $required_questions = []; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var EE_Registration[] |
|
43 | + */ |
|
44 | + private $registrations = []; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var EE_Answer[][] |
|
48 | + */ |
|
49 | + private $registrant_answers = []; |
|
50 | + |
|
51 | + /** |
|
52 | + * array for tracking reg form data for the primary registrant |
|
53 | + * |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + private $primary_registrant_data; |
|
57 | + |
|
58 | + /** |
|
59 | + * the attendee object created for the primary registrant |
|
60 | + * |
|
61 | + * @var EE_Attendee |
|
62 | + */ |
|
63 | + private $primary_registrant; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * RegistrantData constructor. |
|
68 | + */ |
|
69 | + public function __construct() |
|
70 | + { |
|
71 | + $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @param EE_Registration $registration |
|
77 | + * @throws EE_Error |
|
78 | + */ |
|
79 | + public function initializeRegistrantData(EE_Registration $registration): void |
|
80 | + { |
|
81 | + $reg_url_link = $registration->reg_url_link(); |
|
82 | + $this->registrations[ $reg_url_link ] = $registration; |
|
83 | + $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
84 | + $this->registrant_data[ $reg_url_link ] = []; |
|
85 | + $this->attendee_counter++; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + public function attendeeCount(): int |
|
93 | + { |
|
94 | + return $this->attendee_counter; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + public function copyPrimary(): bool |
|
102 | + { |
|
103 | + return $this->copy_primary; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param bool $copy_primary |
|
109 | + */ |
|
110 | + public function setCopyPrimary(bool $copy_primary): void |
|
111 | + { |
|
112 | + $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $reg_url_link |
|
118 | + * @return array|null |
|
119 | + */ |
|
120 | + public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
121 | + { |
|
122 | + return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param string $reg_url_link |
|
128 | + * @return array|null |
|
129 | + */ |
|
130 | + public function getRegistrantData(string $reg_url_link): ?array |
|
131 | + { |
|
132 | + return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @param string $reg_url_link |
|
138 | + * @param string $key |
|
139 | + * @param mixed $value |
|
140 | + */ |
|
141 | + public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
142 | + { |
|
143 | + $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
149 | + * |
|
150 | + * @param string $reg_url_link |
|
151 | + * @throws EE_Error |
|
152 | + * @throws ReflectionException |
|
153 | + */ |
|
154 | + public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
155 | + { |
|
156 | + if ($this->currentRegistrantIsPrimary()) { |
|
157 | + return; |
|
158 | + } |
|
159 | + // bare minimum critical details include first name, last name, email address |
|
160 | + $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
161 | + // add address info to critical details? |
|
162 | + if ( |
|
163 | + apply_filters( |
|
164 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
165 | + false |
|
166 | + ) |
|
167 | + ) { |
|
168 | + $critical_attendee_details += [ |
|
169 | + 'ATT_address', |
|
170 | + 'ATT_address2', |
|
171 | + 'ATT_city', |
|
172 | + 'STA_ID', |
|
173 | + 'CNT_ISO', |
|
174 | + 'ATT_zip', |
|
175 | + 'ATT_phone', |
|
176 | + ]; |
|
177 | + } |
|
178 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
179 | + if ( |
|
180 | + ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | + || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | + ) { |
|
183 | + $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
184 | + $critical_attendee_detail |
|
185 | + ); |
|
186 | + } |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param string $reg_url_link |
|
193 | + * @param array $registrant_data |
|
194 | + */ |
|
195 | + public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
196 | + { |
|
197 | + $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * @return array |
|
203 | + */ |
|
204 | + public function getRequiredQuestions(): array |
|
205 | + { |
|
206 | + return $this->required_questions; |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * @param string $identifier |
|
212 | + * @param string $required_question |
|
213 | + */ |
|
214 | + public function addRequiredQuestion(string $identifier, string $required_question): void |
|
215 | + { |
|
216 | + $this->required_questions[ $identifier ] = $required_question; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * @return EE_Answer[] |
|
222 | + */ |
|
223 | + public function registrantAnswers(string $reg_url_link): array |
|
224 | + { |
|
225 | + return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * @param string $reg_url_link |
|
231 | + * @param string $identifier the answer cache ID |
|
232 | + * @param EE_Answer $answer |
|
233 | + */ |
|
234 | + public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
235 | + { |
|
236 | + $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $reg_url_link |
|
242 | + * @param string $identifier |
|
243 | + * @return EE_Answer|null |
|
244 | + */ |
|
245 | + public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
246 | + { |
|
247 | + return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param string $reg_url_link |
|
254 | + * @param string $identifier |
|
255 | + * @return bool |
|
256 | + */ |
|
257 | + public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
258 | + { |
|
259 | + $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
260 | + return $registrant_answer instanceof EE_Answer; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + public function primaryRegistrantData(): array |
|
268 | + { |
|
269 | + return $this->primary_registrant_data; |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * @param string $key |
|
275 | + * @param mixed $value |
|
276 | + */ |
|
277 | + public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
278 | + { |
|
279 | + $this->primary_registrant_data[ $key ] = $value; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * @param string $key |
|
285 | + * @return mixed |
|
286 | + */ |
|
287 | + public function getPrimaryRegistrantDataValue(string $key) |
|
288 | + { |
|
289 | + return $this->primary_registrant_data[ $key ] ?? null; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @param array $primary_registrant_data |
|
295 | + */ |
|
296 | + public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
297 | + { |
|
298 | + $this->primary_registrant_data = $primary_registrant_data; |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * @return EE_Attendee |
|
304 | + */ |
|
305 | + public function primaryRegistrant(): EE_Attendee |
|
306 | + { |
|
307 | + return $this->primary_registrant; |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * @return bool |
|
313 | + */ |
|
314 | + public function primaryRegistrantIsValid(): bool |
|
315 | + { |
|
316 | + return $this->primary_registrant instanceof EE_Attendee; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * @param EE_Attendee $primary_registrant |
|
322 | + */ |
|
323 | + public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
324 | + { |
|
325 | + $this->primary_registrant = $primary_registrant; |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * @param string $reg_url_link |
|
331 | + * @return bool |
|
332 | + */ |
|
333 | + public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
334 | + { |
|
335 | + return $this->attendeeCount() === 1 |
|
336 | + || ( |
|
337 | + $this->attendeeCount() === 1 |
|
338 | + && $reg_url_link !== '' |
|
339 | + && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
340 | + ); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * @return bool |
|
346 | + */ |
|
347 | + public function currentRegistrantIsNotPrimary(): bool |
|
348 | + { |
|
349 | + return $this->attendeeCount() > 1; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * @param string $reg_url_link |
|
355 | + * @param string $form_input |
|
356 | + * @param mixed $input_value |
|
357 | + * @return mixed|null |
|
358 | + */ |
|
359 | + public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
360 | + { |
|
361 | + // store a bit of data about the primary attendee |
|
362 | + if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | + $this->primary_registrant_data[ $form_input ] = $input_value; |
|
364 | + return $input_value; |
|
365 | + } |
|
366 | + // or copy value from primary if incoming value is not set |
|
367 | + if ($input_value === null && $this->copyPrimary()) { |
|
368 | + $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
369 | + } |
|
370 | + return $input_value; |
|
371 | + } |
|
372 | 372 | } |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | |
54 | 54 | public function translate_js_strings() |
55 | 55 | { |
56 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
56 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | 57 | ' is a required question.', |
58 | 58 | 'event_espresso' |
59 | 59 | ); |
60 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
60 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | 61 | ' is a required question. Please enter a value for at least one of the options.', |
62 | 62 | 'event_espresso' |
63 | 63 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'Please answer all required questions correctly before proceeding.', |
66 | 66 | 'event_espresso' |
67 | 67 | ); |
68 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
68 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | 69 | esc_html_x( |
70 | 70 | 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
71 | 71 | 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | ), |
74 | 74 | '<br/>' |
75 | 75 | ); |
76 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
76 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | 77 | 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
78 | 78 | 'event_espresso' |
79 | 79 | ); |
80 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
80 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | 81 | 'You must enter a valid email address.', |
82 | 82 | 'event_espresso' |
83 | 83 | ); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | if (empty($valid_data)) { |
323 | 323 | return $this->inValidDataError(); |
324 | 324 | } |
325 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
325 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
326 | 326 | return $this->inValidTransactionError(); |
327 | 327 | } |
328 | 328 | // get cached registrations |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | /** @var RegFormHandler $reg_form_handler */ |
335 | 335 | $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
336 | 336 | // extract attendee info from form data and save to model objects |
337 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
337 | + if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
338 | 338 | // return immediately if the previous step exited early due to errors |
339 | 339 | return false; |
340 | 340 | } |
341 | 341 | // if first pass thru SPCO, |
342 | 342 | // then let's check processed registrations against the total number of tickets in the cart |
343 | 343 | $registrations_processed = $reg_form_handler->attendeeCount(); |
344 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
344 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
345 | 345 | return $this->registrationProcessingError($registrations_processed); |
346 | 346 | } |
347 | 347 | // mark this reg step as completed |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
409 | 409 | 'event_espresso' |
410 | 410 | ), |
411 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
411 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
412 | 412 | '</a>', |
413 | 413 | '<br />' |
414 | 414 | ); |
@@ -22,862 +22,862 @@ |
||
22 | 22 | */ |
23 | 23 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
24 | 24 | { |
25 | - /** |
|
26 | - * @var RegForm |
|
27 | - */ |
|
28 | - public $reg_form; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var int |
|
32 | - */ |
|
33 | - protected $reg_form_count = 0; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * class constructor |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param EE_Checkout $checkout |
|
41 | - */ |
|
42 | - public function __construct(EE_Checkout $checkout) |
|
43 | - { |
|
44 | - $this->_slug = 'attendee_information'; |
|
45 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
46 | - $this->checkout = $checkout; |
|
47 | - $this->_reset_success_message(); |
|
48 | - $this->set_instructions( |
|
49 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - public function translate_js_strings() |
|
55 | - { |
|
56 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | - ' is a required question.', |
|
58 | - 'event_espresso' |
|
59 | - ); |
|
60 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | - ' is a required question. Please enter a value for at least one of the options.', |
|
62 | - 'event_espresso' |
|
63 | - ); |
|
64 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
65 | - 'Please answer all required questions correctly before proceeding.', |
|
66 | - 'event_espresso' |
|
67 | - ); |
|
68 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | - esc_html_x( |
|
70 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
71 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - '<br/>' |
|
75 | - ); |
|
76 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
78 | - 'event_espresso' |
|
79 | - ); |
|
80 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | - 'You must enter a valid email address.', |
|
82 | - 'event_espresso' |
|
83 | - ); |
|
84 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
85 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
86 | - 'event_espresso' |
|
87 | - ); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - public function enqueue_styles_and_scripts() |
|
92 | - { |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return boolean |
|
98 | - */ |
|
99 | - public function initialize_reg_step(): bool |
|
100 | - { |
|
101 | - return true; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return RegForm |
|
107 | - * @throws DomainException |
|
108 | - * @throws InvalidArgumentException |
|
109 | - * @throws EntityNotFoundException |
|
110 | - * @throws InvalidDataTypeException |
|
111 | - * @throws InvalidInterfaceException |
|
112 | - */ |
|
113 | - public function generate_reg_form(): RegForm |
|
114 | - { |
|
115 | - $this->setLegacyFiltersForRegFormGeneration(); |
|
116 | - /** @var RegFormDependencyHandler $dependency_handler */ |
|
117 | - $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
118 | - $dependency_handler->registerDependencies(); |
|
119 | - // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
120 | - return LoaderFactory::getShared(RegForm::class, [$this]); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @since 5.0.0.p |
|
126 | - */ |
|
127 | - private function setLegacyFiltersForRegFormGeneration() |
|
128 | - { |
|
129 | - add_filter( |
|
130 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters', |
|
131 | - [$this, 'registrationQuestionGroupsQueryParameters'], |
|
132 | - 1, |
|
133 | - 2 |
|
134 | - ); |
|
135 | - add_filter( |
|
136 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form', |
|
137 | - [$this, 'registrationQuestionGroupsRegForm'], |
|
138 | - 1, |
|
139 | - 3 |
|
140 | - ); |
|
141 | - add_filter( |
|
142 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo', |
|
143 | - [$this, 'registrationRegFormPrintCopyInfo'], |
|
144 | - 1, |
|
145 | - 2 |
|
146 | - ); |
|
147 | - add_filter( |
|
148 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params', |
|
149 | - [$this, 'registrationRegFormRelatedQuestionsQueryParams'], |
|
150 | - 1, |
|
151 | - 3 |
|
152 | - ); |
|
153 | - add_filter( |
|
154 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions', |
|
155 | - [$this, 'registrationRegFormBeforeQuestionGroupQuestions'], |
|
156 | - 1, |
|
157 | - 3 |
|
158 | - ); |
|
159 | - add_filter( |
|
160 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array', |
|
161 | - [$this, 'registrationRegFormSubsections'], |
|
162 | - 1, |
|
163 | - 3 |
|
164 | - ); |
|
165 | - add_filter( |
|
166 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions', |
|
167 | - [$this, 'registrationRegFormAfterQuestionGroupQuestions'], |
|
168 | - 1, |
|
169 | - 3 |
|
170 | - ); |
|
171 | - add_filter( |
|
172 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args', |
|
173 | - [$this, 'autoCopyAttendeeInfoTemplateArgs'], |
|
174 | - 1 |
|
175 | - ); |
|
176 | - add_filter( |
|
177 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options', |
|
178 | - [$this, 'generateQuestionInputCountryOptions'], |
|
179 | - 1, |
|
180 | - 4 |
|
181 | - ); |
|
182 | - add_filter( |
|
183 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options', |
|
184 | - [$this, 'generateQuestionInputStateOptions'], |
|
185 | - 1, |
|
186 | - 4 |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param array $query_params |
|
193 | - * @param EE_Registration $registration |
|
194 | - * @return mixed|void |
|
195 | - * @since 5.0.0.p |
|
196 | - */ |
|
197 | - public function registrationQuestionGroupsQueryParameters( |
|
198 | - array $query_params, |
|
199 | - EE_Registration $registration |
|
200 | - ) { |
|
201 | - return apply_filters( |
|
202 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
203 | - $query_params, |
|
204 | - $registration, |
|
205 | - $this |
|
206 | - ); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * @param RegFormQuestionGroup $question_group_reg_form |
|
212 | - * @param EE_Registration $registration |
|
213 | - * @param EE_Question_Group $question_group |
|
214 | - * @return mixed|void |
|
215 | - * @since 5.0.0.p |
|
216 | - */ |
|
217 | - public function registrationQuestionGroupsRegForm( |
|
218 | - RegFormQuestionGroup $question_group_reg_form, |
|
219 | - EE_Registration $registration, |
|
220 | - EE_Question_Group $question_group |
|
221 | - ) { |
|
222 | - return apply_filters( |
|
223 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
224 | - $question_group_reg_form, |
|
225 | - $registration, |
|
226 | - $question_group, |
|
227 | - $this |
|
228 | - ); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * @param int $print_copy_info |
|
234 | - * @param int $attendee_nmbr |
|
235 | - * @return mixed|void |
|
236 | - * @since 5.0.0.p |
|
237 | - */ |
|
238 | - public function registrationRegFormPrintCopyInfo( |
|
239 | - int $print_copy_info, |
|
240 | - int $attendee_nmbr |
|
241 | - ) { |
|
242 | - return apply_filters( |
|
243 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
244 | - $print_copy_info, |
|
245 | - $attendee_nmbr |
|
246 | - ); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * @param array $query_params |
|
252 | - * @param EE_Question_Group $question_group |
|
253 | - * @param EE_Registration $registration |
|
254 | - * @return mixed|void |
|
255 | - * @since 5.0.0.p |
|
256 | - */ |
|
257 | - public function registrationRegFormRelatedQuestionsQueryParams( |
|
258 | - array $query_params, |
|
259 | - EE_Question_Group $question_group, |
|
260 | - EE_Registration $registration |
|
261 | - ) { |
|
262 | - return apply_filters( |
|
263 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
264 | - $query_params, |
|
265 | - $question_group, |
|
266 | - $registration, |
|
267 | - $this |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * @param $html |
|
274 | - * @param EE_Registration $registration |
|
275 | - * @param EE_Question_Group $question_group |
|
276 | - * @return mixed|void |
|
277 | - * @since 5.0.0.p |
|
278 | - */ |
|
279 | - public function registrationRegFormBeforeQuestionGroupQuestions( |
|
280 | - $html, |
|
281 | - EE_Registration $registration, |
|
282 | - EE_Question_Group $question_group |
|
283 | - ) { |
|
284 | - return apply_filters( |
|
285 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
286 | - $html, |
|
287 | - $registration, |
|
288 | - $question_group, |
|
289 | - $this |
|
290 | - ); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @param array $form_subsections |
|
296 | - * @param EE_Registration $registration |
|
297 | - * @param EE_Question_Group $question_group |
|
298 | - * @return mixed|void |
|
299 | - * @since 5.0.0.p |
|
300 | - */ |
|
301 | - public function registrationRegFormSubsections( |
|
302 | - array $form_subsections, |
|
303 | - EE_Registration $registration, |
|
304 | - EE_Question_Group $question_group |
|
305 | - ) { |
|
306 | - return apply_filters( |
|
307 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
308 | - $form_subsections, |
|
309 | - $registration, |
|
310 | - $question_group, |
|
311 | - $this |
|
312 | - ); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param $html |
|
318 | - * @param EE_Registration $registration |
|
319 | - * @param EE_Question_Group $question_group |
|
320 | - * @return mixed|void |
|
321 | - * @since 5.0.0.p |
|
322 | - */ |
|
323 | - public function registrationRegFormAfterQuestionGroupQuestions( |
|
324 | - $html, |
|
325 | - EE_Registration $registration, |
|
326 | - EE_Question_Group $question_group |
|
327 | - ) { |
|
328 | - return apply_filters( |
|
329 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
330 | - $html, |
|
331 | - $registration, |
|
332 | - $question_group, |
|
333 | - $this |
|
334 | - ); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @param array $template_args |
|
340 | - * @return mixed|void |
|
341 | - * @since 5.0.0.p |
|
342 | - */ |
|
343 | - public function autoCopyAttendeeInfoTemplateArgs(array $template_args = []) |
|
344 | - { |
|
345 | - return apply_filters( |
|
346 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
347 | - $template_args |
|
348 | - ); |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @param array $country_options |
|
354 | - * @param EE_Registration $registration |
|
355 | - * @param EE_Question $question |
|
356 | - * @param EE_Answer|null $answer |
|
357 | - * @return mixed|void |
|
358 | - * @since 5.0.0.p |
|
359 | - */ |
|
360 | - public function generateQuestionInputCountryOptions( |
|
361 | - array $country_options, |
|
362 | - EE_Registration $registration, |
|
363 | - EE_Question $question, |
|
364 | - ?EE_Answer $answer |
|
365 | - ) { |
|
366 | - return apply_filters( |
|
367 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
368 | - $country_options, |
|
369 | - $this, |
|
370 | - $registration, |
|
371 | - $question, |
|
372 | - $answer |
|
373 | - ); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * @param array $state_options |
|
379 | - * @param EE_Registration $registration |
|
380 | - * @param EE_Question $question |
|
381 | - * @param EE_Answer|null $answer |
|
382 | - * @return mixed|void |
|
383 | - * @since 5.0.0.p |
|
384 | - */ |
|
385 | - public function generateQuestionInputStateOptions( |
|
386 | - array $state_options, |
|
387 | - EE_Registration $registration, |
|
388 | - EE_Question $question, |
|
389 | - ?EE_Answer $answer |
|
390 | - ) { |
|
391 | - return apply_filters( |
|
392 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
393 | - $state_options, |
|
394 | - $this, |
|
395 | - $registration, |
|
396 | - $question, |
|
397 | - $answer |
|
398 | - ); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * looking for hooks? |
|
404 | - * this method has been replaced by: |
|
405 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
406 | - * |
|
407 | - * @deprecated 5.0.0.p |
|
408 | - */ |
|
409 | - private function _registrations_reg_form() |
|
410 | - { |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * looking for hooks? |
|
416 | - * this method has been replaced by: |
|
417 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
418 | - * |
|
419 | - * @deprecated 5.0.0.p |
|
420 | - */ |
|
421 | - private function _additional_attendee_reg_info_input() |
|
422 | - { |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * looking for hooks? |
|
428 | - * this method has been replaced by: |
|
429 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
430 | - * |
|
431 | - * @deprecated 5.0.0.p |
|
432 | - */ |
|
433 | - private function _question_group_reg_form() |
|
434 | - { |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * looking for hooks? |
|
440 | - * this method has been replaced by: |
|
441 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
442 | - * |
|
443 | - * @deprecated 5.0.0.p |
|
444 | - */ |
|
445 | - private function _question_group_header() |
|
446 | - { |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * looking for hooks? |
|
452 | - * this method has been replaced by: |
|
453 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
454 | - * |
|
455 | - * @deprecated 5.0.0.p |
|
456 | - */ |
|
457 | - private function _copy_attendee_info_form() |
|
458 | - { |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - /** |
|
463 | - * looking for hooks? |
|
464 | - * this method has been replaced by: |
|
465 | - * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
466 | - * |
|
467 | - * @deprecated 5.0.0.p |
|
468 | - */ |
|
469 | - private function _auto_copy_attendee_info() |
|
470 | - { |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * looking for hooks? |
|
476 | - * this method has been replaced by: |
|
477 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
478 | - * |
|
479 | - * @deprecated 5.0.0.p |
|
480 | - */ |
|
481 | - private function _copy_attendee_info_inputs() |
|
482 | - { |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - /** |
|
487 | - * looking for hooks? |
|
488 | - * this method has been replaced by: |
|
489 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
490 | - * |
|
491 | - * @deprecated 5.0.0.p |
|
492 | - */ |
|
493 | - private function _additional_primary_registrant_inputs() |
|
494 | - { |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * looking for hooks? |
|
500 | - * this method has been replaced by: |
|
501 | - * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
502 | - * |
|
503 | - * @param EE_Registration $registration |
|
504 | - * @param EE_Question $question |
|
505 | - * @return EE_Form_Input_Base |
|
506 | - * @throws EE_Error |
|
507 | - * @throws ReflectionException |
|
508 | - * @deprecated 5.0.0.p |
|
509 | - */ |
|
510 | - public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
511 | - { |
|
512 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
513 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
514 | - return $reg_form_question_factory->create($registration, $question); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * looking for hooks? |
|
520 | - * this method has been replaced by: |
|
521 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
522 | - * |
|
523 | - * @deprecated 5.0.0.p |
|
524 | - */ |
|
525 | - private function _generate_question_input() |
|
526 | - { |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * looking for hooks? |
|
532 | - * this method has been replaced by: |
|
533 | - * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
534 | - * |
|
535 | - * @param array|null $countries_list |
|
536 | - * @param EE_Question|null $question |
|
537 | - * @param EE_Registration|null $registration |
|
538 | - * @param EE_Answer|null $answer |
|
539 | - * @return array 2d keys are country IDs, values are their names |
|
540 | - * @throws EE_Error |
|
541 | - * @throws ReflectionException |
|
542 | - * @deprecated 5.0.0.p |
|
543 | - */ |
|
544 | - public function use_cached_countries_for_form_input( |
|
545 | - array $countries_list = null, |
|
546 | - EE_Question $question = null, |
|
547 | - EE_Registration $registration = null, |
|
548 | - EE_Answer $answer = null |
|
549 | - ): array { |
|
550 | - /** @var CountryOptions $country_options */ |
|
551 | - $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
552 | - return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * looking for hooks? |
|
558 | - * this method has been replaced by: |
|
559 | - * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
560 | - * |
|
561 | - * @param array|null $states_list |
|
562 | - * @param EE_Question|null $question |
|
563 | - * @param EE_Registration|null $registration |
|
564 | - * @param EE_Answer|null $answer |
|
565 | - * @return array 2d keys are state IDs, values are their names |
|
566 | - * @throws EE_Error |
|
567 | - * @throws ReflectionException |
|
568 | - * @deprecated 5.0.0.p |
|
569 | - */ |
|
570 | - public function use_cached_states_for_form_input( |
|
571 | - array $states_list = null, |
|
572 | - EE_Question $question = null, |
|
573 | - EE_Registration $registration = null, |
|
574 | - EE_Answer $answer = null |
|
575 | - ): array { |
|
576 | - /** @var StateOptions $state_options */ |
|
577 | - $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
578 | - return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
579 | - } |
|
580 | - |
|
581 | - |
|
582 | - /********************************************************************************************************/ |
|
583 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
584 | - /********************************************************************************************************/ |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * @return bool |
|
589 | - * @throws EE_Error |
|
590 | - * @throws InvalidArgumentException |
|
591 | - * @throws ReflectionException |
|
592 | - * @throws RuntimeException |
|
593 | - * @throws InvalidDataTypeException |
|
594 | - * @throws InvalidInterfaceException |
|
595 | - */ |
|
596 | - public function process_reg_step(): bool |
|
597 | - { |
|
598 | - $this->setLegacyFiltersForRegFormProcessing(); |
|
599 | - // grab validated data from form |
|
600 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
601 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
602 | - if (empty($valid_data)) { |
|
603 | - return $this->inValidDataError(); |
|
604 | - } |
|
605 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
606 | - return $this->inValidTransactionError(); |
|
607 | - } |
|
608 | - // get cached registrations |
|
609 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
610 | - // verify we got the goods |
|
611 | - if (empty($registrations)) { |
|
612 | - return $this->noRegistrationsError(); |
|
613 | - } |
|
614 | - /** @var RegFormHandler $reg_form_handler */ |
|
615 | - $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
616 | - // extract attendee info from form data and save to model objects |
|
617 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
618 | - // return immediately if the previous step exited early due to errors |
|
619 | - return false; |
|
620 | - } |
|
621 | - // if first pass thru SPCO, |
|
622 | - // then let's check processed registrations against the total number of tickets in the cart |
|
623 | - $registrations_processed = $reg_form_handler->attendeeCount(); |
|
624 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
625 | - return $this->registrationProcessingError($registrations_processed); |
|
626 | - } |
|
627 | - // mark this reg step as completed |
|
628 | - $this->set_completed(); |
|
629 | - $this->_set_success_message( |
|
630 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
631 | - ); |
|
632 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
633 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
634 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
635 | - return true; |
|
636 | - } |
|
637 | - |
|
638 | - |
|
639 | - /** |
|
640 | - * @since 5.0.0.p |
|
641 | - */ |
|
642 | - private function setLegacyFiltersForRegFormProcessing() |
|
643 | - { |
|
644 | - add_filter( |
|
645 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass', |
|
646 | - [$this, 'preRegistrationProcess'], |
|
647 | - 1, |
|
648 | - 5 |
|
649 | - ); |
|
650 | - add_filter( |
|
651 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data', |
|
652 | - [$this, 'validDataLineItem'], |
|
653 | - 1, |
|
654 | - 2 |
|
655 | - ); |
|
656 | - add_filter( |
|
657 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
658 | - [$this, 'saveRegistrationFormInput'], |
|
659 | - 1, |
|
660 | - 4 |
|
661 | - ); |
|
662 | - add_filter( |
|
663 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
664 | - [$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'], |
|
665 | - 1 |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * @param bool $bypass |
|
672 | - * @param int $attendee_count |
|
673 | - * @param EE_Registration $registration |
|
674 | - * @param array $registrations |
|
675 | - * @param array $reg_form_data |
|
676 | - * @return mixed|void |
|
677 | - * @since 5.0.0.p |
|
678 | - */ |
|
679 | - public function preRegistrationProcess( |
|
680 | - bool $bypass, |
|
681 | - int $attendee_count, |
|
682 | - EE_Registration $registration, |
|
683 | - array $registrations, |
|
684 | - array $reg_form_data |
|
685 | - ) { |
|
686 | - return apply_filters( |
|
687 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
688 | - $bypass, |
|
689 | - $attendee_count, |
|
690 | - $registration, |
|
691 | - $registrations, |
|
692 | - $reg_form_data, |
|
693 | - $this |
|
694 | - ); |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * @param array $reg_form_data |
|
700 | - * @param EE_Registration $registration |
|
701 | - * @return mixed|void |
|
702 | - * @since 5.0.0.p |
|
703 | - */ |
|
704 | - public function validDataLineItem(array $reg_form_data, EE_Registration $registration) |
|
705 | - { |
|
706 | - return apply_filters( |
|
707 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
708 | - $reg_form_data, |
|
709 | - $registration |
|
710 | - ); |
|
711 | - } |
|
712 | - |
|
713 | - |
|
714 | - /** |
|
715 | - * @param bool $save |
|
716 | - * @param EE_Registration $registration |
|
717 | - * @param $form_input |
|
718 | - * @param $input_value |
|
719 | - * @return mixed|void |
|
720 | - * @since 5.0.0.p |
|
721 | - */ |
|
722 | - public function saveRegistrationFormInput(bool $save, EE_Registration $registration, $form_input, $input_value) |
|
723 | - { |
|
724 | - return apply_filters( |
|
725 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
726 | - $save, |
|
727 | - $registration, |
|
728 | - $form_input, |
|
729 | - $input_value, |
|
730 | - $this |
|
731 | - ); |
|
732 | - } |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * @param bool $merge_data |
|
737 | - * @return mixed|void |
|
738 | - * @since 5.0.0.p |
|
739 | - */ |
|
740 | - public function mergeAddressDetailsWithCriticalAttendeeDetails(bool $merge_data) |
|
741 | - { |
|
742 | - return apply_filters( |
|
743 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
744 | - $merge_data |
|
745 | - ); |
|
746 | - } |
|
747 | - |
|
748 | - |
|
749 | - /** |
|
750 | - * @return bool |
|
751 | - * @since 5.0.0.p |
|
752 | - */ |
|
753 | - private function inValidDataError(): bool |
|
754 | - { |
|
755 | - EE_Error::add_error( |
|
756 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
757 | - __FILE__, |
|
758 | - __FUNCTION__, |
|
759 | - __LINE__ |
|
760 | - ); |
|
761 | - return false; |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * @return bool |
|
767 | - * @since 5.0.0.p |
|
768 | - */ |
|
769 | - private function inValidTransactionError(): bool |
|
770 | - { |
|
771 | - EE_Error::add_error( |
|
772 | - esc_html__( |
|
773 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
774 | - 'event_espresso' |
|
775 | - ), |
|
776 | - __FILE__, |
|
777 | - __FUNCTION__, |
|
778 | - __LINE__ |
|
779 | - ); |
|
780 | - return false; |
|
781 | - } |
|
782 | - |
|
783 | - |
|
784 | - /** |
|
785 | - * @return bool |
|
786 | - * @since 5.0.0.p |
|
787 | - */ |
|
788 | - private function noRegistrationsError(): bool |
|
789 | - { |
|
790 | - // combine the old translated string with a new one, in order to not break translations |
|
791 | - $error_message = esc_html__( |
|
792 | - 'Your form data could not be applied to any valid registrations.', |
|
793 | - 'event_espresso' |
|
794 | - ); |
|
795 | - $error_message .= sprintf( |
|
796 | - esc_html_x( |
|
797 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
798 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
799 | - 'event_espresso' |
|
800 | - ), |
|
801 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
802 | - '</a>', |
|
803 | - '<br />' |
|
804 | - ); |
|
805 | - EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
806 | - return false; |
|
807 | - } |
|
808 | - |
|
809 | - |
|
810 | - /** |
|
811 | - * @param int $registrations_processed |
|
812 | - * @return bool |
|
813 | - * @since 5.0.0.p |
|
814 | - */ |
|
815 | - private function registrationProcessingError(int $registrations_processed): bool |
|
816 | - { |
|
817 | - // generate a correctly translated string for all possible singular/plural combinations |
|
818 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
819 | - $error_msg = sprintf( |
|
820 | - esc_html_x( |
|
821 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
822 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
823 | - 'event_espresso' |
|
824 | - ), |
|
825 | - $this->checkout->total_ticket_count, |
|
826 | - $registrations_processed |
|
827 | - ); |
|
828 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
829 | - $error_msg = sprintf( |
|
830 | - esc_html_x( |
|
831 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
832 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
833 | - 'event_espresso' |
|
834 | - ), |
|
835 | - $this->checkout->total_ticket_count, |
|
836 | - $registrations_processed |
|
837 | - ); |
|
838 | - } else { |
|
839 | - $error_msg = sprintf( |
|
840 | - esc_html__( |
|
841 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
842 | - 'event_espresso' |
|
843 | - ), |
|
844 | - $this->checkout->total_ticket_count, |
|
845 | - $registrations_processed |
|
846 | - ); |
|
847 | - } |
|
848 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
849 | - return false; |
|
850 | - } |
|
851 | - |
|
852 | - |
|
853 | - /** |
|
854 | - * update_reg_step |
|
855 | - * this is the final step after a user revisits the site to edit their attendee information |
|
856 | - * this gets called AFTER the process_reg_step() method above |
|
857 | - * |
|
858 | - * @return bool |
|
859 | - * @throws EE_Error |
|
860 | - * @throws InvalidArgumentException |
|
861 | - * @throws ReflectionException |
|
862 | - * @throws RuntimeException |
|
863 | - * @throws InvalidDataTypeException |
|
864 | - * @throws InvalidInterfaceException |
|
865 | - */ |
|
866 | - public function update_reg_step(): bool |
|
867 | - { |
|
868 | - // save everything |
|
869 | - if ($this->process_reg_step()) { |
|
870 | - $this->checkout->redirect = true; |
|
871 | - $this->checkout->redirect_url = add_query_arg( |
|
872 | - [ |
|
873 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
874 | - 'revisit' => true, |
|
875 | - ], |
|
876 | - $this->checkout->thank_you_page_url |
|
877 | - ); |
|
878 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
879 | - return true; |
|
880 | - } |
|
881 | - return false; |
|
882 | - } |
|
25 | + /** |
|
26 | + * @var RegForm |
|
27 | + */ |
|
28 | + public $reg_form; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var int |
|
32 | + */ |
|
33 | + protected $reg_form_count = 0; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * class constructor |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param EE_Checkout $checkout |
|
41 | + */ |
|
42 | + public function __construct(EE_Checkout $checkout) |
|
43 | + { |
|
44 | + $this->_slug = 'attendee_information'; |
|
45 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
46 | + $this->checkout = $checkout; |
|
47 | + $this->_reset_success_message(); |
|
48 | + $this->set_instructions( |
|
49 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + public function translate_js_strings() |
|
55 | + { |
|
56 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | + ' is a required question.', |
|
58 | + 'event_espresso' |
|
59 | + ); |
|
60 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | + ' is a required question. Please enter a value for at least one of the options.', |
|
62 | + 'event_espresso' |
|
63 | + ); |
|
64 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
65 | + 'Please answer all required questions correctly before proceeding.', |
|
66 | + 'event_espresso' |
|
67 | + ); |
|
68 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | + esc_html_x( |
|
70 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
71 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + '<br/>' |
|
75 | + ); |
|
76 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
78 | + 'event_espresso' |
|
79 | + ); |
|
80 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | + 'You must enter a valid email address.', |
|
82 | + 'event_espresso' |
|
83 | + ); |
|
84 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
85 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
86 | + 'event_espresso' |
|
87 | + ); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + public function enqueue_styles_and_scripts() |
|
92 | + { |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return boolean |
|
98 | + */ |
|
99 | + public function initialize_reg_step(): bool |
|
100 | + { |
|
101 | + return true; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return RegForm |
|
107 | + * @throws DomainException |
|
108 | + * @throws InvalidArgumentException |
|
109 | + * @throws EntityNotFoundException |
|
110 | + * @throws InvalidDataTypeException |
|
111 | + * @throws InvalidInterfaceException |
|
112 | + */ |
|
113 | + public function generate_reg_form(): RegForm |
|
114 | + { |
|
115 | + $this->setLegacyFiltersForRegFormGeneration(); |
|
116 | + /** @var RegFormDependencyHandler $dependency_handler */ |
|
117 | + $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
118 | + $dependency_handler->registerDependencies(); |
|
119 | + // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
120 | + return LoaderFactory::getShared(RegForm::class, [$this]); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @since 5.0.0.p |
|
126 | + */ |
|
127 | + private function setLegacyFiltersForRegFormGeneration() |
|
128 | + { |
|
129 | + add_filter( |
|
130 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters', |
|
131 | + [$this, 'registrationQuestionGroupsQueryParameters'], |
|
132 | + 1, |
|
133 | + 2 |
|
134 | + ); |
|
135 | + add_filter( |
|
136 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form', |
|
137 | + [$this, 'registrationQuestionGroupsRegForm'], |
|
138 | + 1, |
|
139 | + 3 |
|
140 | + ); |
|
141 | + add_filter( |
|
142 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo', |
|
143 | + [$this, 'registrationRegFormPrintCopyInfo'], |
|
144 | + 1, |
|
145 | + 2 |
|
146 | + ); |
|
147 | + add_filter( |
|
148 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params', |
|
149 | + [$this, 'registrationRegFormRelatedQuestionsQueryParams'], |
|
150 | + 1, |
|
151 | + 3 |
|
152 | + ); |
|
153 | + add_filter( |
|
154 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions', |
|
155 | + [$this, 'registrationRegFormBeforeQuestionGroupQuestions'], |
|
156 | + 1, |
|
157 | + 3 |
|
158 | + ); |
|
159 | + add_filter( |
|
160 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array', |
|
161 | + [$this, 'registrationRegFormSubsections'], |
|
162 | + 1, |
|
163 | + 3 |
|
164 | + ); |
|
165 | + add_filter( |
|
166 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions', |
|
167 | + [$this, 'registrationRegFormAfterQuestionGroupQuestions'], |
|
168 | + 1, |
|
169 | + 3 |
|
170 | + ); |
|
171 | + add_filter( |
|
172 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args', |
|
173 | + [$this, 'autoCopyAttendeeInfoTemplateArgs'], |
|
174 | + 1 |
|
175 | + ); |
|
176 | + add_filter( |
|
177 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options', |
|
178 | + [$this, 'generateQuestionInputCountryOptions'], |
|
179 | + 1, |
|
180 | + 4 |
|
181 | + ); |
|
182 | + add_filter( |
|
183 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options', |
|
184 | + [$this, 'generateQuestionInputStateOptions'], |
|
185 | + 1, |
|
186 | + 4 |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param array $query_params |
|
193 | + * @param EE_Registration $registration |
|
194 | + * @return mixed|void |
|
195 | + * @since 5.0.0.p |
|
196 | + */ |
|
197 | + public function registrationQuestionGroupsQueryParameters( |
|
198 | + array $query_params, |
|
199 | + EE_Registration $registration |
|
200 | + ) { |
|
201 | + return apply_filters( |
|
202 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
203 | + $query_params, |
|
204 | + $registration, |
|
205 | + $this |
|
206 | + ); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * @param RegFormQuestionGroup $question_group_reg_form |
|
212 | + * @param EE_Registration $registration |
|
213 | + * @param EE_Question_Group $question_group |
|
214 | + * @return mixed|void |
|
215 | + * @since 5.0.0.p |
|
216 | + */ |
|
217 | + public function registrationQuestionGroupsRegForm( |
|
218 | + RegFormQuestionGroup $question_group_reg_form, |
|
219 | + EE_Registration $registration, |
|
220 | + EE_Question_Group $question_group |
|
221 | + ) { |
|
222 | + return apply_filters( |
|
223 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
224 | + $question_group_reg_form, |
|
225 | + $registration, |
|
226 | + $question_group, |
|
227 | + $this |
|
228 | + ); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * @param int $print_copy_info |
|
234 | + * @param int $attendee_nmbr |
|
235 | + * @return mixed|void |
|
236 | + * @since 5.0.0.p |
|
237 | + */ |
|
238 | + public function registrationRegFormPrintCopyInfo( |
|
239 | + int $print_copy_info, |
|
240 | + int $attendee_nmbr |
|
241 | + ) { |
|
242 | + return apply_filters( |
|
243 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
244 | + $print_copy_info, |
|
245 | + $attendee_nmbr |
|
246 | + ); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * @param array $query_params |
|
252 | + * @param EE_Question_Group $question_group |
|
253 | + * @param EE_Registration $registration |
|
254 | + * @return mixed|void |
|
255 | + * @since 5.0.0.p |
|
256 | + */ |
|
257 | + public function registrationRegFormRelatedQuestionsQueryParams( |
|
258 | + array $query_params, |
|
259 | + EE_Question_Group $question_group, |
|
260 | + EE_Registration $registration |
|
261 | + ) { |
|
262 | + return apply_filters( |
|
263 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
264 | + $query_params, |
|
265 | + $question_group, |
|
266 | + $registration, |
|
267 | + $this |
|
268 | + ); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * @param $html |
|
274 | + * @param EE_Registration $registration |
|
275 | + * @param EE_Question_Group $question_group |
|
276 | + * @return mixed|void |
|
277 | + * @since 5.0.0.p |
|
278 | + */ |
|
279 | + public function registrationRegFormBeforeQuestionGroupQuestions( |
|
280 | + $html, |
|
281 | + EE_Registration $registration, |
|
282 | + EE_Question_Group $question_group |
|
283 | + ) { |
|
284 | + return apply_filters( |
|
285 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
286 | + $html, |
|
287 | + $registration, |
|
288 | + $question_group, |
|
289 | + $this |
|
290 | + ); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @param array $form_subsections |
|
296 | + * @param EE_Registration $registration |
|
297 | + * @param EE_Question_Group $question_group |
|
298 | + * @return mixed|void |
|
299 | + * @since 5.0.0.p |
|
300 | + */ |
|
301 | + public function registrationRegFormSubsections( |
|
302 | + array $form_subsections, |
|
303 | + EE_Registration $registration, |
|
304 | + EE_Question_Group $question_group |
|
305 | + ) { |
|
306 | + return apply_filters( |
|
307 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
308 | + $form_subsections, |
|
309 | + $registration, |
|
310 | + $question_group, |
|
311 | + $this |
|
312 | + ); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param $html |
|
318 | + * @param EE_Registration $registration |
|
319 | + * @param EE_Question_Group $question_group |
|
320 | + * @return mixed|void |
|
321 | + * @since 5.0.0.p |
|
322 | + */ |
|
323 | + public function registrationRegFormAfterQuestionGroupQuestions( |
|
324 | + $html, |
|
325 | + EE_Registration $registration, |
|
326 | + EE_Question_Group $question_group |
|
327 | + ) { |
|
328 | + return apply_filters( |
|
329 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
330 | + $html, |
|
331 | + $registration, |
|
332 | + $question_group, |
|
333 | + $this |
|
334 | + ); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @param array $template_args |
|
340 | + * @return mixed|void |
|
341 | + * @since 5.0.0.p |
|
342 | + */ |
|
343 | + public function autoCopyAttendeeInfoTemplateArgs(array $template_args = []) |
|
344 | + { |
|
345 | + return apply_filters( |
|
346 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
347 | + $template_args |
|
348 | + ); |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @param array $country_options |
|
354 | + * @param EE_Registration $registration |
|
355 | + * @param EE_Question $question |
|
356 | + * @param EE_Answer|null $answer |
|
357 | + * @return mixed|void |
|
358 | + * @since 5.0.0.p |
|
359 | + */ |
|
360 | + public function generateQuestionInputCountryOptions( |
|
361 | + array $country_options, |
|
362 | + EE_Registration $registration, |
|
363 | + EE_Question $question, |
|
364 | + ?EE_Answer $answer |
|
365 | + ) { |
|
366 | + return apply_filters( |
|
367 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
368 | + $country_options, |
|
369 | + $this, |
|
370 | + $registration, |
|
371 | + $question, |
|
372 | + $answer |
|
373 | + ); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * @param array $state_options |
|
379 | + * @param EE_Registration $registration |
|
380 | + * @param EE_Question $question |
|
381 | + * @param EE_Answer|null $answer |
|
382 | + * @return mixed|void |
|
383 | + * @since 5.0.0.p |
|
384 | + */ |
|
385 | + public function generateQuestionInputStateOptions( |
|
386 | + array $state_options, |
|
387 | + EE_Registration $registration, |
|
388 | + EE_Question $question, |
|
389 | + ?EE_Answer $answer |
|
390 | + ) { |
|
391 | + return apply_filters( |
|
392 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
393 | + $state_options, |
|
394 | + $this, |
|
395 | + $registration, |
|
396 | + $question, |
|
397 | + $answer |
|
398 | + ); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * looking for hooks? |
|
404 | + * this method has been replaced by: |
|
405 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
406 | + * |
|
407 | + * @deprecated 5.0.0.p |
|
408 | + */ |
|
409 | + private function _registrations_reg_form() |
|
410 | + { |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * looking for hooks? |
|
416 | + * this method has been replaced by: |
|
417 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
418 | + * |
|
419 | + * @deprecated 5.0.0.p |
|
420 | + */ |
|
421 | + private function _additional_attendee_reg_info_input() |
|
422 | + { |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * looking for hooks? |
|
428 | + * this method has been replaced by: |
|
429 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
430 | + * |
|
431 | + * @deprecated 5.0.0.p |
|
432 | + */ |
|
433 | + private function _question_group_reg_form() |
|
434 | + { |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * looking for hooks? |
|
440 | + * this method has been replaced by: |
|
441 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
442 | + * |
|
443 | + * @deprecated 5.0.0.p |
|
444 | + */ |
|
445 | + private function _question_group_header() |
|
446 | + { |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * looking for hooks? |
|
452 | + * this method has been replaced by: |
|
453 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
454 | + * |
|
455 | + * @deprecated 5.0.0.p |
|
456 | + */ |
|
457 | + private function _copy_attendee_info_form() |
|
458 | + { |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + /** |
|
463 | + * looking for hooks? |
|
464 | + * this method has been replaced by: |
|
465 | + * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
466 | + * |
|
467 | + * @deprecated 5.0.0.p |
|
468 | + */ |
|
469 | + private function _auto_copy_attendee_info() |
|
470 | + { |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * looking for hooks? |
|
476 | + * this method has been replaced by: |
|
477 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
478 | + * |
|
479 | + * @deprecated 5.0.0.p |
|
480 | + */ |
|
481 | + private function _copy_attendee_info_inputs() |
|
482 | + { |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + /** |
|
487 | + * looking for hooks? |
|
488 | + * this method has been replaced by: |
|
489 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
490 | + * |
|
491 | + * @deprecated 5.0.0.p |
|
492 | + */ |
|
493 | + private function _additional_primary_registrant_inputs() |
|
494 | + { |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * looking for hooks? |
|
500 | + * this method has been replaced by: |
|
501 | + * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
502 | + * |
|
503 | + * @param EE_Registration $registration |
|
504 | + * @param EE_Question $question |
|
505 | + * @return EE_Form_Input_Base |
|
506 | + * @throws EE_Error |
|
507 | + * @throws ReflectionException |
|
508 | + * @deprecated 5.0.0.p |
|
509 | + */ |
|
510 | + public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
511 | + { |
|
512 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
513 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
514 | + return $reg_form_question_factory->create($registration, $question); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * looking for hooks? |
|
520 | + * this method has been replaced by: |
|
521 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
522 | + * |
|
523 | + * @deprecated 5.0.0.p |
|
524 | + */ |
|
525 | + private function _generate_question_input() |
|
526 | + { |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * looking for hooks? |
|
532 | + * this method has been replaced by: |
|
533 | + * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
534 | + * |
|
535 | + * @param array|null $countries_list |
|
536 | + * @param EE_Question|null $question |
|
537 | + * @param EE_Registration|null $registration |
|
538 | + * @param EE_Answer|null $answer |
|
539 | + * @return array 2d keys are country IDs, values are their names |
|
540 | + * @throws EE_Error |
|
541 | + * @throws ReflectionException |
|
542 | + * @deprecated 5.0.0.p |
|
543 | + */ |
|
544 | + public function use_cached_countries_for_form_input( |
|
545 | + array $countries_list = null, |
|
546 | + EE_Question $question = null, |
|
547 | + EE_Registration $registration = null, |
|
548 | + EE_Answer $answer = null |
|
549 | + ): array { |
|
550 | + /** @var CountryOptions $country_options */ |
|
551 | + $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
552 | + return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * looking for hooks? |
|
558 | + * this method has been replaced by: |
|
559 | + * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
560 | + * |
|
561 | + * @param array|null $states_list |
|
562 | + * @param EE_Question|null $question |
|
563 | + * @param EE_Registration|null $registration |
|
564 | + * @param EE_Answer|null $answer |
|
565 | + * @return array 2d keys are state IDs, values are their names |
|
566 | + * @throws EE_Error |
|
567 | + * @throws ReflectionException |
|
568 | + * @deprecated 5.0.0.p |
|
569 | + */ |
|
570 | + public function use_cached_states_for_form_input( |
|
571 | + array $states_list = null, |
|
572 | + EE_Question $question = null, |
|
573 | + EE_Registration $registration = null, |
|
574 | + EE_Answer $answer = null |
|
575 | + ): array { |
|
576 | + /** @var StateOptions $state_options */ |
|
577 | + $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
578 | + return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
579 | + } |
|
580 | + |
|
581 | + |
|
582 | + /********************************************************************************************************/ |
|
583 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
584 | + /********************************************************************************************************/ |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * @return bool |
|
589 | + * @throws EE_Error |
|
590 | + * @throws InvalidArgumentException |
|
591 | + * @throws ReflectionException |
|
592 | + * @throws RuntimeException |
|
593 | + * @throws InvalidDataTypeException |
|
594 | + * @throws InvalidInterfaceException |
|
595 | + */ |
|
596 | + public function process_reg_step(): bool |
|
597 | + { |
|
598 | + $this->setLegacyFiltersForRegFormProcessing(); |
|
599 | + // grab validated data from form |
|
600 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
601 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
602 | + if (empty($valid_data)) { |
|
603 | + return $this->inValidDataError(); |
|
604 | + } |
|
605 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
606 | + return $this->inValidTransactionError(); |
|
607 | + } |
|
608 | + // get cached registrations |
|
609 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
610 | + // verify we got the goods |
|
611 | + if (empty($registrations)) { |
|
612 | + return $this->noRegistrationsError(); |
|
613 | + } |
|
614 | + /** @var RegFormHandler $reg_form_handler */ |
|
615 | + $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
616 | + // extract attendee info from form data and save to model objects |
|
617 | + if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
618 | + // return immediately if the previous step exited early due to errors |
|
619 | + return false; |
|
620 | + } |
|
621 | + // if first pass thru SPCO, |
|
622 | + // then let's check processed registrations against the total number of tickets in the cart |
|
623 | + $registrations_processed = $reg_form_handler->attendeeCount(); |
|
624 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
625 | + return $this->registrationProcessingError($registrations_processed); |
|
626 | + } |
|
627 | + // mark this reg step as completed |
|
628 | + $this->set_completed(); |
|
629 | + $this->_set_success_message( |
|
630 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
631 | + ); |
|
632 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
633 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
634 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
635 | + return true; |
|
636 | + } |
|
637 | + |
|
638 | + |
|
639 | + /** |
|
640 | + * @since 5.0.0.p |
|
641 | + */ |
|
642 | + private function setLegacyFiltersForRegFormProcessing() |
|
643 | + { |
|
644 | + add_filter( |
|
645 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass', |
|
646 | + [$this, 'preRegistrationProcess'], |
|
647 | + 1, |
|
648 | + 5 |
|
649 | + ); |
|
650 | + add_filter( |
|
651 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data', |
|
652 | + [$this, 'validDataLineItem'], |
|
653 | + 1, |
|
654 | + 2 |
|
655 | + ); |
|
656 | + add_filter( |
|
657 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
658 | + [$this, 'saveRegistrationFormInput'], |
|
659 | + 1, |
|
660 | + 4 |
|
661 | + ); |
|
662 | + add_filter( |
|
663 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
664 | + [$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'], |
|
665 | + 1 |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * @param bool $bypass |
|
672 | + * @param int $attendee_count |
|
673 | + * @param EE_Registration $registration |
|
674 | + * @param array $registrations |
|
675 | + * @param array $reg_form_data |
|
676 | + * @return mixed|void |
|
677 | + * @since 5.0.0.p |
|
678 | + */ |
|
679 | + public function preRegistrationProcess( |
|
680 | + bool $bypass, |
|
681 | + int $attendee_count, |
|
682 | + EE_Registration $registration, |
|
683 | + array $registrations, |
|
684 | + array $reg_form_data |
|
685 | + ) { |
|
686 | + return apply_filters( |
|
687 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
688 | + $bypass, |
|
689 | + $attendee_count, |
|
690 | + $registration, |
|
691 | + $registrations, |
|
692 | + $reg_form_data, |
|
693 | + $this |
|
694 | + ); |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * @param array $reg_form_data |
|
700 | + * @param EE_Registration $registration |
|
701 | + * @return mixed|void |
|
702 | + * @since 5.0.0.p |
|
703 | + */ |
|
704 | + public function validDataLineItem(array $reg_form_data, EE_Registration $registration) |
|
705 | + { |
|
706 | + return apply_filters( |
|
707 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
708 | + $reg_form_data, |
|
709 | + $registration |
|
710 | + ); |
|
711 | + } |
|
712 | + |
|
713 | + |
|
714 | + /** |
|
715 | + * @param bool $save |
|
716 | + * @param EE_Registration $registration |
|
717 | + * @param $form_input |
|
718 | + * @param $input_value |
|
719 | + * @return mixed|void |
|
720 | + * @since 5.0.0.p |
|
721 | + */ |
|
722 | + public function saveRegistrationFormInput(bool $save, EE_Registration $registration, $form_input, $input_value) |
|
723 | + { |
|
724 | + return apply_filters( |
|
725 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
726 | + $save, |
|
727 | + $registration, |
|
728 | + $form_input, |
|
729 | + $input_value, |
|
730 | + $this |
|
731 | + ); |
|
732 | + } |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * @param bool $merge_data |
|
737 | + * @return mixed|void |
|
738 | + * @since 5.0.0.p |
|
739 | + */ |
|
740 | + public function mergeAddressDetailsWithCriticalAttendeeDetails(bool $merge_data) |
|
741 | + { |
|
742 | + return apply_filters( |
|
743 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
744 | + $merge_data |
|
745 | + ); |
|
746 | + } |
|
747 | + |
|
748 | + |
|
749 | + /** |
|
750 | + * @return bool |
|
751 | + * @since 5.0.0.p |
|
752 | + */ |
|
753 | + private function inValidDataError(): bool |
|
754 | + { |
|
755 | + EE_Error::add_error( |
|
756 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
757 | + __FILE__, |
|
758 | + __FUNCTION__, |
|
759 | + __LINE__ |
|
760 | + ); |
|
761 | + return false; |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * @return bool |
|
767 | + * @since 5.0.0.p |
|
768 | + */ |
|
769 | + private function inValidTransactionError(): bool |
|
770 | + { |
|
771 | + EE_Error::add_error( |
|
772 | + esc_html__( |
|
773 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
774 | + 'event_espresso' |
|
775 | + ), |
|
776 | + __FILE__, |
|
777 | + __FUNCTION__, |
|
778 | + __LINE__ |
|
779 | + ); |
|
780 | + return false; |
|
781 | + } |
|
782 | + |
|
783 | + |
|
784 | + /** |
|
785 | + * @return bool |
|
786 | + * @since 5.0.0.p |
|
787 | + */ |
|
788 | + private function noRegistrationsError(): bool |
|
789 | + { |
|
790 | + // combine the old translated string with a new one, in order to not break translations |
|
791 | + $error_message = esc_html__( |
|
792 | + 'Your form data could not be applied to any valid registrations.', |
|
793 | + 'event_espresso' |
|
794 | + ); |
|
795 | + $error_message .= sprintf( |
|
796 | + esc_html_x( |
|
797 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
798 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
799 | + 'event_espresso' |
|
800 | + ), |
|
801 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
802 | + '</a>', |
|
803 | + '<br />' |
|
804 | + ); |
|
805 | + EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
806 | + return false; |
|
807 | + } |
|
808 | + |
|
809 | + |
|
810 | + /** |
|
811 | + * @param int $registrations_processed |
|
812 | + * @return bool |
|
813 | + * @since 5.0.0.p |
|
814 | + */ |
|
815 | + private function registrationProcessingError(int $registrations_processed): bool |
|
816 | + { |
|
817 | + // generate a correctly translated string for all possible singular/plural combinations |
|
818 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
819 | + $error_msg = sprintf( |
|
820 | + esc_html_x( |
|
821 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
822 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
823 | + 'event_espresso' |
|
824 | + ), |
|
825 | + $this->checkout->total_ticket_count, |
|
826 | + $registrations_processed |
|
827 | + ); |
|
828 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
829 | + $error_msg = sprintf( |
|
830 | + esc_html_x( |
|
831 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
832 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
833 | + 'event_espresso' |
|
834 | + ), |
|
835 | + $this->checkout->total_ticket_count, |
|
836 | + $registrations_processed |
|
837 | + ); |
|
838 | + } else { |
|
839 | + $error_msg = sprintf( |
|
840 | + esc_html__( |
|
841 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
842 | + 'event_espresso' |
|
843 | + ), |
|
844 | + $this->checkout->total_ticket_count, |
|
845 | + $registrations_processed |
|
846 | + ); |
|
847 | + } |
|
848 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
849 | + return false; |
|
850 | + } |
|
851 | + |
|
852 | + |
|
853 | + /** |
|
854 | + * update_reg_step |
|
855 | + * this is the final step after a user revisits the site to edit their attendee information |
|
856 | + * this gets called AFTER the process_reg_step() method above |
|
857 | + * |
|
858 | + * @return bool |
|
859 | + * @throws EE_Error |
|
860 | + * @throws InvalidArgumentException |
|
861 | + * @throws ReflectionException |
|
862 | + * @throws RuntimeException |
|
863 | + * @throws InvalidDataTypeException |
|
864 | + * @throws InvalidInterfaceException |
|
865 | + */ |
|
866 | + public function update_reg_step(): bool |
|
867 | + { |
|
868 | + // save everything |
|
869 | + if ($this->process_reg_step()) { |
|
870 | + $this->checkout->redirect = true; |
|
871 | + $this->checkout->redirect_url = add_query_arg( |
|
872 | + [ |
|
873 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
874 | + 'revisit' => true, |
|
875 | + ], |
|
876 | + $this->checkout->thank_you_page_url |
|
877 | + ); |
|
878 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
879 | + return true; |
|
880 | + } |
|
881 | + return false; |
|
882 | + } |
|
883 | 883 | } |