@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | // unfortunately, this needs to be done upon INCLUSION of this file, |
13 | 13 | // instead of construction, because it only gets constructed on first page load |
14 | 14 | // (all other times it gets resurrected from a wordpress option) |
15 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
|
15 | +$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*'); |
|
16 | 16 | $class_to_filepath = array(); |
17 | -if (! empty($stages)) { |
|
17 | +if ( ! empty($stages)) { |
|
18 | 18 | foreach ($stages as $filepath) { |
19 | 19 | $matches = array(); |
20 | 20 | preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
21 | + $class_to_filepath[$matches[1]] = $filepath; |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | // give addons a chance to autoload their stages too |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
58 | 58 | // echo "$version_string can be migrated fro"; |
59 | 59 | return true; |
60 | - } elseif (! $version_string) { |
|
60 | + } elseif ( ! $version_string) { |
|
61 | 61 | // echo "no version string provided: $version_string"; |
62 | 62 | // no version string provided... this must be pre 4.1 |
63 | 63 | // because since 4.1 we're |
64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
64 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | 65 | } else { |
66 | 66 | // echo "$version_string doesnt apply"; |
67 | 67 | return false; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function schema_changes_before_migration() |
74 | 74 | { |
75 | 75 | // relies on 4.1's EEH_Activation::create_table |
76 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
76 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
77 | 77 | $table_name = 'esp_answer'; |
78 | 78 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
79 | 79 | REG_ID int(10) unsigned NOT NULL, |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
11 | 11 | $class_to_filepath = array(); |
12 | 12 | if (! empty($stages)) { |
13 | - foreach ($stages as $filepath) { |
|
14 | - $matches = array(); |
|
15 | - preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | - } |
|
13 | + foreach ($stages as $filepath) { |
|
14 | + $matches = array(); |
|
15 | + preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath); |
@@ -32,57 +32,57 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class EE_DMS_Core_4_2_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | - /** |
|
36 | - * EE_DMS_Core_4_2_0 constructor. |
|
37 | - * |
|
38 | - * @param TableManager $table_manager |
|
39 | - * @param TableAnalysis $table_analysis |
|
40 | - */ |
|
41 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | - { |
|
43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
44 | - $this->_priority = 10; |
|
45 | - $this->_migration_stages = array( |
|
46 | - new EE_DMS_4_2_0_question_group_questions(), |
|
47 | - new EE_DMS_4_2_0_datetime_fields(), |
|
48 | - ); |
|
49 | - parent::__construct($table_manager, $table_analysis); |
|
50 | - } |
|
35 | + /** |
|
36 | + * EE_DMS_Core_4_2_0 constructor. |
|
37 | + * |
|
38 | + * @param TableManager $table_manager |
|
39 | + * @param TableAnalysis $table_analysis |
|
40 | + */ |
|
41 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | + { |
|
43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
44 | + $this->_priority = 10; |
|
45 | + $this->_migration_stages = array( |
|
46 | + new EE_DMS_4_2_0_question_group_questions(), |
|
47 | + new EE_DMS_4_2_0_datetime_fields(), |
|
48 | + ); |
|
49 | + parent::__construct($table_manager, $table_analysis); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - public function can_migrate_from_version($version_array) |
|
55 | - { |
|
56 | - $version_string = $version_array['Core']; |
|
57 | - if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
|
54 | + public function can_migrate_from_version($version_array) |
|
55 | + { |
|
56 | + $version_string = $version_array['Core']; |
|
57 | + if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
|
58 | 58 | // echo "$version_string can be migrated fro"; |
59 | - return true; |
|
60 | - } elseif (! $version_string) { |
|
59 | + return true; |
|
60 | + } elseif (! $version_string) { |
|
61 | 61 | // echo "no version string provided: $version_string"; |
62 | - // no version string provided... this must be pre 4.1 |
|
63 | - // because since 4.1 we're |
|
64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | - } else { |
|
62 | + // no version string provided... this must be pre 4.1 |
|
63 | + // because since 4.1 we're |
|
64 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | + } else { |
|
66 | 66 | // echo "$version_string doesnt apply"; |
67 | - return false; |
|
68 | - } |
|
69 | - } |
|
67 | + return false; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | - public function schema_changes_before_migration() |
|
74 | - { |
|
75 | - // relies on 4.1's EEH_Activation::create_table |
|
76 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
77 | - $table_name = 'esp_answer'; |
|
78 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
73 | + public function schema_changes_before_migration() |
|
74 | + { |
|
75 | + // relies on 4.1's EEH_Activation::create_table |
|
76 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
77 | + $table_name = 'esp_answer'; |
|
78 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | 79 | REG_ID int(10) unsigned NOT NULL, |
80 | 80 | QST_ID int(10) unsigned NOT NULL, |
81 | 81 | ANS_value text NOT NULL, |
82 | 82 | PRIMARY KEY (ANS_ID)"; |
83 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
84 | - $table_name = 'esp_attendee_meta'; |
|
85 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
83 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
84 | + $table_name = 'esp_attendee_meta'; |
|
85 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
86 | 86 | ATT_ID bigint(20) unsigned NOT NULL, |
87 | 87 | ATT_fname varchar(45) NOT NULL, |
88 | 88 | ATT_lname varchar(45) NOT NULL, |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | KEY ATT_fname (ATT_fname), |
99 | 99 | KEY ATT_lname (ATT_lname), |
100 | 100 | KEY ATT_email (ATT_email(191))"; |
101 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
102 | - $table_name = 'esp_country'; |
|
103 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
101 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
102 | + $table_name = 'esp_country'; |
|
103 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
104 | 104 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
105 | 105 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
106 | 106 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | CNT_is_EU tinyint(1) DEFAULT '0', |
117 | 117 | CNT_active tinyint(1) DEFAULT '0', |
118 | 118 | PRIMARY KEY (CNT_ISO)"; |
119 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
120 | - $table_name = 'esp_datetime'; |
|
121 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
119 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
120 | + $table_name = 'esp_datetime'; |
|
121 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
122 | 122 | EVT_ID bigint(20) unsigned NOT NULL, |
123 | 123 | DTT_name varchar(255) NOT NULL DEFAULT '', |
124 | 124 | DTT_description text NOT NULL, |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | PRIMARY KEY (DTT_ID), |
134 | 134 | KEY EVT_ID (EVT_ID), |
135 | 135 | KEY DTT_is_primary (DTT_is_primary)"; |
136 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
137 | - $table_name = 'esp_event_meta'; |
|
138 | - $sql = " |
|
136 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
137 | + $table_name = 'esp_event_meta'; |
|
138 | + $sql = " |
|
139 | 139 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
140 | 140 | EVT_ID bigint(20) unsigned NOT NULL, |
141 | 141 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -150,31 +150,31 @@ discard block |
||
150 | 150 | EVT_external_URL varchar(200) NULL, |
151 | 151 | EVT_donations tinyint(1) NULL, |
152 | 152 | PRIMARY KEY (EVTM_ID)"; |
153 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
154 | - $table_name = 'esp_event_question_group'; |
|
155 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
153 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
154 | + $table_name = 'esp_event_question_group'; |
|
155 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
156 | 156 | EVT_ID bigint(20) unsigned NOT NULL, |
157 | 157 | QSG_ID int(10) unsigned NOT NULL, |
158 | 158 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
159 | 159 | PRIMARY KEY (EQG_ID)"; |
160 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | - $table_name = 'esp_event_venue'; |
|
162 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
160 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | + $table_name = 'esp_event_venue'; |
|
162 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
163 | 163 | EVT_ID bigint(20) unsigned NOT NULL, |
164 | 164 | VNU_ID bigint(20) unsigned NOT NULL, |
165 | 165 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
166 | 166 | PRIMARY KEY (EVV_ID)"; |
167 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | - $table_name = 'esp_extra_meta'; |
|
169 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
167 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | + $table_name = 'esp_extra_meta'; |
|
169 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
170 | 170 | OBJ_ID int(11) DEFAULT NULL, |
171 | 171 | EXM_type varchar(45) DEFAULT NULL, |
172 | 172 | EXM_key varchar(45) DEFAULT NULL, |
173 | 173 | EXM_value text, |
174 | 174 | PRIMARY KEY (EXM_ID)"; |
175 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | - $table_name = 'esp_line_item'; |
|
177 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
175 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | + $table_name = 'esp_line_item'; |
|
177 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
178 | 178 | LIN_code varchar(245) NOT NULL DEFAULT '', |
179 | 179 | TXN_ID int(11) DEFAULT NULL, |
180 | 180 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | OBJ_ID int(11) DEFAULT NULL, |
191 | 191 | OBJ_type varchar(45)DEFAULT NULL, |
192 | 192 | PRIMARY KEY (LIN_ID)"; |
193 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | - $table_name = 'esp_message_template'; |
|
195 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
193 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | + $table_name = 'esp_message_template'; |
|
195 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
196 | 196 | GRP_ID int(10) unsigned NOT NULL, |
197 | 197 | MTP_context varchar(50) NOT NULL, |
198 | 198 | MTP_template_field varchar(30) NOT NULL, |
199 | 199 | MTP_content text NOT NULL, |
200 | 200 | PRIMARY KEY (MTP_ID), |
201 | 201 | KEY GRP_ID (GRP_ID)"; |
202 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
203 | - $table_name = 'esp_message_template_group'; |
|
204 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
202 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
203 | + $table_name = 'esp_message_template_group'; |
|
204 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
205 | 205 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
206 | 206 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
207 | 207 | MTP_messenger varchar(30) NOT NULL, |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | PRIMARY KEY (GRP_ID), |
214 | 214 | KEY EVT_ID (EVT_ID), |
215 | 215 | KEY MTP_user_id (MTP_user_id)"; |
216 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
217 | - $table_name = 'esp_payment'; |
|
218 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
216 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
217 | + $table_name = 'esp_payment'; |
|
218 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
219 | 219 | TXN_ID int(10) unsigned DEFAULT NULL, |
220 | 220 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
221 | 221 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | PRIMARY KEY (PAY_ID), |
232 | 232 | KEY TXN_ID (TXN_ID), |
233 | 233 | KEY PAY_timestamp (PAY_timestamp)"; |
234 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
235 | - $table_name = "esp_ticket"; |
|
236 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
234 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
235 | + $table_name = "esp_ticket"; |
|
236 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
237 | 237 | TTM_ID int(10) unsigned NOT NULL, |
238 | 238 | TKT_name varchar(245) NOT NULL DEFAULT '', |
239 | 239 | TKT_description text NOT NULL, |
@@ -252,28 +252,28 @@ discard block |
||
252 | 252 | TKT_parent int(10) unsigned DEFAULT '0', |
253 | 253 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
254 | 254 | PRIMARY KEY (TKT_ID)"; |
255 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
256 | - $table_name = "esp_ticket_price"; |
|
257 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
255 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
256 | + $table_name = "esp_ticket_price"; |
|
257 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
258 | 258 | TKT_ID int(10) unsigned NOT NULL, |
259 | 259 | PRC_ID int(10) unsigned NOT NULL, |
260 | 260 | PRIMARY KEY (TKP_ID)"; |
261 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
262 | - $table_name = "esp_datetime_ticket"; |
|
263 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
261 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
262 | + $table_name = "esp_datetime_ticket"; |
|
263 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
264 | 264 | DTT_ID int(10) unsigned NOT NULL, |
265 | 265 | TKT_ID int(10) unsigned NOT NULL, |
266 | 266 | PRIMARY KEY (DTK_ID)"; |
267 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
268 | - $table_name = "esp_ticket_template"; |
|
269 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
267 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
268 | + $table_name = "esp_ticket_template"; |
|
269 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
270 | 270 | TTM_name varchar(45) NOT NULL, |
271 | 271 | TTM_description text, |
272 | 272 | TTM_file varchar(45), |
273 | 273 | PRIMARY KEY (TTM_ID)"; |
274 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | - $table_name = "esp_price"; |
|
276 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
274 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $table_name = "esp_price"; |
|
276 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
277 | 277 | PRT_ID tinyint(3) unsigned NOT NULL, |
278 | 278 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
279 | 279 | PRC_name varchar(245) NOT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
285 | 285 | PRC_parent int(10) unsigned DEFAULT 0, |
286 | 286 | PRIMARY KEY (PRC_ID)"; |
287 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | - $table_name = "esp_price_type"; |
|
289 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | + $table_name = "esp_price_type"; |
|
289 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | 290 | PRT_name varchar(45) NOT NULL, |
291 | 291 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
292 | 292 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
295 | 295 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
296 | 296 | PRIMARY KEY (PRT_ID)"; |
297 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
298 | - $table_name = 'esp_question'; |
|
299 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
297 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
298 | + $table_name = 'esp_question'; |
|
299 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
300 | 300 | QST_display_text text NOT NULL, |
301 | 301 | QST_admin_label varchar(255) NOT NULL, |
302 | 302 | QST_system varchar(25) DEFAULT NULL, |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | QST_wp_user bigint(20) unsigned NULL, |
309 | 309 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
310 | 310 | PRIMARY KEY (QST_ID)'; |
311 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
313 | - $table_name = 'esp_question_group'; |
|
314 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
311 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
312 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
313 | + $table_name = 'esp_question_group'; |
|
314 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
315 | 315 | QSG_name varchar(255) NOT NULL, |
316 | 316 | QSG_identifier varchar(100) NOT NULL, |
317 | 317 | QSG_desc text NULL, |
@@ -322,24 +322,24 @@ discard block |
||
322 | 322 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
323 | 323 | PRIMARY KEY (QSG_ID), |
324 | 324 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
325 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | - $table_name = 'esp_question_group_question'; |
|
327 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | + $table_name = 'esp_question_group_question'; |
|
327 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
328 | 328 | QSG_ID int(10) unsigned NOT NULL, |
329 | 329 | QST_ID int(10) unsigned NOT NULL, |
330 | 330 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
331 | 331 | PRIMARY KEY (QGQ_ID) "; |
332 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
333 | - $table_name = 'esp_question_option'; |
|
334 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
333 | + $table_name = 'esp_question_option'; |
|
334 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
335 | 335 | QSO_value varchar(255) NOT NULL, |
336 | 336 | QSO_desc text NOT NULL, |
337 | 337 | QST_ID int(10) unsigned NOT NULL, |
338 | 338 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
339 | 339 | PRIMARY KEY (QSO_ID)"; |
340 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
341 | - $table_name = 'esp_registration'; |
|
342 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
340 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
341 | + $table_name = 'esp_registration'; |
|
342 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | 343 | EVT_ID bigint(20) unsigned NOT NULL, |
344 | 344 | ATT_ID bigint(20) unsigned NOT NULL, |
345 | 345 | TXN_ID int(10) unsigned NOT NULL, |
@@ -362,25 +362,25 @@ discard block |
||
362 | 362 | KEY STS_ID (STS_ID), |
363 | 363 | KEY REG_url_link (REG_url_link), |
364 | 364 | KEY REG_code (REG_code)"; |
365 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
366 | - $table_name = 'esp_checkin'; |
|
367 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
365 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
366 | + $table_name = 'esp_checkin'; |
|
367 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
368 | 368 | REG_ID int(10) unsigned NOT NULL, |
369 | 369 | DTT_ID int(10) unsigned NOT NULL, |
370 | 370 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
371 | 371 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
372 | 372 | PRIMARY KEY (CHK_ID)"; |
373 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
374 | - $table_name = 'esp_state'; |
|
375 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
373 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
374 | + $table_name = 'esp_state'; |
|
375 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
376 | 376 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
377 | 377 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
378 | 378 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
379 | 379 | STA_active tinyint(1) DEFAULT '1', |
380 | 380 | PRIMARY KEY (STA_ID)"; |
381 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
382 | - $table_name = 'esp_status'; |
|
383 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
381 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
382 | + $table_name = 'esp_status'; |
|
383 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
384 | 384 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
385 | 385 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
386 | 386 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
389 | 389 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
390 | 390 | KEY STS_type (STS_type)"; |
391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_transaction'; |
|
393 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_transaction'; |
|
393 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
394 | 394 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
395 | 395 | TXN_total decimal(10,3) DEFAULT '0.00', |
396 | 396 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | PRIMARY KEY (TXN_ID), |
401 | 401 | KEY TXN_timestamp (TXN_timestamp), |
402 | 402 | KEY STS_ID (STS_ID)"; |
403 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
404 | - $table_name = 'esp_venue_meta'; |
|
405 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
403 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
404 | + $table_name = 'esp_venue_meta'; |
|
405 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
406 | 406 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
407 | 407 | VNU_address varchar(255) DEFAULT NULL, |
408 | 408 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -420,36 +420,36 @@ discard block |
||
420 | 420 | PRIMARY KEY (VNUM_ID), |
421 | 421 | KEY STA_ID (STA_ID), |
422 | 422 | KEY CNT_ISO (CNT_ISO)"; |
423 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
424 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
425 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
426 | - // (because many need to convert old string states to foreign keys into the states table) |
|
427 | - $script_with_defaults->insert_default_states(); |
|
428 | - $script_with_defaults->insert_default_countries(); |
|
429 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
430 | - $script_with_defaults->insert_default_price_types(); |
|
431 | - $script_with_defaults->insert_default_prices(); |
|
432 | - $script_with_defaults->insert_default_tickets(); |
|
433 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
434 | - EE_Config::instance()->update_espresso_config(false, true); |
|
435 | - return true; |
|
436 | - } |
|
423 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
424 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
425 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
426 | + // (because many need to convert old string states to foreign keys into the states table) |
|
427 | + $script_with_defaults->insert_default_states(); |
|
428 | + $script_with_defaults->insert_default_countries(); |
|
429 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
430 | + $script_with_defaults->insert_default_price_types(); |
|
431 | + $script_with_defaults->insert_default_prices(); |
|
432 | + $script_with_defaults->insert_default_tickets(); |
|
433 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
434 | + EE_Config::instance()->update_espresso_config(false, true); |
|
435 | + return true; |
|
436 | + } |
|
437 | 437 | |
438 | 438 | |
439 | 439 | |
440 | - /** |
|
441 | - * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
442 | - * |
|
443 | - * @return boolean |
|
444 | - */ |
|
445 | - public function schema_changes_after_migration() |
|
446 | - { |
|
447 | - return true; |
|
448 | - } |
|
440 | + /** |
|
441 | + * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
442 | + * |
|
443 | + * @return boolean |
|
444 | + */ |
|
445 | + public function schema_changes_after_migration() |
|
446 | + { |
|
447 | + return true; |
|
448 | + } |
|
449 | 449 | |
450 | 450 | |
451 | 451 | |
452 | - public function migration_page_hooks() |
|
453 | - { |
|
454 | - } |
|
452 | + public function migration_page_hooks() |
|
453 | + { |
|
454 | + } |
|
455 | 455 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | // first get registrations just for this attendee. |
81 | 81 | $att = $data->att_obj; |
82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
83 | 83 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
84 | 84 | ? array($data->reg_obj) : $registrations_on_attendee; |
85 | 85 | $tkts = array(); |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | // tickets will be tickets for all registrations on this attendee. |
102 | 102 | foreach ($registrations_on_attendee as $reg) { |
103 | 103 | if ($reg instanceof EE_Registration) { |
104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | - $data->registrations[ $reg->ID() ] |
|
106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | - ) ]['tkt_obj'] : null; |
|
104 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
105 | + $data->registrations[$reg->ID()] |
|
106 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
107 | + )]['tkt_obj'] : null; |
|
108 | 108 | if ($ticket instanceof EE_Ticket) { |
109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
109 | + $tkts[$ticket->ID()] = $ticket; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | // data will be tickets for this event for this recipient. |
124 | 124 | foreach ($registrations_on_attendee as $reg) { |
125 | 125 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | - $data->registrations[ $reg->ID() ] |
|
128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | - ) ]['tkt_obj'] : null; |
|
126 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
127 | + $data->registrations[$reg->ID()] |
|
128 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
129 | + )]['tkt_obj'] : null; |
|
130 | 130 | if ($ticket instanceof EE_Ticket) { |
131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
131 | + $tkts[$ticket->ID()] = $ticket; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | // first get registrations just for this attendee. |
172 | 172 | $att = $data->att_obj; |
173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
174 | 174 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
175 | 175 | ? array($data->reg_obj) |
176 | 176 | : $registrations_on_attendee; |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | // dtts will be datetimes for all registrations on this attendee |
186 | 186 | foreach ($registrations_on_attendee as $reg) { |
187 | 187 | if ($reg instanceof EE_Registration) { |
188 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | - $data->registrations[ $reg->ID() ] |
|
190 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | - ) ]['dtt_objs'] : array(); |
|
188 | + $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array( |
|
189 | + $data->registrations[$reg->ID()] |
|
190 | + ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID( |
|
191 | + )]['dtt_objs'] : array(); |
|
192 | 192 | $dtt_objs = (array) $dtt_objs; |
193 | 193 | foreach ($dtt_objs as $dtt_obj) { |
194 | 194 | if ($dtt_obj instanceof EE_Datetime) { |
195 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
195 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | // data will be datetimes for this event for this recipient |
209 | 209 | foreach ($registrations_on_attendee as $reg) { |
210 | 210 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
211 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | - $data->registrations[ $reg->ID() ] |
|
213 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | - ) ]['tkt_obj'] : null; |
|
211 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
212 | + $data->registrations[$reg->ID()] |
|
213 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
214 | + )]['tkt_obj'] : null; |
|
215 | 215 | if ($ticket instanceof EE_Ticket) { |
216 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | - $data->tickets[ $ticket->ID() ] |
|
218 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | - ) ]['dtt_objs'] : array(); |
|
216 | + $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array( |
|
217 | + $data->tickets[$ticket->ID()] |
|
218 | + ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID( |
|
219 | + )]['dtt_objs'] : array(); |
|
220 | 220 | $dtt_objs = (array) $dtt_objs; |
221 | 221 | foreach ($dtt_objs as $dtt_obj) { |
222 | 222 | if ($dtt_obj instanceof EE_Datetime) { |
223 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
223 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -18,225 +18,225 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Recipient_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _init_props() |
|
28 | - { |
|
29 | - $this->label = esc_html__('Recipient List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
31 | - $this->_shortcodes = array( |
|
32 | - '[RECIPIENT_TICKET_LIST]' => esc_html__( |
|
33 | - 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '[RECIPIENT_DATETIME_LIST]' => esc_html__( |
|
37 | - 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _parser($shortcode) |
|
45 | - { |
|
46 | - switch ($shortcode) { |
|
47 | - case '[RECIPIENT_TICKET_LIST]': |
|
48 | - return $this->_get_recipient_ticket_list(); |
|
49 | - break; |
|
50 | - |
|
51 | - case '[RECIPIENT_DATETIME_LIST]': |
|
52 | - return $this->_get_recipient_datetime_list(); |
|
53 | - break; |
|
54 | - } |
|
55 | - return ''; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - private function _get_recipient_ticket_list() |
|
65 | - { |
|
66 | - $this->_validate_list_requirements(); |
|
67 | - |
|
68 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
69 | - return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
70 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | - return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
72 | - } else { |
|
73 | - return ''; |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
79 | - { |
|
80 | - // first get registrations just for this attendee. |
|
81 | - $att = $data->att_obj; |
|
82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
83 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
84 | - ? array($data->reg_obj) : $registrations_on_attendee; |
|
85 | - $tkts = array(); |
|
86 | - |
|
87 | - // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
88 | - // which means we want to get tickets for all events this addressee is a part of. |
|
89 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
90 | - $valid_shortcodes = array( |
|
91 | - 'ticket', |
|
92 | - 'event_list', |
|
93 | - 'attendee_list', |
|
94 | - 'datetime_list', |
|
95 | - 'registration_details', |
|
96 | - 'attendee', |
|
97 | - 'recipient_details', |
|
98 | - ); |
|
99 | - $template = $this->_data['template']; |
|
100 | - |
|
101 | - // tickets will be tickets for all registrations on this attendee. |
|
102 | - foreach ($registrations_on_attendee as $reg) { |
|
103 | - if ($reg instanceof EE_Registration) { |
|
104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | - $data->registrations[ $reg->ID() ] |
|
106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | - ) ]['tkt_obj'] : null; |
|
108 | - if ($ticket instanceof EE_Ticket) { |
|
109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
116 | - $event = $this->_data['data']; |
|
117 | - if ($event instanceof EE_Event) { |
|
118 | - $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
119 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
120 | - ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
121 | - // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
122 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
123 | - // data will be tickets for this event for this recipient. |
|
124 | - foreach ($registrations_on_attendee as $reg) { |
|
125 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | - $data->registrations[ $reg->ID() ] |
|
128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | - ) ]['tkt_obj'] : null; |
|
130 | - if ($ticket instanceof EE_Ticket) { |
|
131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $tkt_parsed = ''; |
|
138 | - foreach ($tkts as $ticket) { |
|
139 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | - $template, |
|
141 | - $ticket, |
|
142 | - $valid_shortcodes, |
|
143 | - $this->_extra_data |
|
144 | - ); |
|
145 | - } |
|
146 | - return $tkt_parsed; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - private function _get_recipient_datetime_list() |
|
156 | - { |
|
157 | - $this->_validate_list_requirements(); |
|
158 | - |
|
159 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
160 | - return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
161 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
162 | - return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
163 | - } else { |
|
164 | - return ''; |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
170 | - { |
|
171 | - // first get registrations just for this attendee. |
|
172 | - $att = $data->att_obj; |
|
173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
174 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
175 | - ? array($data->reg_obj) |
|
176 | - : $registrations_on_attendee; |
|
177 | - $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
178 | - $template = ''; |
|
179 | - $dtts = array(); |
|
180 | - |
|
181 | - // setup valid shortcodes depending on what the status of the $this->_data property is |
|
182 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
183 | - $template = $this->_data['template']; |
|
184 | - |
|
185 | - // dtts will be datetimes for all registrations on this attendee |
|
186 | - foreach ($registrations_on_attendee as $reg) { |
|
187 | - if ($reg instanceof EE_Registration) { |
|
188 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | - $data->registrations[ $reg->ID() ] |
|
190 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | - ) ]['dtt_objs'] : array(); |
|
192 | - $dtt_objs = (array) $dtt_objs; |
|
193 | - foreach ($dtt_objs as $dtt_obj) { |
|
194 | - if ($dtt_obj instanceof EE_Datetime) { |
|
195 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
203 | - $event = $this->_data['data']; |
|
204 | - if ($event instanceof EE_Event) { |
|
205 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
206 | - ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
207 | - |
|
208 | - // data will be datetimes for this event for this recipient |
|
209 | - foreach ($registrations_on_attendee as $reg) { |
|
210 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
211 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | - $data->registrations[ $reg->ID() ] |
|
213 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | - ) ]['tkt_obj'] : null; |
|
215 | - if ($ticket instanceof EE_Ticket) { |
|
216 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | - $data->tickets[ $ticket->ID() ] |
|
218 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | - ) ]['dtt_objs'] : array(); |
|
220 | - $dtt_objs = (array) $dtt_objs; |
|
221 | - foreach ($dtt_objs as $dtt_obj) { |
|
222 | - if ($dtt_obj instanceof EE_Datetime) { |
|
223 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - $dtt_parsed = ''; |
|
232 | - foreach ($dtts as $datetime) { |
|
233 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
234 | - $template, |
|
235 | - $datetime, |
|
236 | - $valid_shortcodes, |
|
237 | - $this->_extra_data |
|
238 | - ); |
|
239 | - } |
|
240 | - return $dtt_parsed; |
|
241 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Recipient List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
31 | + $this->_shortcodes = array( |
|
32 | + '[RECIPIENT_TICKET_LIST]' => esc_html__( |
|
33 | + 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '[RECIPIENT_DATETIME_LIST]' => esc_html__( |
|
37 | + 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _parser($shortcode) |
|
45 | + { |
|
46 | + switch ($shortcode) { |
|
47 | + case '[RECIPIENT_TICKET_LIST]': |
|
48 | + return $this->_get_recipient_ticket_list(); |
|
49 | + break; |
|
50 | + |
|
51 | + case '[RECIPIENT_DATETIME_LIST]': |
|
52 | + return $this->_get_recipient_datetime_list(); |
|
53 | + break; |
|
54 | + } |
|
55 | + return ''; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + private function _get_recipient_ticket_list() |
|
65 | + { |
|
66 | + $this->_validate_list_requirements(); |
|
67 | + |
|
68 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
69 | + return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
70 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | + return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
72 | + } else { |
|
73 | + return ''; |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
79 | + { |
|
80 | + // first get registrations just for this attendee. |
|
81 | + $att = $data->att_obj; |
|
82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
83 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
84 | + ? array($data->reg_obj) : $registrations_on_attendee; |
|
85 | + $tkts = array(); |
|
86 | + |
|
87 | + // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
88 | + // which means we want to get tickets for all events this addressee is a part of. |
|
89 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
90 | + $valid_shortcodes = array( |
|
91 | + 'ticket', |
|
92 | + 'event_list', |
|
93 | + 'attendee_list', |
|
94 | + 'datetime_list', |
|
95 | + 'registration_details', |
|
96 | + 'attendee', |
|
97 | + 'recipient_details', |
|
98 | + ); |
|
99 | + $template = $this->_data['template']; |
|
100 | + |
|
101 | + // tickets will be tickets for all registrations on this attendee. |
|
102 | + foreach ($registrations_on_attendee as $reg) { |
|
103 | + if ($reg instanceof EE_Registration) { |
|
104 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | + $data->registrations[ $reg->ID() ] |
|
106 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | + ) ]['tkt_obj'] : null; |
|
108 | + if ($ticket instanceof EE_Ticket) { |
|
109 | + $tkts[ $ticket->ID() ] = $ticket; |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
116 | + $event = $this->_data['data']; |
|
117 | + if ($event instanceof EE_Event) { |
|
118 | + $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
119 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
120 | + ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
121 | + // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
122 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
123 | + // data will be tickets for this event for this recipient. |
|
124 | + foreach ($registrations_on_attendee as $reg) { |
|
125 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
126 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | + $data->registrations[ $reg->ID() ] |
|
128 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | + ) ]['tkt_obj'] : null; |
|
130 | + if ($ticket instanceof EE_Ticket) { |
|
131 | + $tkts[ $ticket->ID() ] = $ticket; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $tkt_parsed = ''; |
|
138 | + foreach ($tkts as $ticket) { |
|
139 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | + $template, |
|
141 | + $ticket, |
|
142 | + $valid_shortcodes, |
|
143 | + $this->_extra_data |
|
144 | + ); |
|
145 | + } |
|
146 | + return $tkt_parsed; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + private function _get_recipient_datetime_list() |
|
156 | + { |
|
157 | + $this->_validate_list_requirements(); |
|
158 | + |
|
159 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
160 | + return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
161 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
162 | + return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
163 | + } else { |
|
164 | + return ''; |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
170 | + { |
|
171 | + // first get registrations just for this attendee. |
|
172 | + $att = $data->att_obj; |
|
173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
174 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
175 | + ? array($data->reg_obj) |
|
176 | + : $registrations_on_attendee; |
|
177 | + $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
178 | + $template = ''; |
|
179 | + $dtts = array(); |
|
180 | + |
|
181 | + // setup valid shortcodes depending on what the status of the $this->_data property is |
|
182 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
183 | + $template = $this->_data['template']; |
|
184 | + |
|
185 | + // dtts will be datetimes for all registrations on this attendee |
|
186 | + foreach ($registrations_on_attendee as $reg) { |
|
187 | + if ($reg instanceof EE_Registration) { |
|
188 | + $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | + $data->registrations[ $reg->ID() ] |
|
190 | + ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | + ) ]['dtt_objs'] : array(); |
|
192 | + $dtt_objs = (array) $dtt_objs; |
|
193 | + foreach ($dtt_objs as $dtt_obj) { |
|
194 | + if ($dtt_obj instanceof EE_Datetime) { |
|
195 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
203 | + $event = $this->_data['data']; |
|
204 | + if ($event instanceof EE_Event) { |
|
205 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
206 | + ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
207 | + |
|
208 | + // data will be datetimes for this event for this recipient |
|
209 | + foreach ($registrations_on_attendee as $reg) { |
|
210 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
211 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | + $data->registrations[ $reg->ID() ] |
|
213 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | + ) ]['tkt_obj'] : null; |
|
215 | + if ($ticket instanceof EE_Ticket) { |
|
216 | + $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | + $data->tickets[ $ticket->ID() ] |
|
218 | + ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | + ) ]['dtt_objs'] : array(); |
|
220 | + $dtt_objs = (array) $dtt_objs; |
|
221 | + foreach ($dtt_objs as $dtt_obj) { |
|
222 | + if ($dtt_obj instanceof EE_Datetime) { |
|
223 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + $dtt_parsed = ''; |
|
232 | + foreach ($dtts as $datetime) { |
|
233 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
234 | + $template, |
|
235 | + $datetime, |
|
236 | + $valid_shortcodes, |
|
237 | + $this->_extra_data |
|
238 | + ); |
|
239 | + } |
|
240 | + return $dtt_parsed; |
|
241 | + } |
|
242 | 242 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $text .= '<span class="drk-grey-text">'; |
71 | 71 | $text .= '<span class="dashicons dashicons-calendar"></span>'; |
72 | 72 | $text .= $datetime->name(); |
73 | - $text .= ' ( ' . $datetime->start_date() . ' )'; |
|
73 | + $text .= ' ( '.$datetime->start_date().' )'; |
|
74 | 74 | $text .= '</span></h3>'; |
75 | 75 | } |
76 | 76 | } |
@@ -22,57 +22,57 @@ |
||
22 | 22 | */ |
23 | 23 | class DateFilterHeader extends AdminPageHeaderDecorator |
24 | 24 | { |
25 | - /** |
|
26 | - * @var EEM_Datetime $datetime_model |
|
27 | - */ |
|
28 | - private $datetime_model; |
|
25 | + /** |
|
26 | + * @var EEM_Datetime $datetime_model |
|
27 | + */ |
|
28 | + private $datetime_model; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * DateFilterHeader constructor. |
|
33 | - * |
|
34 | - * @param RequestInterface $request |
|
35 | - * @param EEM_Datetime $datetime_model |
|
36 | - */ |
|
37 | - public function __construct(RequestInterface $request, EEM_Datetime $datetime_model) |
|
38 | - { |
|
39 | - parent::__construct($request); |
|
40 | - $this->datetime_model = $datetime_model; |
|
41 | - } |
|
31 | + /** |
|
32 | + * DateFilterHeader constructor. |
|
33 | + * |
|
34 | + * @param RequestInterface $request |
|
35 | + * @param EEM_Datetime $datetime_model |
|
36 | + */ |
|
37 | + public function __construct(RequestInterface $request, EEM_Datetime $datetime_model) |
|
38 | + { |
|
39 | + parent::__construct($request); |
|
40 | + $this->datetime_model = $datetime_model; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @param string $text |
|
46 | - * @return string |
|
47 | - * @throws EE_Error |
|
48 | - * @throws InvalidDataTypeException |
|
49 | - * @throws InvalidInterfaceException |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws ReflectionException |
|
52 | - * @since 4.10.2.p |
|
53 | - */ |
|
54 | - public function getHeaderText($text = '') |
|
55 | - { |
|
56 | - $DTT_ID = $this->request->getRequestParam('DTT_ID'); |
|
57 | - $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int'); |
|
58 | - if ($DTT_ID) { |
|
59 | - $datetime = $this->datetime_model->get_one_by_ID($DTT_ID); |
|
60 | - if ($datetime instanceof EE_Datetime && $text !== '') { |
|
61 | - // remove the closing h3 heading tag if it exists |
|
62 | - $text = str_replace( |
|
63 | - '</h3>', |
|
64 | - '', |
|
65 | - $text |
|
66 | - ); |
|
67 | - $text .= ' '; |
|
68 | - $text .= '<span class="drk-grey-text">'; |
|
69 | - $text .= '<span class="dashicons dashicons-calendar"></span>'; |
|
70 | - $text .= $datetime->name(); |
|
71 | - $text .= ' ( ' . $datetime->start_date() . ' )'; |
|
72 | - $text .= '</span></h3>'; |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @param string $text |
|
46 | + * @return string |
|
47 | + * @throws EE_Error |
|
48 | + * @throws InvalidDataTypeException |
|
49 | + * @throws InvalidInterfaceException |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws ReflectionException |
|
52 | + * @since 4.10.2.p |
|
53 | + */ |
|
54 | + public function getHeaderText($text = '') |
|
55 | + { |
|
56 | + $DTT_ID = $this->request->getRequestParam('DTT_ID'); |
|
57 | + $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int'); |
|
58 | + if ($DTT_ID) { |
|
59 | + $datetime = $this->datetime_model->get_one_by_ID($DTT_ID); |
|
60 | + if ($datetime instanceof EE_Datetime && $text !== '') { |
|
61 | + // remove the closing h3 heading tag if it exists |
|
62 | + $text = str_replace( |
|
63 | + '</h3>', |
|
64 | + '', |
|
65 | + $text |
|
66 | + ); |
|
67 | + $text .= ' '; |
|
68 | + $text .= '<span class="drk-grey-text">'; |
|
69 | + $text .= '<span class="dashicons dashicons-calendar"></span>'; |
|
70 | + $text .= $datetime->name(); |
|
71 | + $text .= ' ( ' . $datetime->start_date() . ' )'; |
|
72 | + $text .= '</span></h3>'; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - return $text; |
|
77 | - } |
|
76 | + return $text; |
|
77 | + } |
|
78 | 78 | } |
@@ -59,13 +59,13 @@ |
||
59 | 59 | 'event_espresso' |
60 | 60 | ), |
61 | 61 | '<h3 style="line-height:1.5em;">', |
62 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
62 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
63 | 63 | array( |
64 | 64 | 'action' => 'edit_attendee', |
65 | 65 | 'post' => $ATT_ID, |
66 | 66 | ), |
67 | 67 | REG_ADMIN_URL |
68 | - ) . '">' . $attendee->full_name() . '</a>', |
|
68 | + ).'">'.$attendee->full_name().'</a>', |
|
69 | 69 | '</h3>' |
70 | 70 | ); |
71 | 71 | } |
@@ -19,55 +19,55 @@ |
||
19 | 19 | */ |
20 | 20 | class AttendeeFilterHeader extends AdminPageHeaderDecorator |
21 | 21 | { |
22 | - /** |
|
23 | - * @var EEM_Attendee $attendee_model |
|
24 | - */ |
|
25 | - private $attendee_model; |
|
22 | + /** |
|
23 | + * @var EEM_Attendee $attendee_model |
|
24 | + */ |
|
25 | + private $attendee_model; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * AttendeeFilterHeader constructor. |
|
30 | - * |
|
31 | - * @param RequestInterface $request |
|
32 | - * @param EEM_Attendee $attendee_model |
|
33 | - */ |
|
34 | - public function __construct(RequestInterface $request, EEM_Attendee $attendee_model) |
|
35 | - { |
|
36 | - parent::__construct($request); |
|
37 | - $this->attendee_model = $attendee_model; |
|
38 | - } |
|
28 | + /** |
|
29 | + * AttendeeFilterHeader constructor. |
|
30 | + * |
|
31 | + * @param RequestInterface $request |
|
32 | + * @param EEM_Attendee $attendee_model |
|
33 | + */ |
|
34 | + public function __construct(RequestInterface $request, EEM_Attendee $attendee_model) |
|
35 | + { |
|
36 | + parent::__construct($request); |
|
37 | + $this->attendee_model = $attendee_model; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $text |
|
43 | - * @return string |
|
44 | - * @throws EE_Error |
|
45 | - * @since 4.10.2.p |
|
46 | - */ |
|
47 | - public function getHeaderText($text = '') |
|
48 | - { |
|
49 | - $ATT_ID = $this->request->getRequestParam('ATT_ID'); |
|
50 | - $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int'); |
|
51 | - if ($ATT_ID) { |
|
52 | - $attendee = $this->attendee_model->get_one_by_ID($ATT_ID); |
|
53 | - if ($attendee instanceof EE_Attendee) { |
|
54 | - $text .= sprintf( |
|
55 | - esc_html__( |
|
56 | - '%1$s Viewing registrations for %2$s%3$s', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - '<h3 style="line-height:1.5em;">', |
|
60 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
61 | - array( |
|
62 | - 'action' => 'edit_attendee', |
|
63 | - 'post' => $ATT_ID, |
|
64 | - ), |
|
65 | - REG_ADMIN_URL |
|
66 | - ) . '">' . $attendee->full_name() . '</a>', |
|
67 | - '</h3>' |
|
68 | - ); |
|
69 | - } |
|
70 | - } |
|
71 | - return $text; |
|
72 | - } |
|
41 | + /** |
|
42 | + * @param string $text |
|
43 | + * @return string |
|
44 | + * @throws EE_Error |
|
45 | + * @since 4.10.2.p |
|
46 | + */ |
|
47 | + public function getHeaderText($text = '') |
|
48 | + { |
|
49 | + $ATT_ID = $this->request->getRequestParam('ATT_ID'); |
|
50 | + $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int'); |
|
51 | + if ($ATT_ID) { |
|
52 | + $attendee = $this->attendee_model->get_one_by_ID($ATT_ID); |
|
53 | + if ($attendee instanceof EE_Attendee) { |
|
54 | + $text .= sprintf( |
|
55 | + esc_html__( |
|
56 | + '%1$s Viewing registrations for %2$s%3$s', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + '<h3 style="line-height:1.5em;">', |
|
60 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
61 | + array( |
|
62 | + 'action' => 'edit_attendee', |
|
63 | + 'post' => $ATT_ID, |
|
64 | + ), |
|
65 | + REG_ADMIN_URL |
|
66 | + ) . '">' . $attendee->full_name() . '</a>', |
|
67 | + '</h3>' |
|
68 | + ); |
|
69 | + } |
|
70 | + } |
|
71 | + return $text; |
|
72 | + } |
|
73 | 73 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $jsonDates = []; |
38 | 38 | foreach ($datetimes as $datetime) { |
39 | 39 | if ($datetime instanceof EE_Datetime) { |
40 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | + $jsonDates[$datetime->ID()] = $this->convertAndEncode($datetime); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | return $jsonDates; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $arrayOfDates = []; |
76 | 76 | foreach ($datetimes as $datetime) { |
77 | 77 | if ($datetime instanceof EE_Datetime) { |
78 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | + $arrayOfDates[$datetime->ID()] = $this->convert($datetime); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | return $arrayOfDates; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $jsonDates = []; |
128 | 128 | foreach ($datetimes as $datetime) { |
129 | 129 | if ($datetime instanceof EE_Datetime) { |
130 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | + $jsonDates[$datetime->ID()] = $this->encode($datetime); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | return $jsonDates; |
@@ -21,125 +21,125 @@ |
||
21 | 21 | */ |
22 | 22 | class DatetimeToJson implements ModelObjectToJsonConverterInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * @param EE_Datetime[] $datetimes |
|
26 | - * @return array |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - * @since 5.0.0.p |
|
33 | - */ |
|
34 | - public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | - { |
|
36 | - $jsonDates = []; |
|
37 | - foreach ($datetimes as $datetime) { |
|
38 | - if ($datetime instanceof EE_Datetime) { |
|
39 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | - } |
|
41 | - } |
|
42 | - return $jsonDates; |
|
43 | - } |
|
24 | + /** |
|
25 | + * @param EE_Datetime[] $datetimes |
|
26 | + * @return array |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + * @since 5.0.0.p |
|
33 | + */ |
|
34 | + public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | + { |
|
36 | + $jsonDates = []; |
|
37 | + foreach ($datetimes as $datetime) { |
|
38 | + if ($datetime instanceof EE_Datetime) { |
|
39 | + $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | + } |
|
41 | + } |
|
42 | + return $jsonDates; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param EE_Datetime $datetime |
|
48 | - * @return false|string |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws InvalidDataTypeException |
|
52 | - * @throws InvalidInterfaceException |
|
53 | - * @throws ReflectionException |
|
54 | - * @since 5.0.0.p |
|
55 | - */ |
|
56 | - public function convertAndEncode($datetime) |
|
57 | - { |
|
58 | - return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | - } |
|
46 | + /** |
|
47 | + * @param EE_Datetime $datetime |
|
48 | + * @return false|string |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws InvalidDataTypeException |
|
52 | + * @throws InvalidInterfaceException |
|
53 | + * @throws ReflectionException |
|
54 | + * @since 5.0.0.p |
|
55 | + */ |
|
56 | + public function convertAndEncode($datetime) |
|
57 | + { |
|
58 | + return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param EE_Datetime[] $datetimes |
|
64 | - * @return array |
|
65 | - * @throws EE_Error |
|
66 | - * @throws InvalidArgumentException |
|
67 | - * @throws InvalidDataTypeException |
|
68 | - * @throws InvalidInterfaceException |
|
69 | - * @throws ReflectionException |
|
70 | - * @since 5.0.0.p |
|
71 | - */ |
|
72 | - public function convertArrayOf(array $datetimes) |
|
73 | - { |
|
74 | - $arrayOfDates = []; |
|
75 | - foreach ($datetimes as $datetime) { |
|
76 | - if ($datetime instanceof EE_Datetime) { |
|
77 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | - } |
|
79 | - } |
|
80 | - return $arrayOfDates; |
|
81 | - } |
|
62 | + /** |
|
63 | + * @param EE_Datetime[] $datetimes |
|
64 | + * @return array |
|
65 | + * @throws EE_Error |
|
66 | + * @throws InvalidArgumentException |
|
67 | + * @throws InvalidDataTypeException |
|
68 | + * @throws InvalidInterfaceException |
|
69 | + * @throws ReflectionException |
|
70 | + * @since 5.0.0.p |
|
71 | + */ |
|
72 | + public function convertArrayOf(array $datetimes) |
|
73 | + { |
|
74 | + $arrayOfDates = []; |
|
75 | + foreach ($datetimes as $datetime) { |
|
76 | + if ($datetime instanceof EE_Datetime) { |
|
77 | + $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | + } |
|
79 | + } |
|
80 | + return $arrayOfDates; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param EE_Datetime $datetime |
|
86 | - * @return array |
|
87 | - * @throws EE_Error |
|
88 | - * @throws InvalidDataTypeException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @throws InvalidArgumentException |
|
91 | - * @throws ReflectionException |
|
92 | - * @since 5.0.0.p |
|
93 | - */ |
|
94 | - public function convert($datetime) |
|
95 | - { |
|
96 | - return $datetime instanceof EE_Datetime ? [ |
|
97 | - 'DTT_ID' => $datetime->ID(), |
|
98 | - 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | - 'DTT_name' => $datetime->name(), |
|
100 | - 'DTT_description' => $datetime->description(), |
|
101 | - 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | - 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | - 'DTT_sold' => $datetime->sold(), |
|
104 | - 'DTT_reserved' => $datetime->reserved(), |
|
105 | - 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | - 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | - 'DTT_order' => $datetime->order(), |
|
108 | - 'DTT_parent' => $datetime->parent(), |
|
109 | - 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | - ] : []; |
|
111 | - } |
|
84 | + /** |
|
85 | + * @param EE_Datetime $datetime |
|
86 | + * @return array |
|
87 | + * @throws EE_Error |
|
88 | + * @throws InvalidDataTypeException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @throws InvalidArgumentException |
|
91 | + * @throws ReflectionException |
|
92 | + * @since 5.0.0.p |
|
93 | + */ |
|
94 | + public function convert($datetime) |
|
95 | + { |
|
96 | + return $datetime instanceof EE_Datetime ? [ |
|
97 | + 'DTT_ID' => $datetime->ID(), |
|
98 | + 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | + 'DTT_name' => $datetime->name(), |
|
100 | + 'DTT_description' => $datetime->description(), |
|
101 | + 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | + 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | + 'DTT_sold' => $datetime->sold(), |
|
104 | + 'DTT_reserved' => $datetime->reserved(), |
|
105 | + 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | + 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | + 'DTT_order' => $datetime->order(), |
|
108 | + 'DTT_parent' => $datetime->parent(), |
|
109 | + 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | + ] : []; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @param EE_Datetime[] $datetimes |
|
116 | - * @return array |
|
117 | - * @throws EE_Error |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - * @throws ReflectionException |
|
122 | - * @since 5.0.0.p |
|
123 | - */ |
|
124 | - public function encodeArrayOf(array $datetimes) |
|
125 | - { |
|
126 | - $jsonDates = []; |
|
127 | - foreach ($datetimes as $datetime) { |
|
128 | - if ($datetime instanceof EE_Datetime) { |
|
129 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | - } |
|
131 | - } |
|
132 | - return $jsonDates; |
|
133 | - } |
|
114 | + /** |
|
115 | + * @param EE_Datetime[] $datetimes |
|
116 | + * @return array |
|
117 | + * @throws EE_Error |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + * @throws ReflectionException |
|
122 | + * @since 5.0.0.p |
|
123 | + */ |
|
124 | + public function encodeArrayOf(array $datetimes) |
|
125 | + { |
|
126 | + $jsonDates = []; |
|
127 | + foreach ($datetimes as $datetime) { |
|
128 | + if ($datetime instanceof EE_Datetime) { |
|
129 | + $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | + } |
|
131 | + } |
|
132 | + return $jsonDates; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | - /** |
|
137 | - * @param array $datetime_array |
|
138 | - * @return false|string |
|
139 | - * @since 5.0.0.p |
|
140 | - */ |
|
141 | - public function encode(array $datetime_array) |
|
142 | - { |
|
143 | - return wp_json_encode($datetime_array); |
|
144 | - } |
|
136 | + /** |
|
137 | + * @param array $datetime_array |
|
138 | + * @return false|string |
|
139 | + * @since 5.0.0.p |
|
140 | + */ |
|
141 | + public function encode(array $datetime_array) |
|
142 | + { |
|
143 | + return wp_json_encode($datetime_array); |
|
144 | + } |
|
145 | 145 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
118 | 118 | { |
119 | - if (! array_key_exists('limit', $query_params)) { |
|
119 | + if ( ! array_key_exists('limit', $query_params)) { |
|
120 | 120 | $query_params['limit'] = 1; |
121 | 121 | } |
122 | 122 | $result = $this->getApiResults($model, $query_params, $include); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
145 | 145 | { |
146 | - if (! array_key_exists('caps', $query_params)) { |
|
146 | + if ( ! array_key_exists('caps', $query_params)) { |
|
147 | 147 | $query_params['caps'] = EEM_Base::caps_read_admin; |
148 | 148 | } |
149 | - if (! array_key_exists('default_where_conditions', $query_params)) { |
|
149 | + if ( ! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | 150 | $query_params['default_where_conditions'] = 'none'; |
151 | 151 | } |
152 | 152 | /** @type array $results */ |
@@ -49,137 +49,137 @@ |
||
49 | 49 | */ |
50 | 50 | class RestApiSpoofer |
51 | 51 | { |
52 | - /** |
|
53 | - * @var WP_REST_Server $wp_rest_server |
|
54 | - */ |
|
55 | - protected $wp_rest_server; |
|
52 | + /** |
|
53 | + * @var WP_REST_Server $wp_rest_server |
|
54 | + */ |
|
55 | + protected $wp_rest_server; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var Read |
|
59 | - */ |
|
60 | - protected $rest_controller; |
|
57 | + /** |
|
58 | + * @var Read |
|
59 | + */ |
|
60 | + protected $rest_controller; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var EED_Core_Rest_Api $rest_module |
|
64 | - */ |
|
65 | - protected $rest_module; |
|
62 | + /** |
|
63 | + * @var EED_Core_Rest_Api $rest_module |
|
64 | + */ |
|
65 | + protected $rest_module; |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * RestApiSpoofer constructor. |
|
70 | - * |
|
71 | - * @param WP_REST_Server $wp_rest_server |
|
72 | - * @param EED_Core_Rest_Api $rest_module |
|
73 | - * @param Read $rest_api |
|
74 | - * @param string $api_version |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - WP_REST_Server $wp_rest_server, |
|
78 | - EED_Core_Rest_Api $rest_module, |
|
79 | - Read $rest_api, |
|
80 | - $api_version = '4.8.36' |
|
81 | - ) { |
|
82 | - $this->wp_rest_server = $wp_rest_server; |
|
83 | - $this->rest_module = $rest_module; |
|
84 | - $this->rest_controller = $rest_api; |
|
85 | - $this->rest_controller->setRequestedVersion($api_version); |
|
86 | - $this->setUpRestServer(); |
|
87 | - } |
|
68 | + /** |
|
69 | + * RestApiSpoofer constructor. |
|
70 | + * |
|
71 | + * @param WP_REST_Server $wp_rest_server |
|
72 | + * @param EED_Core_Rest_Api $rest_module |
|
73 | + * @param Read $rest_api |
|
74 | + * @param string $api_version |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + WP_REST_Server $wp_rest_server, |
|
78 | + EED_Core_Rest_Api $rest_module, |
|
79 | + Read $rest_api, |
|
80 | + $api_version = '4.8.36' |
|
81 | + ) { |
|
82 | + $this->wp_rest_server = $wp_rest_server; |
|
83 | + $this->rest_module = $rest_module; |
|
84 | + $this->rest_controller = $rest_api; |
|
85 | + $this->rest_controller->setRequestedVersion($api_version); |
|
86 | + $this->setUpRestServer(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - private function setUpRestServer() |
|
91 | - { |
|
92 | - /* @var WP_REST_Server $wp_rest_server */ |
|
93 | - global $wp_rest_server; |
|
94 | - $wp_rest_server = $this->wp_rest_server; |
|
95 | - EED_Core_Rest_Api::set_hooks_both(); |
|
96 | - do_action('rest_api_init', $this->wp_rest_server); |
|
97 | - } |
|
90 | + private function setUpRestServer() |
|
91 | + { |
|
92 | + /* @var WP_REST_Server $wp_rest_server */ |
|
93 | + global $wp_rest_server; |
|
94 | + $wp_rest_server = $this->wp_rest_server; |
|
95 | + EED_Core_Rest_Api::set_hooks_both(); |
|
96 | + do_action('rest_api_init', $this->wp_rest_server); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param EEM_Base $model |
|
101 | - * @param array $query_params |
|
102 | - * @param string $include |
|
103 | - * @return array |
|
104 | - * @throws EE_Error |
|
105 | - * @throws InvalidArgumentException |
|
106 | - * @throws InvalidDataTypeException |
|
107 | - * @throws InvalidInterfaceException |
|
108 | - * @throws ModelConfigurationException |
|
109 | - * @throws ReflectionException |
|
110 | - * @throws RestException |
|
111 | - * @throws RestPasswordIncorrectException |
|
112 | - * @throws RestPasswordRequiredException |
|
113 | - * @throws UnexpectedEntityException |
|
114 | - * @throws DomainException |
|
115 | - * @since 5.0.0.p |
|
116 | - */ |
|
117 | - public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | - { |
|
119 | - if (! array_key_exists('limit', $query_params)) { |
|
120 | - $query_params['limit'] = 1; |
|
121 | - } |
|
122 | - $result = $this->getApiResults($model, $query_params, $include); |
|
123 | - return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | - } |
|
99 | + /** |
|
100 | + * @param EEM_Base $model |
|
101 | + * @param array $query_params |
|
102 | + * @param string $include |
|
103 | + * @return array |
|
104 | + * @throws EE_Error |
|
105 | + * @throws InvalidArgumentException |
|
106 | + * @throws InvalidDataTypeException |
|
107 | + * @throws InvalidInterfaceException |
|
108 | + * @throws ModelConfigurationException |
|
109 | + * @throws ReflectionException |
|
110 | + * @throws RestException |
|
111 | + * @throws RestPasswordIncorrectException |
|
112 | + * @throws RestPasswordRequiredException |
|
113 | + * @throws UnexpectedEntityException |
|
114 | + * @throws DomainException |
|
115 | + * @since 5.0.0.p |
|
116 | + */ |
|
117 | + public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | + { |
|
119 | + if (! array_key_exists('limit', $query_params)) { |
|
120 | + $query_params['limit'] = 1; |
|
121 | + } |
|
122 | + $result = $this->getApiResults($model, $query_params, $include); |
|
123 | + return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param EEM_Base $model |
|
128 | - * @param array $query_params |
|
129 | - * @param string $include |
|
130 | - * @return array |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - * @throws ModelConfigurationException |
|
136 | - * @throws ReflectionException |
|
137 | - * @throws RestException |
|
138 | - * @throws RestPasswordIncorrectException |
|
139 | - * @throws RestPasswordRequiredException |
|
140 | - * @throws UnexpectedEntityException |
|
141 | - * @throws DomainException |
|
142 | - * @since 5.0.0.p |
|
143 | - */ |
|
144 | - public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | - { |
|
146 | - if (! array_key_exists('caps', $query_params)) { |
|
147 | - $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | - } |
|
149 | - if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | - $query_params['default_where_conditions'] = 'none'; |
|
151 | - } |
|
152 | - /** @type array $results */ |
|
153 | - $results = $model->get_all_wpdb_results($query_params); |
|
154 | - $rest_request = new WP_REST_Request(); |
|
155 | - $rest_request->set_param('include', $include); |
|
156 | - $rest_request->set_param('caps', 'edit'); |
|
157 | - $nice_results = array(); |
|
158 | - foreach ($results as $result) { |
|
159 | - $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | - $model, |
|
161 | - $result, |
|
162 | - $rest_request |
|
163 | - ); |
|
164 | - } |
|
165 | - return $nice_results; |
|
166 | - } |
|
126 | + /** |
|
127 | + * @param EEM_Base $model |
|
128 | + * @param array $query_params |
|
129 | + * @param string $include |
|
130 | + * @return array |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + * @throws ModelConfigurationException |
|
136 | + * @throws ReflectionException |
|
137 | + * @throws RestException |
|
138 | + * @throws RestPasswordIncorrectException |
|
139 | + * @throws RestPasswordRequiredException |
|
140 | + * @throws UnexpectedEntityException |
|
141 | + * @throws DomainException |
|
142 | + * @since 5.0.0.p |
|
143 | + */ |
|
144 | + public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | + { |
|
146 | + if (! array_key_exists('caps', $query_params)) { |
|
147 | + $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | + } |
|
149 | + if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | + $query_params['default_where_conditions'] = 'none'; |
|
151 | + } |
|
152 | + /** @type array $results */ |
|
153 | + $results = $model->get_all_wpdb_results($query_params); |
|
154 | + $rest_request = new WP_REST_Request(); |
|
155 | + $rest_request->set_param('include', $include); |
|
156 | + $rest_request->set_param('caps', 'edit'); |
|
157 | + $nice_results = array(); |
|
158 | + foreach ($results as $result) { |
|
159 | + $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | + $model, |
|
161 | + $result, |
|
162 | + $rest_request |
|
163 | + ); |
|
164 | + } |
|
165 | + return $nice_results; |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * @param string $endpoint |
|
171 | - * @return array |
|
172 | - * @throws EE_Error |
|
173 | - * @since 5.0.0.p |
|
174 | - */ |
|
175 | - public function getModelSchema($endpoint) |
|
176 | - { |
|
177 | - $response = $this->wp_rest_server->dispatch( |
|
178 | - new WP_REST_Request( |
|
179 | - 'OPTIONS', |
|
180 | - "/ee/v4.8.36/{$endpoint}" |
|
181 | - ) |
|
182 | - ); |
|
183 | - return $response->get_data(); |
|
184 | - } |
|
169 | + /** |
|
170 | + * @param string $endpoint |
|
171 | + * @return array |
|
172 | + * @throws EE_Error |
|
173 | + * @since 5.0.0.p |
|
174 | + */ |
|
175 | + public function getModelSchema($endpoint) |
|
176 | + { |
|
177 | + $response = $this->wp_rest_server->dispatch( |
|
178 | + new WP_REST_Request( |
|
179 | + 'OPTIONS', |
|
180 | + "/ee/v4.8.36/{$endpoint}" |
|
181 | + ) |
|
182 | + ); |
|
183 | + return $response->get_data(); |
|
184 | + } |
|
185 | 185 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $config = $field->toArray(); |
76 | 76 | if ($field->useForInput()) { |
77 | 77 | // Register input fields for existing mutations. |
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
78 | + register_graphql_field('Update'.$typeName.'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create'.$typeName.'Input', $fieldName, $config); |
|
80 | 80 | } |
81 | 81 | if ($field->useForOutput()) { |
82 | 82 | $config['resolve'] = [$type, 'resolveField']; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | $fieldName = $field->name(); |
103 | 103 | $config = $field->toArray(); |
104 | 104 | if ($field->useForInput()) { |
105 | - $inputFields[ $fieldName ] = $config; |
|
105 | + $inputFields[$fieldName] = $config; |
|
106 | 106 | } |
107 | 107 | if ($field->useForOutput()) { |
108 | 108 | $config['resolve'] = [$type, 'resolveField']; |
109 | - $outputFields[ $fieldName ] = $config; |
|
109 | + $outputFields[$fieldName] = $config; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $typeName = $type->name(); |
113 | - if (! empty($outputFields)) { |
|
113 | + if ( ! empty($outputFields)) { |
|
114 | 114 | // Register the object type. |
115 | 115 | register_graphql_object_type( |
116 | 116 | $typeName, |
@@ -17,110 +17,110 @@ |
||
17 | 17 | */ |
18 | 18 | class TypesManager implements GQLManagerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var TypeCollection|TypeInterface[] $types |
|
22 | - */ |
|
23 | - private $types; |
|
20 | + /** |
|
21 | + * @var TypeCollection|TypeInterface[] $types |
|
22 | + */ |
|
23 | + private $types; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * TypesManager constructor. |
|
28 | - * |
|
29 | - * @param TypeCollection|TypeInterface[] $types |
|
30 | - */ |
|
31 | - public function __construct(TypeCollection $types) |
|
32 | - { |
|
33 | - $this->types = $types; |
|
34 | - } |
|
26 | + /** |
|
27 | + * TypesManager constructor. |
|
28 | + * |
|
29 | + * @param TypeCollection|TypeInterface[] $types |
|
30 | + */ |
|
31 | + public function __construct(TypeCollection $types) |
|
32 | + { |
|
33 | + $this->types = $types; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @throws CollectionDetailsException |
|
39 | - * @throws CollectionLoaderException |
|
40 | - * @since 5.0.0.p |
|
41 | - */ |
|
42 | - public function init() |
|
43 | - { |
|
44 | - $this->types->loadTypes(); |
|
45 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
46 | - } |
|
37 | + /** |
|
38 | + * @throws CollectionDetailsException |
|
39 | + * @throws CollectionLoaderException |
|
40 | + * @since 5.0.0.p |
|
41 | + */ |
|
42 | + public function init() |
|
43 | + { |
|
44 | + $this->types->loadTypes(); |
|
45 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @since 5.0.0.p |
|
51 | - */ |
|
52 | - public function configureTypes() |
|
53 | - { |
|
54 | - // loop through the collection of types and register their fields |
|
55 | - foreach ($this->types as $type) { |
|
56 | - if ($type->isCustomPostType()) { |
|
57 | - $this->extendCustomPostType($type); |
|
58 | - } else { |
|
59 | - $this->registerType($type); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
49 | + /** |
|
50 | + * @since 5.0.0.p |
|
51 | + */ |
|
52 | + public function configureTypes() |
|
53 | + { |
|
54 | + // loop through the collection of types and register their fields |
|
55 | + foreach ($this->types as $type) { |
|
56 | + if ($type->isCustomPostType()) { |
|
57 | + $this->extendCustomPostType($type); |
|
58 | + } else { |
|
59 | + $this->registerType($type); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @param TypeInterface $type |
|
67 | - * @since 5.0.0.p |
|
68 | - */ |
|
69 | - public function extendCustomPostType(TypeInterface $type) |
|
70 | - { |
|
71 | - $typeName = $type->name(); |
|
72 | - foreach ($type->fields() as $field) { |
|
73 | - $fieldName = $field->name(); |
|
74 | - $config = $field->toArray(); |
|
75 | - if ($field->useForInput()) { |
|
76 | - // Register input fields for existing mutations. |
|
77 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
78 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
79 | - } |
|
80 | - if ($field->useForOutput()) { |
|
81 | - $config['resolve'] = [$type, 'resolveField']; |
|
82 | - // Register fields for queries. |
|
83 | - register_graphql_field($typeName, $fieldName, $config); |
|
84 | - } |
|
85 | - } |
|
86 | - if (is_callable([$type, 'extendMutations'])) { |
|
87 | - $type->extendMutations(); |
|
88 | - } |
|
89 | - } |
|
65 | + /** |
|
66 | + * @param TypeInterface $type |
|
67 | + * @since 5.0.0.p |
|
68 | + */ |
|
69 | + public function extendCustomPostType(TypeInterface $type) |
|
70 | + { |
|
71 | + $typeName = $type->name(); |
|
72 | + foreach ($type->fields() as $field) { |
|
73 | + $fieldName = $field->name(); |
|
74 | + $config = $field->toArray(); |
|
75 | + if ($field->useForInput()) { |
|
76 | + // Register input fields for existing mutations. |
|
77 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
78 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
79 | + } |
|
80 | + if ($field->useForOutput()) { |
|
81 | + $config['resolve'] = [$type, 'resolveField']; |
|
82 | + // Register fields for queries. |
|
83 | + register_graphql_field($typeName, $fieldName, $config); |
|
84 | + } |
|
85 | + } |
|
86 | + if (is_callable([$type, 'extendMutations'])) { |
|
87 | + $type->extendMutations(); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @param TypeInterface $type |
|
94 | - * @since 5.0.0.p |
|
95 | - */ |
|
96 | - public function registerType(TypeInterface $type) |
|
97 | - { |
|
98 | - $outputFields = []; |
|
99 | - $inputFields = []; |
|
100 | - foreach ($type->fields() as $field) { |
|
101 | - $fieldName = $field->name(); |
|
102 | - $config = $field->toArray(); |
|
103 | - if ($field->useForInput()) { |
|
104 | - $inputFields[ $fieldName ] = $config; |
|
105 | - } |
|
106 | - if ($field->useForOutput()) { |
|
107 | - $config['resolve'] = [$type, 'resolveField']; |
|
108 | - $outputFields[ $fieldName ] = $config; |
|
109 | - } |
|
110 | - } |
|
111 | - $typeName = $type->name(); |
|
112 | - if (! empty($outputFields)) { |
|
113 | - // Register the object type. |
|
114 | - register_graphql_object_type( |
|
115 | - $typeName, |
|
116 | - [ |
|
117 | - 'description' => $type->description(), |
|
118 | - 'fields' => $outputFields, |
|
119 | - ] |
|
120 | - ); |
|
121 | - } |
|
122 | - if (is_callable([$type, 'registerMutations'])) { |
|
123 | - $type->registerMutations($inputFields); |
|
124 | - } |
|
125 | - } |
|
92 | + /** |
|
93 | + * @param TypeInterface $type |
|
94 | + * @since 5.0.0.p |
|
95 | + */ |
|
96 | + public function registerType(TypeInterface $type) |
|
97 | + { |
|
98 | + $outputFields = []; |
|
99 | + $inputFields = []; |
|
100 | + foreach ($type->fields() as $field) { |
|
101 | + $fieldName = $field->name(); |
|
102 | + $config = $field->toArray(); |
|
103 | + if ($field->useForInput()) { |
|
104 | + $inputFields[ $fieldName ] = $config; |
|
105 | + } |
|
106 | + if ($field->useForOutput()) { |
|
107 | + $config['resolve'] = [$type, 'resolveField']; |
|
108 | + $outputFields[ $fieldName ] = $config; |
|
109 | + } |
|
110 | + } |
|
111 | + $typeName = $type->name(); |
|
112 | + if (! empty($outputFields)) { |
|
113 | + // Register the object type. |
|
114 | + register_graphql_object_type( |
|
115 | + $typeName, |
|
116 | + [ |
|
117 | + 'description' => $type->description(), |
|
118 | + 'fields' => $outputFields, |
|
119 | + ] |
|
120 | + ); |
|
121 | + } |
|
122 | + if (is_callable([$type, 'registerMutations'])) { |
|
123 | + $type->registerMutations($inputFields); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class ResolverCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * ResolverCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | - ResolverCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ResolverCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | + ResolverCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since 5.0.0.p |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - ResolverCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since 5.0.0.p |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + ResolverCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since 5.0.0.p |
|
82 | - */ |
|
83 | - public function loadResolvers() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since 5.0.0.p |
|
82 | + */ |
|
83 | + public function loadResolvers() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class EnumCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * EnumCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | - EnumCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * EnumCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | + EnumCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since 5.0.0.p |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - EnumCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\enums'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since 5.0.0.p |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + EnumCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\enums'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since 5.0.0.p |
|
82 | - */ |
|
83 | - public function loadEnums() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since 5.0.0.p |
|
82 | + */ |
|
83 | + public function loadEnums() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |