@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $job_response = $job_handler->createJob($this->_job_parameters); |
118 | 118 | $this->validateResponse('createJob', $this->_job_id, $job_response); |
119 | 119 | $success = $this->_job_parameters->save(); |
120 | - if (! $success) { |
|
120 | + if ( ! $success) { |
|
121 | 121 | throw new BatchRequestException( |
122 | 122 | sprintf( |
123 | 123 | esc_html__( |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | array $request_data = [] |
216 | 216 | ): JobHandlerInterface { |
217 | 217 | |
218 | - if (! class_exists($classname)) { |
|
218 | + if ( ! class_exists($classname)) { |
|
219 | 219 | throw new BatchRequestException( |
220 | 220 | sprintf( |
221 | 221 | esc_html__( |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ); |
228 | 228 | } |
229 | 229 | $job_handler = $this->loader->getNew($classname); |
230 | - if (! $job_handler instanceof JobHandlerInterface) { |
|
230 | + if ( ! $job_handler instanceof JobHandlerInterface) { |
|
231 | 231 | throw new BatchRequestException( |
232 | 232 | sprintf( |
233 | 233 | esc_html__( |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function _get_error_response(Exception $exception, string $method_name): JobStepResponse |
257 | 257 | { |
258 | - if (! $this->_job_parameters instanceof JobParameters) { |
|
258 | + if ( ! $this->_job_parameters instanceof JobParameters) { |
|
259 | 259 | $this->_job_parameters = new JobParameters($this->_job_id, esc_html__('__Unknown__', 'event_espresso'), []); |
260 | 260 | } |
261 | 261 | $this->_job_parameters->set_status(JobParameters::status_error); |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | ), |
268 | 268 | '<h4>', |
269 | 269 | get_class($exception), |
270 | - '<code>' . 'BatchRunner::' . $method_name . '()</code>', |
|
271 | - '</h4><p>' . $exception->getMessage() . '</p>', |
|
272 | - '<pre>' . $exception->getTraceAsString() . '</pre>' |
|
270 | + '<code>'.'BatchRunner::'.$method_name.'()</code>', |
|
271 | + '</h4><p>'.$exception->getMessage().'</p>', |
|
272 | + '<pre>'.$exception->getTraceAsString().'</pre>' |
|
273 | 273 | ); |
274 | 274 | return new JobStepResponse( |
275 | 275 | $this->_job_parameters, |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | private function validateResponse(string $function, string $job_id, $job_response) |
289 | 289 | { |
290 | - if (! $job_response instanceof JobStepResponse) { |
|
290 | + if ( ! $job_response instanceof JobStepResponse) { |
|
291 | 291 | throw new BatchRequestException( |
292 | 292 | sprintf( |
293 | 293 | esc_html__( |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function load(string $job_id): JobParameters |
193 | 193 | { |
194 | - $job_record = new JobParametersWordPressOption(JobParameters::wp_option_prefix . $job_id); |
|
194 | + $job_record = new JobParametersWordPressOption(JobParameters::wp_option_prefix.$job_id); |
|
195 | 195 | $job_parameter_vars = $job_record->loadOption(); |
196 | 196 | if ( |
197 | 197 | ! is_array($job_parameter_vars) |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'event_espresso' |
206 | 206 | ), |
207 | 207 | $job_id, |
208 | - JobParameters::wp_option_prefix . $job_id |
|
208 | + JobParameters::wp_option_prefix.$job_id |
|
209 | 209 | ) |
210 | 210 | ); |
211 | 211 | } |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function request_datum(string $key, $default = '') |
267 | 267 | { |
268 | - if (isset($this->_request_data[ $key ])) { |
|
269 | - return $this->_request_data[ $key ]; |
|
268 | + if (isset($this->_request_data[$key])) { |
|
269 | + return $this->_request_data[$key]; |
|
270 | 270 | } |
271 | 271 | return $default; |
272 | 272 | } |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function extra_datum(string $key, $default = '') |
283 | 283 | { |
284 | - if (isset($this->_extra_data[ $key ])) { |
|
285 | - return $this->_extra_data[ $key ]; |
|
284 | + if (isset($this->_extra_data[$key])) { |
|
285 | + return $this->_extra_data[$key]; |
|
286 | 286 | } |
287 | 287 | return $default; |
288 | 288 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function add_extra_data(string $key, $value) |
298 | 298 | { |
299 | - $this->_extra_data[ $key ] = $value; |
|
299 | + $this->_extra_data[$key] = $value; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function option_name(): string |
421 | 421 | { |
422 | - return JobParameters::wp_option_prefix . $this->job_id(); |
|
422 | + return JobParameters::wp_option_prefix.$this->job_id(); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | if (empty($this->_update_text)) { |
69 | 69 | return ''; |
70 | 70 | } |
71 | - $text = implode( "</p><p class='ee-batch-job-update'>", $this->_update_text); |
|
71 | + $text = implode("</p><p class='ee-batch-job-update'>", $this->_update_text); |
|
72 | 72 | return "<p class='ee-batch-job-update'>$text</p>"; |
73 | 73 | } |
74 | 74 |
@@ -23,471 +23,471 @@ |
||
23 | 23 | |
24 | 24 | class DatetimeOffsetFix extends JobHandler |
25 | 25 | { |
26 | - /** |
|
27 | - * Key for the option used to track which models have been processed when doing the batches. |
|
28 | - */ |
|
29 | - const MODELS_TO_PROCESS_OPTION_KEY = 'ee_models_processed_for_datetime_offset_fix'; |
|
30 | - |
|
31 | - |
|
32 | - const COUNT_OF_MODELS_PROCESSED = 'ee_count_of_ee_models_processed_for_datetime_offset_fixed'; |
|
33 | - |
|
34 | - /** |
|
35 | - * Key for the option used to track what the current offset is that will be applied when this tool is executed. |
|
36 | - */ |
|
37 | - const OFFSET_TO_APPLY_OPTION_KEY = 'ee_datetime_offset_fix_offset_to_apply'; |
|
38 | - |
|
39 | - |
|
40 | - const OPTION_KEY_OFFSET_RANGE_START_DATE = 'ee_datetime_offset_start_date_range'; |
|
41 | - |
|
42 | - |
|
43 | - const OPTION_KEY_OFFSET_RANGE_END_DATE = 'ee_datetime_offset_end_date_range'; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * String labelling the datetime offset fix type for change-log entries. |
|
48 | - */ |
|
49 | - const DATETIME_OFFSET_FIX_CHANGELOG_TYPE = 'datetime_offset_fix'; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * String labelling a datetime offset fix error for change-log entries. |
|
54 | - */ |
|
55 | - const DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE = 'datetime_offset_fix_error'; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var EEM_Base[] |
|
59 | - */ |
|
60 | - protected $models_with_datetime_fields = array(); |
|
61 | - |
|
62 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | - |
|
64 | - /** |
|
65 | - * Performs any necessary setup for starting the job. This is also a good |
|
66 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
67 | - * when continue_job will be called |
|
68 | - * |
|
69 | - * @param JobParameters $job_parameters |
|
70 | - * @return JobStepResponse |
|
71 | - * @throws EE_Error |
|
72 | - * @throws InvalidArgumentException |
|
73 | - * @throws InvalidDataTypeException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - */ |
|
76 | - public function create_job(JobParameters $job_parameters) |
|
77 | - { |
|
78 | - $models_with_datetime_fields = $this->getModelsWithDatetimeFields(); |
|
79 | - // we'll be doing each model as a batch. |
|
80 | - $job_parameters->set_job_size(count($models_with_datetime_fields)); |
|
81 | - return new JobStepResponse( |
|
82 | - $job_parameters, |
|
83 | - esc_html__('Starting Datetime Offset Fix', 'event_espresso') |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Performs another step of the job |
|
89 | - * |
|
90 | - * @param JobParameters $job_parameters |
|
91 | - * @param int $batch_size |
|
92 | - * @return JobStepResponse |
|
93 | - * @throws EE_Error |
|
94 | - * @throws InvalidArgumentException |
|
95 | - * @throws InvalidDataTypeException |
|
96 | - * @throws InvalidInterfaceException |
|
97 | - */ |
|
98 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
99 | - { |
|
100 | - $models_to_process = $this->getModelsWithDatetimeFields(); |
|
101 | - // let's pop off the a model and do the query to apply the offset. |
|
102 | - $model_to_process = array_pop($models_to_process); |
|
103 | - // update our record |
|
104 | - $this->setModelsToProcess($models_to_process); |
|
105 | - $this->processModel($model_to_process); |
|
106 | - $this->updateCountOfModelsProcessed(); |
|
107 | - $job_parameters->set_units_processed($this->getCountOfModelsProcessed()); |
|
108 | - if (count($models_to_process) > 0) { |
|
109 | - $job_parameters->set_status(JobParameters::status_continue); |
|
110 | - } else { |
|
111 | - $job_parameters->set_status(JobParameters::status_complete); |
|
112 | - } |
|
113 | - return new JobStepResponse( |
|
114 | - $job_parameters, |
|
115 | - sprintf( |
|
116 | - esc_html__('Updated the offset for all datetime fields on the %s model.', 'event_espresso'), |
|
117 | - $model_to_process |
|
118 | - ) |
|
119 | - ); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Performs any clean-up logic when we know the job is completed |
|
124 | - * |
|
125 | - * @param JobParameters $job_parameters |
|
126 | - * @return JobStepResponse |
|
127 | - * @throws BatchRequestException |
|
128 | - */ |
|
129 | - public function cleanup_job(JobParameters $job_parameters) |
|
130 | - { |
|
131 | - // delete important saved options. |
|
132 | - delete_option(self::MODELS_TO_PROCESS_OPTION_KEY); |
|
133 | - delete_option(self::COUNT_OF_MODELS_PROCESSED); |
|
134 | - delete_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE); |
|
135 | - delete_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE); |
|
136 | - return new JobStepResponse($job_parameters, esc_html__( |
|
137 | - 'Offset has been applied to all affected fields.', |
|
138 | - 'event_espresso' |
|
139 | - )); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * Contains the logic for processing a model and applying the datetime offset to affected fields on that model. |
|
145 | - * |
|
146 | - * @param string $model_class_name |
|
147 | - * @throws EE_Error |
|
148 | - */ |
|
149 | - protected function processModel($model_class_name) |
|
150 | - { |
|
151 | - global $wpdb; |
|
152 | - /** @var EEM_Base $model */ |
|
153 | - $model = $model_class_name::instance(); |
|
154 | - $original_offset = self::getOffset(); |
|
155 | - $start_date_range = self::getStartDateRange(); |
|
156 | - $end_date_range = self::getEndDateRange(); |
|
157 | - $sql_date_function = $original_offset > 0 ? 'DATE_ADD' : 'DATE_SUB'; |
|
158 | - $offset = abs($original_offset) * 60; |
|
159 | - $date_ranges = array(); |
|
160 | - // since some affected models might have two tables, we have to get our tables and set up a query for each table. |
|
161 | - foreach ($model->get_tables() as $table) { |
|
162 | - $query = 'UPDATE ' . $table->get_table_name(); |
|
163 | - $fields_affected = array(); |
|
164 | - $inner_query = array(); |
|
165 | - foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) { |
|
166 | - if ($model_field instanceof EE_Datetime_Field) { |
|
167 | - $inner_query[ $model_field->get_table_column() ] = $model_field->get_table_column() . ' = ' |
|
168 | - . $sql_date_function . '(' |
|
169 | - . $model_field->get_table_column() |
|
170 | - . ", INTERVAL {$offset} MINUTE)"; |
|
171 | - $fields_affected[] = $model_field; |
|
172 | - } |
|
173 | - } |
|
174 | - if (! $fields_affected) { |
|
175 | - continue; |
|
176 | - } |
|
177 | - // do we do one query per column/field or one query for all fields on the model? It all depends on whether |
|
178 | - // there is a date range applied or not. |
|
179 | - if ($start_date_range instanceof DbSafeDateTime || $end_date_range instanceof DbSafeDateTime) { |
|
180 | - $result = $this->doQueryForEachField($query, $inner_query, $start_date_range, $end_date_range); |
|
181 | - } else { |
|
182 | - $result = $this->doQueryForAllFields($query, $inner_query); |
|
183 | - } |
|
184 | - |
|
185 | - // record appropriate logs for the query |
|
186 | - switch (true) { |
|
187 | - case $result === false: |
|
188 | - // record error. |
|
189 | - $error_message = $wpdb->last_error; |
|
190 | - // handle the edge cases where last_error might be empty. |
|
191 | - if (! $error_message) { |
|
192 | - $error_message = esc_html__('Unknown mysql error occurred.', 'event_espresso'); |
|
193 | - } |
|
194 | - $this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message); |
|
195 | - break; |
|
196 | - case is_array($result) && ! empty($result): |
|
197 | - foreach ($result as $field_name => $error_message) { |
|
198 | - $this->recordChangeLog($model, $original_offset, $table, array($field_name), $error_message); |
|
199 | - } |
|
200 | - break; |
|
201 | - default: |
|
202 | - $this->recordChangeLog($model, $original_offset, $table, $fields_affected); |
|
203 | - } |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * Does the query on each $inner_query individually. |
|
210 | - * |
|
211 | - * @param string $query |
|
212 | - * @param array $inner_query |
|
213 | - * @param DbSafeDateTime|null $start_date_range |
|
214 | - * @param DbSafeDateTime|null $end_date_range |
|
215 | - * @return array An array of any errors encountered and the fields they were for. |
|
216 | - */ |
|
217 | - private function doQueryForEachField($query, array $inner_query, $start_date_range, $end_date_range) |
|
218 | - { |
|
219 | - global $wpdb; |
|
220 | - $errors = array(); |
|
221 | - foreach ($inner_query as $field_name => $field_query) { |
|
222 | - $query_to_run = $query; |
|
223 | - $where_conditions = array(); |
|
224 | - $query_to_run .= ' SET ' . $field_query; |
|
225 | - if ($start_date_range instanceof DbSafeDateTime) { |
|
226 | - $start_date = $start_date_range->format(EE_Datetime_Field::mysql_timestamp_format); |
|
227 | - $where_conditions[] = "{$field_name} > '{$start_date}'"; |
|
228 | - } |
|
229 | - if ($end_date_range instanceof DbSafeDateTime) { |
|
230 | - $end_date = $end_date_range->format(EE_Datetime_Field::mysql_timestamp_format); |
|
231 | - $where_conditions[] = "{$field_name} < '{$end_date}'"; |
|
232 | - } |
|
233 | - if ($where_conditions) { |
|
234 | - $query_to_run .= ' WHERE ' . implode(' AND ', $where_conditions); |
|
235 | - } |
|
236 | - $result = $wpdb->query($query_to_run); |
|
237 | - if ($result === false) { |
|
238 | - // record error. |
|
239 | - $error_message = $wpdb->last_error; |
|
240 | - // handle the edgecases where last_error might be empty. |
|
241 | - if (! $error_message) { |
|
242 | - $error_message = esc_html__('Unknown mysql error occured.', 'event_espresso'); |
|
243 | - } |
|
244 | - $errors[ $field_name ] = $error_message; |
|
245 | - } |
|
246 | - } |
|
247 | - return $errors; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * Performs the query for all fields within the inner_query |
|
253 | - * |
|
254 | - * @param string $query |
|
255 | - * @param array $inner_query |
|
256 | - * @return false|int |
|
257 | - */ |
|
258 | - private function doQueryForAllFields($query, array $inner_query) |
|
259 | - { |
|
260 | - global $wpdb; |
|
261 | - $query .= ' SET ' . implode(',', $inner_query); |
|
262 | - return $wpdb->query($query); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * Records a changelog entry using the given information. |
|
268 | - * |
|
269 | - * @param EEM_Base $model |
|
270 | - * @param float $offset |
|
271 | - * @param EE_Table_Base $table |
|
272 | - * @param EE_Model_Field_Base[] $model_fields_affected |
|
273 | - * @param string $error_message If present then there was an error so let's record that instead. |
|
274 | - * @throws EE_Error |
|
275 | - */ |
|
276 | - private function recordChangeLog( |
|
277 | - EEM_Base $model, |
|
278 | - $offset, |
|
279 | - EE_Table_Base $table, |
|
280 | - $model_fields_affected, |
|
281 | - $error_message = '' |
|
282 | - ) { |
|
283 | - // setup $fields list. |
|
284 | - $fields = array(); |
|
285 | - /** @var EE_Datetime_Field $model_field */ |
|
286 | - foreach ($model_fields_affected as $model_field) { |
|
287 | - if (! $model_field instanceof EE_Datetime_Field) { |
|
288 | - continue; |
|
289 | - } |
|
290 | - $fields[] = $model_field->get_name(); |
|
291 | - } |
|
292 | - // setup the message for the changelog entry. |
|
293 | - $message = $error_message |
|
294 | - ? sprintf( |
|
295 | - esc_html__( |
|
296 | - 'The %1$s table for the %2$s model did not have the offset of %3$f applied to its fields (%4$s), because of the following error:%5$s', |
|
297 | - 'event_espresso' |
|
298 | - ), |
|
299 | - $table->get_table_name(), |
|
300 | - $model->get_this_model_name(), |
|
301 | - $offset, |
|
302 | - implode(',', $fields), |
|
303 | - $error_message |
|
304 | - ) |
|
305 | - : sprintf( |
|
306 | - esc_html__( |
|
307 | - 'The %1$s table for the %2$s model has had the offset of %3$f applied to its following fields: %4$s', |
|
308 | - 'event_espresso' |
|
309 | - ), |
|
310 | - $table->get_table_name(), |
|
311 | - $model->get_this_model_name(), |
|
312 | - $offset, |
|
313 | - implode(',', $fields) |
|
314 | - ); |
|
315 | - // write to the log |
|
316 | - $changelog = EE_Change_Log::new_instance(array( |
|
317 | - 'LOG_type' => $error_message |
|
318 | - ? self::DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE |
|
319 | - : self::DATETIME_OFFSET_FIX_CHANGELOG_TYPE, |
|
320 | - 'LOG_message' => $message, |
|
321 | - )); |
|
322 | - $changelog->save(); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * Returns an array of models that have datetime fields. |
|
328 | - * This array is added to a short lived transient cache to keep having to build this list to a minimum. |
|
329 | - * |
|
330 | - * @return array an array of model class names. |
|
331 | - * @throws EE_Error |
|
332 | - * @throws InvalidDataTypeException |
|
333 | - * @throws InvalidInterfaceException |
|
334 | - * @throws InvalidArgumentException |
|
335 | - */ |
|
336 | - private function getModelsWithDatetimeFields() |
|
337 | - { |
|
338 | - $this->getModelsToProcess(); |
|
339 | - if (! empty($this->models_with_datetime_fields)) { |
|
340 | - return $this->models_with_datetime_fields; |
|
341 | - } |
|
342 | - |
|
343 | - $all_non_abstract_models = EE_Registry::instance()->non_abstract_db_models; |
|
344 | - foreach ($all_non_abstract_models as $non_abstract_model) { |
|
345 | - // get model instance |
|
346 | - /** @var EEM_Base $non_abstract_model */ |
|
347 | - $non_abstract_model = $non_abstract_model::instance(); |
|
348 | - if ($non_abstract_model->get_a_field_of_type('EE_Datetime_Field') instanceof EE_Datetime_Field) { |
|
349 | - $this->models_with_datetime_fields[] = get_class($non_abstract_model); |
|
350 | - } |
|
351 | - } |
|
352 | - $this->setModelsToProcess($this->models_with_datetime_fields); |
|
353 | - return $this->models_with_datetime_fields; |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * This simply records the models that have been processed with our tracking option. |
|
359 | - * |
|
360 | - * @param array $models_to_set array of model class names. |
|
361 | - */ |
|
362 | - private function setModelsToProcess($models_to_set) |
|
363 | - { |
|
364 | - update_option(self::MODELS_TO_PROCESS_OPTION_KEY, $models_to_set); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * Used to keep track of how many models have been processed for the batch |
|
370 | - * |
|
371 | - * @param $count |
|
372 | - */ |
|
373 | - private function updateCountOfModelsProcessed($count = 1) |
|
374 | - { |
|
375 | - $count = $this->getCountOfModelsProcessed() + (int) $count; |
|
376 | - update_option(self::COUNT_OF_MODELS_PROCESSED, $count); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * Retrieve the tracked number of models processed between requests. |
|
382 | - * |
|
383 | - * @return int |
|
384 | - */ |
|
385 | - private function getCountOfModelsProcessed() |
|
386 | - { |
|
387 | - return (int) get_option(self::COUNT_OF_MODELS_PROCESSED, 0); |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Returns the models that are left to process. |
|
393 | - * |
|
394 | - * @return array an array of model class names. |
|
395 | - */ |
|
396 | - private function getModelsToProcess() |
|
397 | - { |
|
398 | - if (empty($this->models_with_datetime_fields)) { |
|
399 | - $this->models_with_datetime_fields = get_option(self::MODELS_TO_PROCESS_OPTION_KEY, array()); |
|
400 | - } |
|
401 | - return $this->models_with_datetime_fields; |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * Used to record the offset that will be applied to dates and times for EE_Datetime_Field columns. |
|
407 | - * |
|
408 | - * @param float $offset |
|
409 | - */ |
|
410 | - public static function updateOffset($offset) |
|
411 | - { |
|
412 | - update_option(self::OFFSET_TO_APPLY_OPTION_KEY, $offset); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * Used to retrieve the saved offset that will be applied to dates and times for EE_Datetime_Field columns. |
|
418 | - * |
|
419 | - * @return float |
|
420 | - */ |
|
421 | - public static function getOffset() |
|
422 | - { |
|
423 | - return (float) get_option(self::OFFSET_TO_APPLY_OPTION_KEY, 0); |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * Used to set the saved offset range start date. |
|
429 | - * |
|
430 | - * @param DbSafeDateTime|null $start_date |
|
431 | - */ |
|
432 | - public static function updateStartDateRange(DbSafeDateTime $start_date = null) |
|
433 | - { |
|
434 | - $date_to_save = $start_date instanceof DbSafeDateTime |
|
435 | - ? $start_date->format('U') |
|
436 | - : ''; |
|
437 | - update_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE, $date_to_save); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * Used to get the saved offset range start date. |
|
443 | - * |
|
444 | - * @return DbSafeDateTime|null |
|
445 | - */ |
|
446 | - public static function getStartDateRange() |
|
447 | - { |
|
448 | - $start_date = get_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE, null); |
|
449 | - try { |
|
450 | - $datetime = DateTime::createFromFormat('U', $start_date, new DateTimeZone('UTC')); |
|
451 | - $start_date = $datetime instanceof DateTime |
|
452 | - ? DbSafeDateTime::createFromDateTime($datetime) |
|
453 | - : null; |
|
454 | - } catch (Exception $e) { |
|
455 | - $start_date = null; |
|
456 | - } |
|
457 | - return $start_date; |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * Used to set the saved offset range end date. |
|
463 | - * |
|
464 | - * @param DbSafeDateTime|null $end_date |
|
465 | - */ |
|
466 | - public static function updateEndDateRange(DbSafeDateTime $end_date = null) |
|
467 | - { |
|
468 | - $date_to_save = $end_date instanceof DbSafeDateTime |
|
469 | - ? $end_date->format('U') |
|
470 | - : ''; |
|
471 | - update_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE, $date_to_save); |
|
472 | - } |
|
473 | - |
|
474 | - |
|
475 | - /** |
|
476 | - * Used to get the saved offset range end date. |
|
477 | - * |
|
478 | - * @return DbSafeDateTime|null |
|
479 | - */ |
|
480 | - public static function getEndDateRange() |
|
481 | - { |
|
482 | - $end_date = get_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE, null); |
|
483 | - try { |
|
484 | - $datetime = DateTime::createFromFormat('U', $end_date, new DateTimeZone('UTC')); |
|
485 | - $end_date = $datetime instanceof Datetime |
|
486 | - ? DbSafeDateTime::createFromDateTime($datetime) |
|
487 | - : null; |
|
488 | - } catch (Exception $e) { |
|
489 | - $end_date = null; |
|
490 | - } |
|
491 | - return $end_date; |
|
492 | - } |
|
26 | + /** |
|
27 | + * Key for the option used to track which models have been processed when doing the batches. |
|
28 | + */ |
|
29 | + const MODELS_TO_PROCESS_OPTION_KEY = 'ee_models_processed_for_datetime_offset_fix'; |
|
30 | + |
|
31 | + |
|
32 | + const COUNT_OF_MODELS_PROCESSED = 'ee_count_of_ee_models_processed_for_datetime_offset_fixed'; |
|
33 | + |
|
34 | + /** |
|
35 | + * Key for the option used to track what the current offset is that will be applied when this tool is executed. |
|
36 | + */ |
|
37 | + const OFFSET_TO_APPLY_OPTION_KEY = 'ee_datetime_offset_fix_offset_to_apply'; |
|
38 | + |
|
39 | + |
|
40 | + const OPTION_KEY_OFFSET_RANGE_START_DATE = 'ee_datetime_offset_start_date_range'; |
|
41 | + |
|
42 | + |
|
43 | + const OPTION_KEY_OFFSET_RANGE_END_DATE = 'ee_datetime_offset_end_date_range'; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * String labelling the datetime offset fix type for change-log entries. |
|
48 | + */ |
|
49 | + const DATETIME_OFFSET_FIX_CHANGELOG_TYPE = 'datetime_offset_fix'; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * String labelling a datetime offset fix error for change-log entries. |
|
54 | + */ |
|
55 | + const DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE = 'datetime_offset_fix_error'; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var EEM_Base[] |
|
59 | + */ |
|
60 | + protected $models_with_datetime_fields = array(); |
|
61 | + |
|
62 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | + |
|
64 | + /** |
|
65 | + * Performs any necessary setup for starting the job. This is also a good |
|
66 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
67 | + * when continue_job will be called |
|
68 | + * |
|
69 | + * @param JobParameters $job_parameters |
|
70 | + * @return JobStepResponse |
|
71 | + * @throws EE_Error |
|
72 | + * @throws InvalidArgumentException |
|
73 | + * @throws InvalidDataTypeException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + */ |
|
76 | + public function create_job(JobParameters $job_parameters) |
|
77 | + { |
|
78 | + $models_with_datetime_fields = $this->getModelsWithDatetimeFields(); |
|
79 | + // we'll be doing each model as a batch. |
|
80 | + $job_parameters->set_job_size(count($models_with_datetime_fields)); |
|
81 | + return new JobStepResponse( |
|
82 | + $job_parameters, |
|
83 | + esc_html__('Starting Datetime Offset Fix', 'event_espresso') |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Performs another step of the job |
|
89 | + * |
|
90 | + * @param JobParameters $job_parameters |
|
91 | + * @param int $batch_size |
|
92 | + * @return JobStepResponse |
|
93 | + * @throws EE_Error |
|
94 | + * @throws InvalidArgumentException |
|
95 | + * @throws InvalidDataTypeException |
|
96 | + * @throws InvalidInterfaceException |
|
97 | + */ |
|
98 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
99 | + { |
|
100 | + $models_to_process = $this->getModelsWithDatetimeFields(); |
|
101 | + // let's pop off the a model and do the query to apply the offset. |
|
102 | + $model_to_process = array_pop($models_to_process); |
|
103 | + // update our record |
|
104 | + $this->setModelsToProcess($models_to_process); |
|
105 | + $this->processModel($model_to_process); |
|
106 | + $this->updateCountOfModelsProcessed(); |
|
107 | + $job_parameters->set_units_processed($this->getCountOfModelsProcessed()); |
|
108 | + if (count($models_to_process) > 0) { |
|
109 | + $job_parameters->set_status(JobParameters::status_continue); |
|
110 | + } else { |
|
111 | + $job_parameters->set_status(JobParameters::status_complete); |
|
112 | + } |
|
113 | + return new JobStepResponse( |
|
114 | + $job_parameters, |
|
115 | + sprintf( |
|
116 | + esc_html__('Updated the offset for all datetime fields on the %s model.', 'event_espresso'), |
|
117 | + $model_to_process |
|
118 | + ) |
|
119 | + ); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Performs any clean-up logic when we know the job is completed |
|
124 | + * |
|
125 | + * @param JobParameters $job_parameters |
|
126 | + * @return JobStepResponse |
|
127 | + * @throws BatchRequestException |
|
128 | + */ |
|
129 | + public function cleanup_job(JobParameters $job_parameters) |
|
130 | + { |
|
131 | + // delete important saved options. |
|
132 | + delete_option(self::MODELS_TO_PROCESS_OPTION_KEY); |
|
133 | + delete_option(self::COUNT_OF_MODELS_PROCESSED); |
|
134 | + delete_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE); |
|
135 | + delete_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE); |
|
136 | + return new JobStepResponse($job_parameters, esc_html__( |
|
137 | + 'Offset has been applied to all affected fields.', |
|
138 | + 'event_espresso' |
|
139 | + )); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * Contains the logic for processing a model and applying the datetime offset to affected fields on that model. |
|
145 | + * |
|
146 | + * @param string $model_class_name |
|
147 | + * @throws EE_Error |
|
148 | + */ |
|
149 | + protected function processModel($model_class_name) |
|
150 | + { |
|
151 | + global $wpdb; |
|
152 | + /** @var EEM_Base $model */ |
|
153 | + $model = $model_class_name::instance(); |
|
154 | + $original_offset = self::getOffset(); |
|
155 | + $start_date_range = self::getStartDateRange(); |
|
156 | + $end_date_range = self::getEndDateRange(); |
|
157 | + $sql_date_function = $original_offset > 0 ? 'DATE_ADD' : 'DATE_SUB'; |
|
158 | + $offset = abs($original_offset) * 60; |
|
159 | + $date_ranges = array(); |
|
160 | + // since some affected models might have two tables, we have to get our tables and set up a query for each table. |
|
161 | + foreach ($model->get_tables() as $table) { |
|
162 | + $query = 'UPDATE ' . $table->get_table_name(); |
|
163 | + $fields_affected = array(); |
|
164 | + $inner_query = array(); |
|
165 | + foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) { |
|
166 | + if ($model_field instanceof EE_Datetime_Field) { |
|
167 | + $inner_query[ $model_field->get_table_column() ] = $model_field->get_table_column() . ' = ' |
|
168 | + . $sql_date_function . '(' |
|
169 | + . $model_field->get_table_column() |
|
170 | + . ", INTERVAL {$offset} MINUTE)"; |
|
171 | + $fields_affected[] = $model_field; |
|
172 | + } |
|
173 | + } |
|
174 | + if (! $fields_affected) { |
|
175 | + continue; |
|
176 | + } |
|
177 | + // do we do one query per column/field or one query for all fields on the model? It all depends on whether |
|
178 | + // there is a date range applied or not. |
|
179 | + if ($start_date_range instanceof DbSafeDateTime || $end_date_range instanceof DbSafeDateTime) { |
|
180 | + $result = $this->doQueryForEachField($query, $inner_query, $start_date_range, $end_date_range); |
|
181 | + } else { |
|
182 | + $result = $this->doQueryForAllFields($query, $inner_query); |
|
183 | + } |
|
184 | + |
|
185 | + // record appropriate logs for the query |
|
186 | + switch (true) { |
|
187 | + case $result === false: |
|
188 | + // record error. |
|
189 | + $error_message = $wpdb->last_error; |
|
190 | + // handle the edge cases where last_error might be empty. |
|
191 | + if (! $error_message) { |
|
192 | + $error_message = esc_html__('Unknown mysql error occurred.', 'event_espresso'); |
|
193 | + } |
|
194 | + $this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message); |
|
195 | + break; |
|
196 | + case is_array($result) && ! empty($result): |
|
197 | + foreach ($result as $field_name => $error_message) { |
|
198 | + $this->recordChangeLog($model, $original_offset, $table, array($field_name), $error_message); |
|
199 | + } |
|
200 | + break; |
|
201 | + default: |
|
202 | + $this->recordChangeLog($model, $original_offset, $table, $fields_affected); |
|
203 | + } |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * Does the query on each $inner_query individually. |
|
210 | + * |
|
211 | + * @param string $query |
|
212 | + * @param array $inner_query |
|
213 | + * @param DbSafeDateTime|null $start_date_range |
|
214 | + * @param DbSafeDateTime|null $end_date_range |
|
215 | + * @return array An array of any errors encountered and the fields they were for. |
|
216 | + */ |
|
217 | + private function doQueryForEachField($query, array $inner_query, $start_date_range, $end_date_range) |
|
218 | + { |
|
219 | + global $wpdb; |
|
220 | + $errors = array(); |
|
221 | + foreach ($inner_query as $field_name => $field_query) { |
|
222 | + $query_to_run = $query; |
|
223 | + $where_conditions = array(); |
|
224 | + $query_to_run .= ' SET ' . $field_query; |
|
225 | + if ($start_date_range instanceof DbSafeDateTime) { |
|
226 | + $start_date = $start_date_range->format(EE_Datetime_Field::mysql_timestamp_format); |
|
227 | + $where_conditions[] = "{$field_name} > '{$start_date}'"; |
|
228 | + } |
|
229 | + if ($end_date_range instanceof DbSafeDateTime) { |
|
230 | + $end_date = $end_date_range->format(EE_Datetime_Field::mysql_timestamp_format); |
|
231 | + $where_conditions[] = "{$field_name} < '{$end_date}'"; |
|
232 | + } |
|
233 | + if ($where_conditions) { |
|
234 | + $query_to_run .= ' WHERE ' . implode(' AND ', $where_conditions); |
|
235 | + } |
|
236 | + $result = $wpdb->query($query_to_run); |
|
237 | + if ($result === false) { |
|
238 | + // record error. |
|
239 | + $error_message = $wpdb->last_error; |
|
240 | + // handle the edgecases where last_error might be empty. |
|
241 | + if (! $error_message) { |
|
242 | + $error_message = esc_html__('Unknown mysql error occured.', 'event_espresso'); |
|
243 | + } |
|
244 | + $errors[ $field_name ] = $error_message; |
|
245 | + } |
|
246 | + } |
|
247 | + return $errors; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * Performs the query for all fields within the inner_query |
|
253 | + * |
|
254 | + * @param string $query |
|
255 | + * @param array $inner_query |
|
256 | + * @return false|int |
|
257 | + */ |
|
258 | + private function doQueryForAllFields($query, array $inner_query) |
|
259 | + { |
|
260 | + global $wpdb; |
|
261 | + $query .= ' SET ' . implode(',', $inner_query); |
|
262 | + return $wpdb->query($query); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * Records a changelog entry using the given information. |
|
268 | + * |
|
269 | + * @param EEM_Base $model |
|
270 | + * @param float $offset |
|
271 | + * @param EE_Table_Base $table |
|
272 | + * @param EE_Model_Field_Base[] $model_fields_affected |
|
273 | + * @param string $error_message If present then there was an error so let's record that instead. |
|
274 | + * @throws EE_Error |
|
275 | + */ |
|
276 | + private function recordChangeLog( |
|
277 | + EEM_Base $model, |
|
278 | + $offset, |
|
279 | + EE_Table_Base $table, |
|
280 | + $model_fields_affected, |
|
281 | + $error_message = '' |
|
282 | + ) { |
|
283 | + // setup $fields list. |
|
284 | + $fields = array(); |
|
285 | + /** @var EE_Datetime_Field $model_field */ |
|
286 | + foreach ($model_fields_affected as $model_field) { |
|
287 | + if (! $model_field instanceof EE_Datetime_Field) { |
|
288 | + continue; |
|
289 | + } |
|
290 | + $fields[] = $model_field->get_name(); |
|
291 | + } |
|
292 | + // setup the message for the changelog entry. |
|
293 | + $message = $error_message |
|
294 | + ? sprintf( |
|
295 | + esc_html__( |
|
296 | + 'The %1$s table for the %2$s model did not have the offset of %3$f applied to its fields (%4$s), because of the following error:%5$s', |
|
297 | + 'event_espresso' |
|
298 | + ), |
|
299 | + $table->get_table_name(), |
|
300 | + $model->get_this_model_name(), |
|
301 | + $offset, |
|
302 | + implode(',', $fields), |
|
303 | + $error_message |
|
304 | + ) |
|
305 | + : sprintf( |
|
306 | + esc_html__( |
|
307 | + 'The %1$s table for the %2$s model has had the offset of %3$f applied to its following fields: %4$s', |
|
308 | + 'event_espresso' |
|
309 | + ), |
|
310 | + $table->get_table_name(), |
|
311 | + $model->get_this_model_name(), |
|
312 | + $offset, |
|
313 | + implode(',', $fields) |
|
314 | + ); |
|
315 | + // write to the log |
|
316 | + $changelog = EE_Change_Log::new_instance(array( |
|
317 | + 'LOG_type' => $error_message |
|
318 | + ? self::DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE |
|
319 | + : self::DATETIME_OFFSET_FIX_CHANGELOG_TYPE, |
|
320 | + 'LOG_message' => $message, |
|
321 | + )); |
|
322 | + $changelog->save(); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * Returns an array of models that have datetime fields. |
|
328 | + * This array is added to a short lived transient cache to keep having to build this list to a minimum. |
|
329 | + * |
|
330 | + * @return array an array of model class names. |
|
331 | + * @throws EE_Error |
|
332 | + * @throws InvalidDataTypeException |
|
333 | + * @throws InvalidInterfaceException |
|
334 | + * @throws InvalidArgumentException |
|
335 | + */ |
|
336 | + private function getModelsWithDatetimeFields() |
|
337 | + { |
|
338 | + $this->getModelsToProcess(); |
|
339 | + if (! empty($this->models_with_datetime_fields)) { |
|
340 | + return $this->models_with_datetime_fields; |
|
341 | + } |
|
342 | + |
|
343 | + $all_non_abstract_models = EE_Registry::instance()->non_abstract_db_models; |
|
344 | + foreach ($all_non_abstract_models as $non_abstract_model) { |
|
345 | + // get model instance |
|
346 | + /** @var EEM_Base $non_abstract_model */ |
|
347 | + $non_abstract_model = $non_abstract_model::instance(); |
|
348 | + if ($non_abstract_model->get_a_field_of_type('EE_Datetime_Field') instanceof EE_Datetime_Field) { |
|
349 | + $this->models_with_datetime_fields[] = get_class($non_abstract_model); |
|
350 | + } |
|
351 | + } |
|
352 | + $this->setModelsToProcess($this->models_with_datetime_fields); |
|
353 | + return $this->models_with_datetime_fields; |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * This simply records the models that have been processed with our tracking option. |
|
359 | + * |
|
360 | + * @param array $models_to_set array of model class names. |
|
361 | + */ |
|
362 | + private function setModelsToProcess($models_to_set) |
|
363 | + { |
|
364 | + update_option(self::MODELS_TO_PROCESS_OPTION_KEY, $models_to_set); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * Used to keep track of how many models have been processed for the batch |
|
370 | + * |
|
371 | + * @param $count |
|
372 | + */ |
|
373 | + private function updateCountOfModelsProcessed($count = 1) |
|
374 | + { |
|
375 | + $count = $this->getCountOfModelsProcessed() + (int) $count; |
|
376 | + update_option(self::COUNT_OF_MODELS_PROCESSED, $count); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * Retrieve the tracked number of models processed between requests. |
|
382 | + * |
|
383 | + * @return int |
|
384 | + */ |
|
385 | + private function getCountOfModelsProcessed() |
|
386 | + { |
|
387 | + return (int) get_option(self::COUNT_OF_MODELS_PROCESSED, 0); |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Returns the models that are left to process. |
|
393 | + * |
|
394 | + * @return array an array of model class names. |
|
395 | + */ |
|
396 | + private function getModelsToProcess() |
|
397 | + { |
|
398 | + if (empty($this->models_with_datetime_fields)) { |
|
399 | + $this->models_with_datetime_fields = get_option(self::MODELS_TO_PROCESS_OPTION_KEY, array()); |
|
400 | + } |
|
401 | + return $this->models_with_datetime_fields; |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * Used to record the offset that will be applied to dates and times for EE_Datetime_Field columns. |
|
407 | + * |
|
408 | + * @param float $offset |
|
409 | + */ |
|
410 | + public static function updateOffset($offset) |
|
411 | + { |
|
412 | + update_option(self::OFFSET_TO_APPLY_OPTION_KEY, $offset); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * Used to retrieve the saved offset that will be applied to dates and times for EE_Datetime_Field columns. |
|
418 | + * |
|
419 | + * @return float |
|
420 | + */ |
|
421 | + public static function getOffset() |
|
422 | + { |
|
423 | + return (float) get_option(self::OFFSET_TO_APPLY_OPTION_KEY, 0); |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * Used to set the saved offset range start date. |
|
429 | + * |
|
430 | + * @param DbSafeDateTime|null $start_date |
|
431 | + */ |
|
432 | + public static function updateStartDateRange(DbSafeDateTime $start_date = null) |
|
433 | + { |
|
434 | + $date_to_save = $start_date instanceof DbSafeDateTime |
|
435 | + ? $start_date->format('U') |
|
436 | + : ''; |
|
437 | + update_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE, $date_to_save); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * Used to get the saved offset range start date. |
|
443 | + * |
|
444 | + * @return DbSafeDateTime|null |
|
445 | + */ |
|
446 | + public static function getStartDateRange() |
|
447 | + { |
|
448 | + $start_date = get_option(self::OPTION_KEY_OFFSET_RANGE_START_DATE, null); |
|
449 | + try { |
|
450 | + $datetime = DateTime::createFromFormat('U', $start_date, new DateTimeZone('UTC')); |
|
451 | + $start_date = $datetime instanceof DateTime |
|
452 | + ? DbSafeDateTime::createFromDateTime($datetime) |
|
453 | + : null; |
|
454 | + } catch (Exception $e) { |
|
455 | + $start_date = null; |
|
456 | + } |
|
457 | + return $start_date; |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * Used to set the saved offset range end date. |
|
463 | + * |
|
464 | + * @param DbSafeDateTime|null $end_date |
|
465 | + */ |
|
466 | + public static function updateEndDateRange(DbSafeDateTime $end_date = null) |
|
467 | + { |
|
468 | + $date_to_save = $end_date instanceof DbSafeDateTime |
|
469 | + ? $end_date->format('U') |
|
470 | + : ''; |
|
471 | + update_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE, $date_to_save); |
|
472 | + } |
|
473 | + |
|
474 | + |
|
475 | + /** |
|
476 | + * Used to get the saved offset range end date. |
|
477 | + * |
|
478 | + * @return DbSafeDateTime|null |
|
479 | + */ |
|
480 | + public static function getEndDateRange() |
|
481 | + { |
|
482 | + $end_date = get_option(self::OPTION_KEY_OFFSET_RANGE_END_DATE, null); |
|
483 | + try { |
|
484 | + $datetime = DateTime::createFromFormat('U', $end_date, new DateTimeZone('UTC')); |
|
485 | + $end_date = $datetime instanceof Datetime |
|
486 | + ? DbSafeDateTime::createFromDateTime($datetime) |
|
487 | + : null; |
|
488 | + } catch (Exception $e) { |
|
489 | + $end_date = null; |
|
490 | + } |
|
491 | + return $end_date; |
|
492 | + } |
|
493 | 493 | } |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | $date_ranges = array(); |
160 | 160 | // since some affected models might have two tables, we have to get our tables and set up a query for each table. |
161 | 161 | foreach ($model->get_tables() as $table) { |
162 | - $query = 'UPDATE ' . $table->get_table_name(); |
|
162 | + $query = 'UPDATE '.$table->get_table_name(); |
|
163 | 163 | $fields_affected = array(); |
164 | 164 | $inner_query = array(); |
165 | 165 | foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) { |
166 | 166 | if ($model_field instanceof EE_Datetime_Field) { |
167 | - $inner_query[ $model_field->get_table_column() ] = $model_field->get_table_column() . ' = ' |
|
168 | - . $sql_date_function . '(' |
|
167 | + $inner_query[$model_field->get_table_column()] = $model_field->get_table_column().' = ' |
|
168 | + . $sql_date_function.'(' |
|
169 | 169 | . $model_field->get_table_column() |
170 | 170 | . ", INTERVAL {$offset} MINUTE)"; |
171 | 171 | $fields_affected[] = $model_field; |
172 | 172 | } |
173 | 173 | } |
174 | - if (! $fields_affected) { |
|
174 | + if ( ! $fields_affected) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | // do we do one query per column/field or one query for all fields on the model? It all depends on whether |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // record error. |
189 | 189 | $error_message = $wpdb->last_error; |
190 | 190 | // handle the edge cases where last_error might be empty. |
191 | - if (! $error_message) { |
|
191 | + if ( ! $error_message) { |
|
192 | 192 | $error_message = esc_html__('Unknown mysql error occurred.', 'event_espresso'); |
193 | 193 | } |
194 | 194 | $this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | foreach ($inner_query as $field_name => $field_query) { |
222 | 222 | $query_to_run = $query; |
223 | 223 | $where_conditions = array(); |
224 | - $query_to_run .= ' SET ' . $field_query; |
|
224 | + $query_to_run .= ' SET '.$field_query; |
|
225 | 225 | if ($start_date_range instanceof DbSafeDateTime) { |
226 | 226 | $start_date = $start_date_range->format(EE_Datetime_Field::mysql_timestamp_format); |
227 | 227 | $where_conditions[] = "{$field_name} > '{$start_date}'"; |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | $where_conditions[] = "{$field_name} < '{$end_date}'"; |
232 | 232 | } |
233 | 233 | if ($where_conditions) { |
234 | - $query_to_run .= ' WHERE ' . implode(' AND ', $where_conditions); |
|
234 | + $query_to_run .= ' WHERE '.implode(' AND ', $where_conditions); |
|
235 | 235 | } |
236 | 236 | $result = $wpdb->query($query_to_run); |
237 | 237 | if ($result === false) { |
238 | 238 | // record error. |
239 | 239 | $error_message = $wpdb->last_error; |
240 | 240 | // handle the edgecases where last_error might be empty. |
241 | - if (! $error_message) { |
|
241 | + if ( ! $error_message) { |
|
242 | 242 | $error_message = esc_html__('Unknown mysql error occured.', 'event_espresso'); |
243 | 243 | } |
244 | - $errors[ $field_name ] = $error_message; |
|
244 | + $errors[$field_name] = $error_message; |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | return $errors; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | private function doQueryForAllFields($query, array $inner_query) |
259 | 259 | { |
260 | 260 | global $wpdb; |
261 | - $query .= ' SET ' . implode(',', $inner_query); |
|
261 | + $query .= ' SET '.implode(',', $inner_query); |
|
262 | 262 | return $wpdb->query($query); |
263 | 263 | } |
264 | 264 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $fields = array(); |
285 | 285 | /** @var EE_Datetime_Field $model_field */ |
286 | 286 | foreach ($model_fields_affected as $model_field) { |
287 | - if (! $model_field instanceof EE_Datetime_Field) { |
|
287 | + if ( ! $model_field instanceof EE_Datetime_Field) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | $fields[] = $model_field->get_name(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | private function getModelsWithDatetimeFields() |
337 | 337 | { |
338 | 338 | $this->getModelsToProcess(); |
339 | - if (! empty($this->models_with_datetime_fields)) { |
|
339 | + if ( ! empty($this->models_with_datetime_fields)) { |
|
340 | 340 | return $this->models_with_datetime_fields; |
341 | 341 | } |
342 | 342 |
@@ -128,7 +128,7 @@ |
||
128 | 128 | */ |
129 | 129 | public function getRequestData($key) |
130 | 130 | { |
131 | - return $this->request_data[ $key] ?? null; |
|
131 | + return $this->request_data[$key] ?? null; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 |
@@ -20,1132 +20,1132 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Dependency_Map |
22 | 22 | { |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - /** |
|
53 | - * @type EE_Dependency_Map $_instance |
|
54 | - */ |
|
55 | - protected static $_instance; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var ClassInterfaceCache $class_cache |
|
59 | - */ |
|
60 | - private $class_cache; |
|
61 | - |
|
62 | - /** |
|
63 | - * @type RequestInterface $request |
|
64 | - */ |
|
65 | - protected $request; |
|
66 | - |
|
67 | - /** |
|
68 | - * @type LegacyRequestInterface $legacy_request |
|
69 | - */ |
|
70 | - protected $legacy_request; |
|
71 | - |
|
72 | - /** |
|
73 | - * @type ResponseInterface $response |
|
74 | - */ |
|
75 | - protected $response; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type LoaderInterface $loader |
|
79 | - */ |
|
80 | - protected $loader; |
|
81 | - |
|
82 | - /** |
|
83 | - * @type array $_dependency_map |
|
84 | - */ |
|
85 | - protected $_dependency_map = []; |
|
86 | - |
|
87 | - /** |
|
88 | - * @type array $_class_loaders |
|
89 | - */ |
|
90 | - protected $_class_loaders = []; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * EE_Dependency_Map constructor. |
|
95 | - * |
|
96 | - * @param ClassInterfaceCache $class_cache |
|
97 | - */ |
|
98 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | - { |
|
100 | - $this->class_cache = $class_cache; |
|
101 | - do_action('EE_Dependency_Map____construct', $this); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return void |
|
107 | - * @throws InvalidAliasException |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if ( |
|
126 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
127 | - && $class_cache instanceof ClassInterfaceCache |
|
128 | - ) { |
|
129 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | - } |
|
131 | - return EE_Dependency_Map::$_instance; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param RequestInterface $request |
|
137 | - */ |
|
138 | - public function setRequest(RequestInterface $request) |
|
139 | - { |
|
140 | - $this->request = $request; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param LegacyRequestInterface $legacy_request |
|
146 | - */ |
|
147 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | - { |
|
149 | - $this->legacy_request = $legacy_request; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @param ResponseInterface $response |
|
155 | - */ |
|
156 | - public function setResponse(ResponseInterface $response) |
|
157 | - { |
|
158 | - $this->response = $response; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param LoaderInterface $loader |
|
164 | - */ |
|
165 | - public function setLoader(LoaderInterface $loader) |
|
166 | - { |
|
167 | - $this->loader = $loader; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param string $class |
|
173 | - * @param array $dependencies |
|
174 | - * @param int $overwrite |
|
175 | - * @return bool |
|
176 | - */ |
|
177 | - public static function register_dependencies( |
|
178 | - string $class, |
|
179 | - array $dependencies, |
|
180 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | - ): bool { |
|
182 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | - * to the class specified by the first parameter. |
|
189 | - * IMPORTANT !!! |
|
190 | - * The order of elements in the incoming $dependencies array MUST match |
|
191 | - * the order of the constructor parameters for the class in question. |
|
192 | - * This is especially important when overriding any existing dependencies that are registered. |
|
193 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | - * |
|
195 | - * @param string $class |
|
196 | - * @param array $dependencies |
|
197 | - * @param int $overwrite |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - public function registerDependencies( |
|
201 | - string $class, |
|
202 | - array $dependencies, |
|
203 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | - ): bool { |
|
205 | - $class = trim($class, '\\'); |
|
206 | - $registered = false; |
|
207 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
208 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
209 | - } |
|
210 | - // we need to make sure that any aliases used when registering a dependency |
|
211 | - // get resolved to the correct class name |
|
212 | - foreach ($dependencies as $dependency => $load_source) { |
|
213 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
214 | - if ( |
|
215 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | - ) { |
|
218 | - unset($dependencies[ $dependency ]); |
|
219 | - $dependencies[ $alias ] = $load_source; |
|
220 | - $registered = true; |
|
221 | - } |
|
222 | - } |
|
223 | - // now add our two lists of dependencies together. |
|
224 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | - // so $dependencies is NOT overwritten because it is listed first |
|
226 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | - // Union is way faster than array_merge() but should be used with caution... |
|
228 | - // especially with numerically indexed arrays |
|
229 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
230 | - // now we need to ensure that the resulting dependencies |
|
231 | - // array only has the entries that are required for the class |
|
232 | - // so first count how many dependencies were originally registered for the class |
|
233 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
234 | - // if that count is non-zero (meaning dependencies were already registered) |
|
235 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | - // then truncate the final array to match that count |
|
237 | - ? array_slice($dependencies, 0, $dependency_count) |
|
238 | - // otherwise just take the incoming array because nothing previously existed |
|
239 | - : $dependencies; |
|
240 | - return $registered; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @param string $class_name |
|
246 | - * @param callable|string $loader |
|
247 | - * @param bool $overwrite |
|
248 | - * @return bool |
|
249 | - * @throws DomainException |
|
250 | - */ |
|
251 | - public static function register_class_loader( |
|
252 | - string $class_name, |
|
253 | - $loader = 'load_core', |
|
254 | - bool $overwrite = false |
|
255 | - ): bool { |
|
256 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * @param string $class_name |
|
262 | - * @param Closure|string $loader |
|
263 | - * @param bool $overwrite |
|
264 | - * @return bool |
|
265 | - * @throws DomainException |
|
266 | - */ |
|
267 | - public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
268 | - { |
|
269 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
270 | - throw new DomainException( |
|
271 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
272 | - ); |
|
273 | - } |
|
274 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
275 | - if ( |
|
276 | - ! is_callable($loader) |
|
277 | - && ( |
|
278 | - strpos($loader, 'load_') !== 0 |
|
279 | - || ! method_exists('EE_Registry', $loader) |
|
280 | - ) |
|
281 | - ) { |
|
282 | - throw new DomainException( |
|
283 | - sprintf( |
|
284 | - esc_html__( |
|
285 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
286 | - 'event_espresso' |
|
287 | - ), |
|
288 | - $loader |
|
289 | - ) |
|
290 | - ); |
|
291 | - } |
|
292 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
293 | - if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
294 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
295 | - return true; |
|
296 | - } |
|
297 | - return false; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * @return array |
|
303 | - */ |
|
304 | - public function dependency_map(): array |
|
305 | - { |
|
306 | - return $this->_dependency_map; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
312 | - * |
|
313 | - * @param string $class_name |
|
314 | - * @return boolean |
|
315 | - */ |
|
316 | - public function has(string $class_name = ''): bool |
|
317 | - { |
|
318 | - // all legacy models have the same dependencies |
|
319 | - if (strpos($class_name, 'EEM_') === 0) { |
|
320 | - $class_name = 'LEGACY_MODELS'; |
|
321 | - } |
|
322 | - return isset($this->_dependency_map[ $class_name ]); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
328 | - * |
|
329 | - * @param string $class_name |
|
330 | - * @param string $dependency |
|
331 | - * @return bool |
|
332 | - */ |
|
333 | - public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
334 | - { |
|
335 | - // all legacy models have the same dependencies |
|
336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
337 | - $class_name = 'LEGACY_MODELS'; |
|
338 | - } |
|
339 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
340 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
346 | - * |
|
347 | - * @param string $class_name |
|
348 | - * @param string $dependency |
|
349 | - * @return int |
|
350 | - */ |
|
351 | - public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
352 | - { |
|
353 | - // all legacy models have the same dependencies |
|
354 | - if (strpos($class_name, 'EEM_') === 0) { |
|
355 | - $class_name = 'LEGACY_MODELS'; |
|
356 | - } |
|
357 | - $dependency = $this->getFqnForAlias($dependency); |
|
358 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
359 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
360 | - : EE_Dependency_Map::not_registered; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * @param string $class_name |
|
366 | - * @return string | Closure |
|
367 | - */ |
|
368 | - public function class_loader(string $class_name) |
|
369 | - { |
|
370 | - // all legacy models use load_model() |
|
371 | - if (strpos($class_name, 'EEM_') === 0) { |
|
372 | - return 'load_model'; |
|
373 | - } |
|
374 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
375 | - // perform strpos() first to avoid loading regex every time we load a class |
|
376 | - if ( |
|
377 | - strpos($class_name, 'EE_CPT_') === 0 |
|
378 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
379 | - ) { |
|
380 | - return 'load_core'; |
|
381 | - } |
|
382 | - $class_name = $this->getFqnForAlias($class_name); |
|
383 | - return $this->_class_loaders[ $class_name ] ?? ''; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * @return array |
|
389 | - */ |
|
390 | - public function class_loaders(): array |
|
391 | - { |
|
392 | - return $this->_class_loaders; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * adds an alias for a classname |
|
398 | - * |
|
399 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
400 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
401 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
402 | - * @throws InvalidAliasException |
|
403 | - */ |
|
404 | - public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
405 | - { |
|
406 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
412 | - * WHY? |
|
413 | - * Because if a class is type hinting for a concretion, |
|
414 | - * then why would we need to find another class to supply it? |
|
415 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
416 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
417 | - * Don't go looking for some substitute. |
|
418 | - * Whereas if a class is type hinting for an interface... |
|
419 | - * then we need to find an actual class to use. |
|
420 | - * So the interface IS the alias for some other FQN, |
|
421 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
422 | - * represents some other class. |
|
423 | - * |
|
424 | - * @param string $fqn |
|
425 | - * @param string $for_class |
|
426 | - * @return bool |
|
427 | - */ |
|
428 | - public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
429 | - { |
|
430 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
436 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
437 | - * for example: |
|
438 | - * if the following two entries were added to the _aliases array: |
|
439 | - * array( |
|
440 | - * 'interface_alias' => 'some\namespace\interface' |
|
441 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
442 | - * ) |
|
443 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
444 | - * to load an instance of 'some\namespace\classname' |
|
445 | - * |
|
446 | - * @param string $alias |
|
447 | - * @param string $for_class |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
451 | - { |
|
452 | - return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - /** |
|
457 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
458 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
459 | - * This is done by using the following class constants: |
|
460 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
461 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
462 | - */ |
|
463 | - protected function _register_core_dependencies() |
|
464 | - { |
|
465 | - $this->_dependency_map = [ |
|
466 | - 'EE_Admin' => [ |
|
467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
469 | - ], |
|
470 | - 'EE_Request_Handler' => [ |
|
471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | - 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
473 | - ], |
|
474 | - 'EE_System' => [ |
|
475 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
476 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
477 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
478 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
479 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
480 | - ], |
|
481 | - 'EE_Session' => [ |
|
482 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
483 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
484 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
485 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
486 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
487 | - ], |
|
488 | - 'EE_Cart' => [ |
|
489 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
490 | - ], |
|
491 | - 'EE_Messenger_Collection_Loader' => [ |
|
492 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
493 | - ], |
|
494 | - 'EE_Message_Type_Collection_Loader' => [ |
|
495 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | - ], |
|
497 | - 'EE_Message_Resource_Manager' => [ |
|
498 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
499 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | - ], |
|
502 | - 'EE_Message_Factory' => [ |
|
503 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
504 | - ], |
|
505 | - 'EE_messages' => [ |
|
506 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
507 | - ], |
|
508 | - 'EE_Messages_Generator' => [ |
|
509 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
510 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
511 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
512 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
513 | - ], |
|
514 | - 'EE_Messages_Processor' => [ |
|
515 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
516 | - ], |
|
517 | - 'EE_Messages_Queue' => [ |
|
518 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
519 | - ], |
|
520 | - 'EE_Messages_Template_Defaults' => [ |
|
521 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
523 | - ], |
|
524 | - 'EE_Message_To_Generate_From_Request' => [ |
|
525 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
526 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
527 | - ], |
|
528 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
529 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
530 | - ], |
|
531 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
532 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
533 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
534 | - ], |
|
535 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
536 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
537 | - ], |
|
538 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
539 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
540 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
541 | - ], |
|
542 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
543 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
544 | - ], |
|
545 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
546 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
547 | - ], |
|
548 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
549 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
550 | - ], |
|
551 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
552 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
553 | - ], |
|
554 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
555 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
556 | - ], |
|
557 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
558 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
559 | - ], |
|
560 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
561 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
562 | - ], |
|
563 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
564 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
565 | - ], |
|
566 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
567 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
568 | - ], |
|
569 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
570 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
571 | - ], |
|
572 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
573 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
574 | - ], |
|
575 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
576 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
577 | - ], |
|
578 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
579 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
580 | - ], |
|
581 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | - ], |
|
584 | - 'EE_Data_Migration_Class_Base' => [ |
|
585 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | - ], |
|
588 | - 'EE_DMS_Core_4_1_0' => [ |
|
589 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | - ], |
|
592 | - 'EE_DMS_Core_4_2_0' => [ |
|
593 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | - ], |
|
596 | - 'EE_DMS_Core_4_3_0' => [ |
|
597 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | - ], |
|
600 | - 'EE_DMS_Core_4_4_0' => [ |
|
601 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | - ], |
|
604 | - 'EE_DMS_Core_4_5_0' => [ |
|
605 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | - ], |
|
608 | - 'EE_DMS_Core_4_6_0' => [ |
|
609 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | - ], |
|
612 | - 'EE_DMS_Core_4_7_0' => [ |
|
613 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | - ], |
|
616 | - 'EE_DMS_Core_4_8_0' => [ |
|
617 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ], |
|
620 | - 'EE_DMS_Core_4_9_0' => [ |
|
621 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
622 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
623 | - ], |
|
624 | - 'EE_DMS_Core_4_10_0' => [ |
|
625 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
628 | - ], |
|
629 | - 'EE_DMS_Core_4_11_0' => [ |
|
630 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
631 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
632 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
633 | - ], |
|
634 | - 'EE_DMS_Core_4_12_0' => [ |
|
635 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
636 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
637 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
638 | - ], |
|
639 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
640 | - [], |
|
641 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
642 | - ], |
|
643 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
644 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
645 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
646 | - ], |
|
647 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
648 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
649 | - ], |
|
650 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
651 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
652 | - ], |
|
653 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
654 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
655 | - ], |
|
656 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
657 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
658 | - ], |
|
659 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
660 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
661 | - ], |
|
662 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
663 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
664 | - ], |
|
665 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
666 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
667 | - ], |
|
668 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
669 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
670 | - ], |
|
671 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
672 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
673 | - ], |
|
674 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
675 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
677 | - ], |
|
678 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
679 | - null, |
|
680 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
681 | - ], |
|
682 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
683 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | - ], |
|
685 | - 'LEGACY_MODELS' => [ |
|
686 | - null, |
|
687 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
688 | - ], |
|
689 | - 'EE_Module_Request_Router' => [ |
|
690 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
691 | - ], |
|
692 | - 'EE_Registration_Processor' => [ |
|
693 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
694 | - ], |
|
695 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
696 | - null, |
|
697 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
699 | - ], |
|
700 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
701 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
703 | - ], |
|
704 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
705 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
706 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
707 | - 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
708 | - ], |
|
709 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
710 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
711 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
712 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
713 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
714 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
715 | - ], |
|
716 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
717 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
718 | - ], |
|
719 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
720 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
721 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
722 | - ], |
|
723 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
724 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | - ], |
|
726 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
727 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
728 | - ], |
|
729 | - 'EE_CPT_Strategy' => [ |
|
730 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
731 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
732 | - ], |
|
733 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
734 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
735 | - ], |
|
736 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
737 | - null, |
|
738 | - null, |
|
739 | - null, |
|
740 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
741 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
742 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
743 | - ], |
|
744 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
745 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
746 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
747 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
748 | - ], |
|
749 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
750 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
751 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
752 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
753 | - ], |
|
754 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
755 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
756 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
757 | - ], |
|
758 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
759 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
760 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
761 | - ], |
|
762 | - 'EE_URL_Validation_Strategy' => [ |
|
763 | - null, |
|
764 | - null, |
|
765 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
766 | - ], |
|
767 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
768 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
769 | - ], |
|
770 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
771 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + /** |
|
53 | + * @type EE_Dependency_Map $_instance |
|
54 | + */ |
|
55 | + protected static $_instance; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var ClassInterfaceCache $class_cache |
|
59 | + */ |
|
60 | + private $class_cache; |
|
61 | + |
|
62 | + /** |
|
63 | + * @type RequestInterface $request |
|
64 | + */ |
|
65 | + protected $request; |
|
66 | + |
|
67 | + /** |
|
68 | + * @type LegacyRequestInterface $legacy_request |
|
69 | + */ |
|
70 | + protected $legacy_request; |
|
71 | + |
|
72 | + /** |
|
73 | + * @type ResponseInterface $response |
|
74 | + */ |
|
75 | + protected $response; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type LoaderInterface $loader |
|
79 | + */ |
|
80 | + protected $loader; |
|
81 | + |
|
82 | + /** |
|
83 | + * @type array $_dependency_map |
|
84 | + */ |
|
85 | + protected $_dependency_map = []; |
|
86 | + |
|
87 | + /** |
|
88 | + * @type array $_class_loaders |
|
89 | + */ |
|
90 | + protected $_class_loaders = []; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * EE_Dependency_Map constructor. |
|
95 | + * |
|
96 | + * @param ClassInterfaceCache $class_cache |
|
97 | + */ |
|
98 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | + { |
|
100 | + $this->class_cache = $class_cache; |
|
101 | + do_action('EE_Dependency_Map____construct', $this); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return void |
|
107 | + * @throws InvalidAliasException |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if ( |
|
126 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
127 | + && $class_cache instanceof ClassInterfaceCache |
|
128 | + ) { |
|
129 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | + } |
|
131 | + return EE_Dependency_Map::$_instance; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param RequestInterface $request |
|
137 | + */ |
|
138 | + public function setRequest(RequestInterface $request) |
|
139 | + { |
|
140 | + $this->request = $request; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param LegacyRequestInterface $legacy_request |
|
146 | + */ |
|
147 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | + { |
|
149 | + $this->legacy_request = $legacy_request; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @param ResponseInterface $response |
|
155 | + */ |
|
156 | + public function setResponse(ResponseInterface $response) |
|
157 | + { |
|
158 | + $this->response = $response; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param LoaderInterface $loader |
|
164 | + */ |
|
165 | + public function setLoader(LoaderInterface $loader) |
|
166 | + { |
|
167 | + $this->loader = $loader; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param string $class |
|
173 | + * @param array $dependencies |
|
174 | + * @param int $overwrite |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | + public static function register_dependencies( |
|
178 | + string $class, |
|
179 | + array $dependencies, |
|
180 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | + ): bool { |
|
182 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | + * to the class specified by the first parameter. |
|
189 | + * IMPORTANT !!! |
|
190 | + * The order of elements in the incoming $dependencies array MUST match |
|
191 | + * the order of the constructor parameters for the class in question. |
|
192 | + * This is especially important when overriding any existing dependencies that are registered. |
|
193 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | + * |
|
195 | + * @param string $class |
|
196 | + * @param array $dependencies |
|
197 | + * @param int $overwrite |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + public function registerDependencies( |
|
201 | + string $class, |
|
202 | + array $dependencies, |
|
203 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | + ): bool { |
|
205 | + $class = trim($class, '\\'); |
|
206 | + $registered = false; |
|
207 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
208 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
209 | + } |
|
210 | + // we need to make sure that any aliases used when registering a dependency |
|
211 | + // get resolved to the correct class name |
|
212 | + foreach ($dependencies as $dependency => $load_source) { |
|
213 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
214 | + if ( |
|
215 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | + ) { |
|
218 | + unset($dependencies[ $dependency ]); |
|
219 | + $dependencies[ $alias ] = $load_source; |
|
220 | + $registered = true; |
|
221 | + } |
|
222 | + } |
|
223 | + // now add our two lists of dependencies together. |
|
224 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | + // so $dependencies is NOT overwritten because it is listed first |
|
226 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | + // Union is way faster than array_merge() but should be used with caution... |
|
228 | + // especially with numerically indexed arrays |
|
229 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
230 | + // now we need to ensure that the resulting dependencies |
|
231 | + // array only has the entries that are required for the class |
|
232 | + // so first count how many dependencies were originally registered for the class |
|
233 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
234 | + // if that count is non-zero (meaning dependencies were already registered) |
|
235 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | + // then truncate the final array to match that count |
|
237 | + ? array_slice($dependencies, 0, $dependency_count) |
|
238 | + // otherwise just take the incoming array because nothing previously existed |
|
239 | + : $dependencies; |
|
240 | + return $registered; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @param string $class_name |
|
246 | + * @param callable|string $loader |
|
247 | + * @param bool $overwrite |
|
248 | + * @return bool |
|
249 | + * @throws DomainException |
|
250 | + */ |
|
251 | + public static function register_class_loader( |
|
252 | + string $class_name, |
|
253 | + $loader = 'load_core', |
|
254 | + bool $overwrite = false |
|
255 | + ): bool { |
|
256 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * @param string $class_name |
|
262 | + * @param Closure|string $loader |
|
263 | + * @param bool $overwrite |
|
264 | + * @return bool |
|
265 | + * @throws DomainException |
|
266 | + */ |
|
267 | + public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
268 | + { |
|
269 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
270 | + throw new DomainException( |
|
271 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
272 | + ); |
|
273 | + } |
|
274 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
275 | + if ( |
|
276 | + ! is_callable($loader) |
|
277 | + && ( |
|
278 | + strpos($loader, 'load_') !== 0 |
|
279 | + || ! method_exists('EE_Registry', $loader) |
|
280 | + ) |
|
281 | + ) { |
|
282 | + throw new DomainException( |
|
283 | + sprintf( |
|
284 | + esc_html__( |
|
285 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
286 | + 'event_espresso' |
|
287 | + ), |
|
288 | + $loader |
|
289 | + ) |
|
290 | + ); |
|
291 | + } |
|
292 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
293 | + if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
294 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
295 | + return true; |
|
296 | + } |
|
297 | + return false; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * @return array |
|
303 | + */ |
|
304 | + public function dependency_map(): array |
|
305 | + { |
|
306 | + return $this->_dependency_map; |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
312 | + * |
|
313 | + * @param string $class_name |
|
314 | + * @return boolean |
|
315 | + */ |
|
316 | + public function has(string $class_name = ''): bool |
|
317 | + { |
|
318 | + // all legacy models have the same dependencies |
|
319 | + if (strpos($class_name, 'EEM_') === 0) { |
|
320 | + $class_name = 'LEGACY_MODELS'; |
|
321 | + } |
|
322 | + return isset($this->_dependency_map[ $class_name ]); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
328 | + * |
|
329 | + * @param string $class_name |
|
330 | + * @param string $dependency |
|
331 | + * @return bool |
|
332 | + */ |
|
333 | + public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
334 | + { |
|
335 | + // all legacy models have the same dependencies |
|
336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
337 | + $class_name = 'LEGACY_MODELS'; |
|
338 | + } |
|
339 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
340 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
346 | + * |
|
347 | + * @param string $class_name |
|
348 | + * @param string $dependency |
|
349 | + * @return int |
|
350 | + */ |
|
351 | + public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
352 | + { |
|
353 | + // all legacy models have the same dependencies |
|
354 | + if (strpos($class_name, 'EEM_') === 0) { |
|
355 | + $class_name = 'LEGACY_MODELS'; |
|
356 | + } |
|
357 | + $dependency = $this->getFqnForAlias($dependency); |
|
358 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
359 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
360 | + : EE_Dependency_Map::not_registered; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * @param string $class_name |
|
366 | + * @return string | Closure |
|
367 | + */ |
|
368 | + public function class_loader(string $class_name) |
|
369 | + { |
|
370 | + // all legacy models use load_model() |
|
371 | + if (strpos($class_name, 'EEM_') === 0) { |
|
372 | + return 'load_model'; |
|
373 | + } |
|
374 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
375 | + // perform strpos() first to avoid loading regex every time we load a class |
|
376 | + if ( |
|
377 | + strpos($class_name, 'EE_CPT_') === 0 |
|
378 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
379 | + ) { |
|
380 | + return 'load_core'; |
|
381 | + } |
|
382 | + $class_name = $this->getFqnForAlias($class_name); |
|
383 | + return $this->_class_loaders[ $class_name ] ?? ''; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * @return array |
|
389 | + */ |
|
390 | + public function class_loaders(): array |
|
391 | + { |
|
392 | + return $this->_class_loaders; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * adds an alias for a classname |
|
398 | + * |
|
399 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
400 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
401 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
402 | + * @throws InvalidAliasException |
|
403 | + */ |
|
404 | + public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
405 | + { |
|
406 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
412 | + * WHY? |
|
413 | + * Because if a class is type hinting for a concretion, |
|
414 | + * then why would we need to find another class to supply it? |
|
415 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
416 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
417 | + * Don't go looking for some substitute. |
|
418 | + * Whereas if a class is type hinting for an interface... |
|
419 | + * then we need to find an actual class to use. |
|
420 | + * So the interface IS the alias for some other FQN, |
|
421 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
422 | + * represents some other class. |
|
423 | + * |
|
424 | + * @param string $fqn |
|
425 | + * @param string $for_class |
|
426 | + * @return bool |
|
427 | + */ |
|
428 | + public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
429 | + { |
|
430 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
436 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
437 | + * for example: |
|
438 | + * if the following two entries were added to the _aliases array: |
|
439 | + * array( |
|
440 | + * 'interface_alias' => 'some\namespace\interface' |
|
441 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
442 | + * ) |
|
443 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
444 | + * to load an instance of 'some\namespace\classname' |
|
445 | + * |
|
446 | + * @param string $alias |
|
447 | + * @param string $for_class |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
451 | + { |
|
452 | + return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + /** |
|
457 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
458 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
459 | + * This is done by using the following class constants: |
|
460 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
461 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
462 | + */ |
|
463 | + protected function _register_core_dependencies() |
|
464 | + { |
|
465 | + $this->_dependency_map = [ |
|
466 | + 'EE_Admin' => [ |
|
467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
772 | 468 | 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
773 | - ], |
|
774 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
775 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
776 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
777 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
778 | - null, |
|
779 | - ], |
|
780 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
781 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
782 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
783 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
784 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | - ], |
|
786 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
787 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
788 | - ], |
|
789 | - 'EventEspresso\core\services\routing\Router' => [ |
|
790 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
791 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
792 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
793 | - ], |
|
794 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
795 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
796 | - ], |
|
797 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
798 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
799 | - ], |
|
800 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
801 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
802 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
803 | - ], |
|
804 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
805 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
806 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
807 | - ], |
|
808 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
809 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
810 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
811 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
812 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
813 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
814 | - ], |
|
815 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
816 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
817 | - ], |
|
818 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
819 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
820 | - ], |
|
821 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
822 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
823 | - ], |
|
824 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
825 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
826 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
827 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
828 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
829 | - ], |
|
830 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
831 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
832 | - ], |
|
833 | - 'EventEspresso\core\services\request\CurrentPage' => [ |
|
834 | - 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
835 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
836 | - ], |
|
837 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
838 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
839 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
840 | - ], |
|
841 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
842 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
843 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
844 | - ], |
|
845 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
846 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
847 | - ], |
|
848 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
849 | - 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
850 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
851 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
852 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
853 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
854 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
855 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
856 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
857 | - ], |
|
858 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
859 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
860 | - ], |
|
861 | - 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
862 | - 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
863 | - ], |
|
864 | - 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
865 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
866 | - ], |
|
867 | - ]; |
|
868 | - } |
|
869 | - |
|
870 | - |
|
871 | - /** |
|
872 | - * Registers how core classes are loaded. |
|
873 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
874 | - * 'EE_Request_Handler' => 'load_core' |
|
875 | - * 'EE_Messages_Queue' => 'load_lib' |
|
876 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
877 | - * or, if greater control is required, by providing a custom closure. For example: |
|
878 | - * 'Some_Class' => function () { |
|
879 | - * return new Some_Class(); |
|
880 | - * }, |
|
881 | - * This is required for instantiating dependencies |
|
882 | - * where an interface has been type hinted in a class constructor. For example: |
|
883 | - * 'Required_Interface' => function () { |
|
884 | - * return new A_Class_That_Implements_Required_Interface(); |
|
885 | - * }, |
|
886 | - */ |
|
887 | - protected function _register_core_class_loaders() |
|
888 | - { |
|
889 | - $this->_class_loaders = [ |
|
890 | - // load_core |
|
891 | - 'EE_Dependency_Map' => function () { |
|
892 | - return $this; |
|
893 | - }, |
|
894 | - 'EE_Capabilities' => 'load_core', |
|
895 | - 'EE_Encryption' => 'load_core', |
|
896 | - 'EE_Front_Controller' => 'load_core', |
|
897 | - 'EE_Module_Request_Router' => 'load_core', |
|
898 | - 'EE_Registry' => 'load_core', |
|
899 | - 'EE_Request' => function () { |
|
900 | - return $this->legacy_request; |
|
901 | - }, |
|
902 | - 'EventEspresso\core\services\request\Request' => function () { |
|
903 | - return $this->request; |
|
904 | - }, |
|
905 | - 'EventEspresso\core\services\request\Response' => function () { |
|
906 | - return $this->response; |
|
907 | - }, |
|
908 | - 'EE_Base' => 'load_core', |
|
909 | - 'EE_Request_Handler' => 'load_core', |
|
910 | - 'EE_Session' => 'load_core', |
|
911 | - 'EE_Cron_Tasks' => 'load_core', |
|
912 | - 'EE_System' => 'load_core', |
|
913 | - 'EE_Maintenance_Mode' => 'load_core', |
|
914 | - 'EE_Register_CPTs' => 'load_core', |
|
915 | - 'EE_Admin' => 'load_core', |
|
916 | - 'EE_CPT_Strategy' => 'load_core', |
|
917 | - // load_class |
|
918 | - 'EE_Registration_Processor' => 'load_class', |
|
919 | - // load_lib |
|
920 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
921 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
922 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
923 | - 'EE_Messenger_Collection' => 'load_lib', |
|
924 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
925 | - 'EE_Messages_Processor' => 'load_lib', |
|
926 | - 'EE_Message_Repository' => 'load_lib', |
|
927 | - 'EE_Messages_Queue' => 'load_lib', |
|
928 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
929 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
930 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
931 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
932 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
933 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
934 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
935 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
936 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
937 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
938 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
939 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
940 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
941 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
942 | - 'EE_Messages_Generator' => static function () { |
|
943 | - return EE_Registry::instance()->load_lib( |
|
944 | - 'Messages_Generator', |
|
945 | - [], |
|
946 | - false, |
|
947 | - false |
|
948 | - ); |
|
949 | - }, |
|
950 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
951 | - return EE_Registry::instance()->load_lib( |
|
952 | - 'Messages_Template_Defaults', |
|
953 | - $arguments, |
|
954 | - false, |
|
955 | - false |
|
956 | - ); |
|
957 | - }, |
|
958 | - // load_helper |
|
959 | - 'EEH_Parse_Shortcodes' => static function () { |
|
960 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
961 | - return new EEH_Parse_Shortcodes(); |
|
962 | - } |
|
963 | - return null; |
|
964 | - }, |
|
965 | - 'EE_Template_Config' => static function () { |
|
966 | - return EE_Config::instance()->template_settings; |
|
967 | - }, |
|
968 | - 'EE_Currency_Config' => static function () { |
|
969 | - return EE_Currency_Config::getCurrencyConfig(); |
|
970 | - }, |
|
971 | - 'EE_Registration_Config' => static function () { |
|
972 | - return EE_Config::instance()->registration; |
|
973 | - }, |
|
974 | - 'EE_Core_Config' => static function () { |
|
975 | - return EE_Config::instance()->core; |
|
976 | - }, |
|
977 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
978 | - return LoaderFactory::getLoader(); |
|
979 | - }, |
|
980 | - 'EE_Network_Config' => static function () { |
|
981 | - return EE_Network_Config::instance(); |
|
982 | - }, |
|
983 | - 'EE_Config' => static function () { |
|
984 | - return EE_Config::instance(); |
|
985 | - }, |
|
986 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
987 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
988 | - }, |
|
989 | - 'EE_Admin_Config' => static function () { |
|
990 | - return EE_Config::instance()->admin; |
|
991 | - }, |
|
992 | - 'EE_Organization_Config' => static function () { |
|
993 | - return EE_Config::instance()->organization; |
|
994 | - }, |
|
995 | - 'EE_Network_Core_Config' => static function () { |
|
996 | - return EE_Network_Config::instance()->core; |
|
997 | - }, |
|
998 | - 'EE_Environment_Config' => static function () { |
|
999 | - return EE_Config::instance()->environment; |
|
1000 | - }, |
|
1001 | - 'EED_Core_Rest_Api' => static function () { |
|
1002 | - return EED_Core_Rest_Api::instance(); |
|
1003 | - }, |
|
1004 | - 'WP_REST_Server' => static function () { |
|
1005 | - return rest_get_server(); |
|
1006 | - }, |
|
1007 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
1008 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
1009 | - }, |
|
1010 | - 'EE_Ticket_Selector_Config' => function () { |
|
1011 | - return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1012 | - }, |
|
1013 | - ]; |
|
1014 | - } |
|
1015 | - |
|
1016 | - |
|
1017 | - /** |
|
1018 | - * can be used for supplying alternate names for classes, |
|
1019 | - * or for connecting interface names to instantiable classes |
|
1020 | - * |
|
1021 | - * @throws InvalidAliasException |
|
1022 | - */ |
|
1023 | - protected function _register_core_aliases() |
|
1024 | - { |
|
1025 | - $aliases = [ |
|
1026 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1027 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1028 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1029 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1030 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1031 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1032 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1033 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1034 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1035 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1036 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1037 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1038 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1039 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1040 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1041 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1042 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1043 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1044 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1045 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1046 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1047 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1048 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1049 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1050 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1051 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1052 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1053 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1054 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1055 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1056 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1057 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1058 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1059 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1060 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1061 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1062 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1063 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1064 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1065 | - ]; |
|
1066 | - foreach ($aliases as $alias => $fqn) { |
|
1067 | - if (is_array($fqn)) { |
|
1068 | - foreach ($fqn as $class => $for_class) { |
|
1069 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1070 | - } |
|
1071 | - continue; |
|
1072 | - } |
|
1073 | - $this->class_cache->addAlias($fqn, $alias); |
|
1074 | - } |
|
1075 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1076 | - $this->class_cache->addAlias( |
|
1077 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1078 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1079 | - ); |
|
1080 | - } |
|
1081 | - } |
|
1082 | - |
|
1083 | - |
|
1084 | - public function debug($for_class = '') |
|
1085 | - { |
|
1086 | - if (method_exists($this->class_cache, 'debug')) { |
|
1087 | - $this->class_cache->debug($for_class); |
|
1088 | - } |
|
1089 | - } |
|
1090 | - |
|
1091 | - |
|
1092 | - /** |
|
1093 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1094 | - * request Primarily used by unit tests. |
|
1095 | - */ |
|
1096 | - public function reset() |
|
1097 | - { |
|
1098 | - $this->_register_core_class_loaders(); |
|
1099 | - $this->_register_core_dependencies(); |
|
1100 | - } |
|
1101 | - |
|
1102 | - |
|
1103 | - /** |
|
1104 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1105 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1106 | - * WHY? |
|
1107 | - * Because if a class is type hinting for a concretion, |
|
1108 | - * then why would we need to find another class to supply it? |
|
1109 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1110 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1111 | - * Don't go looking for some substitute. |
|
1112 | - * Whereas if a class is type hinting for an interface... |
|
1113 | - * then we need to find an actual class to use. |
|
1114 | - * So the interface IS the alias for some other FQN, |
|
1115 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1116 | - * represents some other class. |
|
1117 | - * |
|
1118 | - * @param string $fqn |
|
1119 | - * @param string $for_class |
|
1120 | - * @return bool |
|
1121 | - * @deprecated 4.9.62.p |
|
1122 | - */ |
|
1123 | - public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
1124 | - { |
|
1125 | - return $this->isAlias($fqn, $for_class); |
|
1126 | - } |
|
1127 | - |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1131 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1132 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1133 | - * for example: |
|
1134 | - * if the following two entries were added to the _aliases array: |
|
1135 | - * array( |
|
1136 | - * 'interface_alias' => 'some\namespace\interface' |
|
1137 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1138 | - * ) |
|
1139 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1140 | - * to load an instance of 'some\namespace\classname' |
|
1141 | - * |
|
1142 | - * @param string $alias |
|
1143 | - * @param string $for_class |
|
1144 | - * @return string |
|
1145 | - * @deprecated 4.9.62.p |
|
1146 | - */ |
|
1147 | - public function get_alias(string $alias = '', string $for_class = ''): string |
|
1148 | - { |
|
1149 | - return $this->getFqnForAlias($alias, $for_class); |
|
1150 | - } |
|
469 | + ], |
|
470 | + 'EE_Request_Handler' => [ |
|
471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | + 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
473 | + ], |
|
474 | + 'EE_System' => [ |
|
475 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
476 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
477 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
478 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
479 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
480 | + ], |
|
481 | + 'EE_Session' => [ |
|
482 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
483 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
484 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
485 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
486 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
487 | + ], |
|
488 | + 'EE_Cart' => [ |
|
489 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
490 | + ], |
|
491 | + 'EE_Messenger_Collection_Loader' => [ |
|
492 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
493 | + ], |
|
494 | + 'EE_Message_Type_Collection_Loader' => [ |
|
495 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | + ], |
|
497 | + 'EE_Message_Resource_Manager' => [ |
|
498 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
499 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | + ], |
|
502 | + 'EE_Message_Factory' => [ |
|
503 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
504 | + ], |
|
505 | + 'EE_messages' => [ |
|
506 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
507 | + ], |
|
508 | + 'EE_Messages_Generator' => [ |
|
509 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
510 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
511 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
512 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
513 | + ], |
|
514 | + 'EE_Messages_Processor' => [ |
|
515 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
516 | + ], |
|
517 | + 'EE_Messages_Queue' => [ |
|
518 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
519 | + ], |
|
520 | + 'EE_Messages_Template_Defaults' => [ |
|
521 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
523 | + ], |
|
524 | + 'EE_Message_To_Generate_From_Request' => [ |
|
525 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
526 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
527 | + ], |
|
528 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
529 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
530 | + ], |
|
531 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
532 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
533 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
534 | + ], |
|
535 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
536 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
537 | + ], |
|
538 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
539 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
540 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
541 | + ], |
|
542 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
543 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
544 | + ], |
|
545 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
546 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
547 | + ], |
|
548 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
549 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
550 | + ], |
|
551 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
552 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
553 | + ], |
|
554 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
555 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
556 | + ], |
|
557 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
558 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
559 | + ], |
|
560 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
561 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
562 | + ], |
|
563 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
564 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
565 | + ], |
|
566 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
567 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
568 | + ], |
|
569 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
570 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
571 | + ], |
|
572 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
573 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
574 | + ], |
|
575 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
576 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
577 | + ], |
|
578 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
579 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
580 | + ], |
|
581 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | + ], |
|
584 | + 'EE_Data_Migration_Class_Base' => [ |
|
585 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | + ], |
|
588 | + 'EE_DMS_Core_4_1_0' => [ |
|
589 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | + ], |
|
592 | + 'EE_DMS_Core_4_2_0' => [ |
|
593 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | + ], |
|
596 | + 'EE_DMS_Core_4_3_0' => [ |
|
597 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | + ], |
|
600 | + 'EE_DMS_Core_4_4_0' => [ |
|
601 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | + ], |
|
604 | + 'EE_DMS_Core_4_5_0' => [ |
|
605 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | + ], |
|
608 | + 'EE_DMS_Core_4_6_0' => [ |
|
609 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | + ], |
|
612 | + 'EE_DMS_Core_4_7_0' => [ |
|
613 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | + ], |
|
616 | + 'EE_DMS_Core_4_8_0' => [ |
|
617 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ], |
|
620 | + 'EE_DMS_Core_4_9_0' => [ |
|
621 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
622 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
623 | + ], |
|
624 | + 'EE_DMS_Core_4_10_0' => [ |
|
625 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
628 | + ], |
|
629 | + 'EE_DMS_Core_4_11_0' => [ |
|
630 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
631 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
632 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
633 | + ], |
|
634 | + 'EE_DMS_Core_4_12_0' => [ |
|
635 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
636 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
637 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
638 | + ], |
|
639 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
640 | + [], |
|
641 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
642 | + ], |
|
643 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
644 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
645 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
646 | + ], |
|
647 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
648 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
649 | + ], |
|
650 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
651 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
652 | + ], |
|
653 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
654 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
655 | + ], |
|
656 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
657 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
658 | + ], |
|
659 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
660 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
661 | + ], |
|
662 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
663 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
664 | + ], |
|
665 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
666 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
667 | + ], |
|
668 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
669 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
670 | + ], |
|
671 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
672 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
673 | + ], |
|
674 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
675 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
677 | + ], |
|
678 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
679 | + null, |
|
680 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
681 | + ], |
|
682 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
683 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | + ], |
|
685 | + 'LEGACY_MODELS' => [ |
|
686 | + null, |
|
687 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
688 | + ], |
|
689 | + 'EE_Module_Request_Router' => [ |
|
690 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
691 | + ], |
|
692 | + 'EE_Registration_Processor' => [ |
|
693 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
694 | + ], |
|
695 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
696 | + null, |
|
697 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
699 | + ], |
|
700 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
701 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
703 | + ], |
|
704 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
705 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
706 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
707 | + 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
708 | + ], |
|
709 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
710 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
711 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
712 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
713 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
714 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
715 | + ], |
|
716 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
717 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
718 | + ], |
|
719 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
720 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
721 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
722 | + ], |
|
723 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
724 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | + ], |
|
726 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
727 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
728 | + ], |
|
729 | + 'EE_CPT_Strategy' => [ |
|
730 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
731 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
732 | + ], |
|
733 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
734 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
735 | + ], |
|
736 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
737 | + null, |
|
738 | + null, |
|
739 | + null, |
|
740 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
741 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
742 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
743 | + ], |
|
744 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
745 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
746 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
747 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
748 | + ], |
|
749 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
750 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
751 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
752 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
753 | + ], |
|
754 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
755 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
756 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
757 | + ], |
|
758 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
759 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
760 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
761 | + ], |
|
762 | + 'EE_URL_Validation_Strategy' => [ |
|
763 | + null, |
|
764 | + null, |
|
765 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
766 | + ], |
|
767 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
768 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
769 | + ], |
|
770 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
771 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
772 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
773 | + ], |
|
774 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
775 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
776 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
777 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
778 | + null, |
|
779 | + ], |
|
780 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
781 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
782 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
783 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
784 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | + ], |
|
786 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
787 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
788 | + ], |
|
789 | + 'EventEspresso\core\services\routing\Router' => [ |
|
790 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
791 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
792 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
793 | + ], |
|
794 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
795 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
796 | + ], |
|
797 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
798 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
799 | + ], |
|
800 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
801 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
802 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
803 | + ], |
|
804 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
805 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
806 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
807 | + ], |
|
808 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
809 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
810 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
811 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
812 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
813 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
814 | + ], |
|
815 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
816 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
817 | + ], |
|
818 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
819 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
820 | + ], |
|
821 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
822 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
823 | + ], |
|
824 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
825 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
826 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
827 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
828 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
829 | + ], |
|
830 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
831 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
832 | + ], |
|
833 | + 'EventEspresso\core\services\request\CurrentPage' => [ |
|
834 | + 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
835 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
836 | + ], |
|
837 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
838 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
839 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
840 | + ], |
|
841 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
842 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
843 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
844 | + ], |
|
845 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
846 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
847 | + ], |
|
848 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
849 | + 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
850 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
851 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
852 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
853 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
854 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
855 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
856 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
857 | + ], |
|
858 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
859 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
860 | + ], |
|
861 | + 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
862 | + 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
863 | + ], |
|
864 | + 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
865 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
866 | + ], |
|
867 | + ]; |
|
868 | + } |
|
869 | + |
|
870 | + |
|
871 | + /** |
|
872 | + * Registers how core classes are loaded. |
|
873 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
874 | + * 'EE_Request_Handler' => 'load_core' |
|
875 | + * 'EE_Messages_Queue' => 'load_lib' |
|
876 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
877 | + * or, if greater control is required, by providing a custom closure. For example: |
|
878 | + * 'Some_Class' => function () { |
|
879 | + * return new Some_Class(); |
|
880 | + * }, |
|
881 | + * This is required for instantiating dependencies |
|
882 | + * where an interface has been type hinted in a class constructor. For example: |
|
883 | + * 'Required_Interface' => function () { |
|
884 | + * return new A_Class_That_Implements_Required_Interface(); |
|
885 | + * }, |
|
886 | + */ |
|
887 | + protected function _register_core_class_loaders() |
|
888 | + { |
|
889 | + $this->_class_loaders = [ |
|
890 | + // load_core |
|
891 | + 'EE_Dependency_Map' => function () { |
|
892 | + return $this; |
|
893 | + }, |
|
894 | + 'EE_Capabilities' => 'load_core', |
|
895 | + 'EE_Encryption' => 'load_core', |
|
896 | + 'EE_Front_Controller' => 'load_core', |
|
897 | + 'EE_Module_Request_Router' => 'load_core', |
|
898 | + 'EE_Registry' => 'load_core', |
|
899 | + 'EE_Request' => function () { |
|
900 | + return $this->legacy_request; |
|
901 | + }, |
|
902 | + 'EventEspresso\core\services\request\Request' => function () { |
|
903 | + return $this->request; |
|
904 | + }, |
|
905 | + 'EventEspresso\core\services\request\Response' => function () { |
|
906 | + return $this->response; |
|
907 | + }, |
|
908 | + 'EE_Base' => 'load_core', |
|
909 | + 'EE_Request_Handler' => 'load_core', |
|
910 | + 'EE_Session' => 'load_core', |
|
911 | + 'EE_Cron_Tasks' => 'load_core', |
|
912 | + 'EE_System' => 'load_core', |
|
913 | + 'EE_Maintenance_Mode' => 'load_core', |
|
914 | + 'EE_Register_CPTs' => 'load_core', |
|
915 | + 'EE_Admin' => 'load_core', |
|
916 | + 'EE_CPT_Strategy' => 'load_core', |
|
917 | + // load_class |
|
918 | + 'EE_Registration_Processor' => 'load_class', |
|
919 | + // load_lib |
|
920 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
921 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
922 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
923 | + 'EE_Messenger_Collection' => 'load_lib', |
|
924 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
925 | + 'EE_Messages_Processor' => 'load_lib', |
|
926 | + 'EE_Message_Repository' => 'load_lib', |
|
927 | + 'EE_Messages_Queue' => 'load_lib', |
|
928 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
929 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
930 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
931 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
932 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
933 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
934 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
935 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
936 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
937 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
938 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
939 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
940 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
941 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
942 | + 'EE_Messages_Generator' => static function () { |
|
943 | + return EE_Registry::instance()->load_lib( |
|
944 | + 'Messages_Generator', |
|
945 | + [], |
|
946 | + false, |
|
947 | + false |
|
948 | + ); |
|
949 | + }, |
|
950 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
951 | + return EE_Registry::instance()->load_lib( |
|
952 | + 'Messages_Template_Defaults', |
|
953 | + $arguments, |
|
954 | + false, |
|
955 | + false |
|
956 | + ); |
|
957 | + }, |
|
958 | + // load_helper |
|
959 | + 'EEH_Parse_Shortcodes' => static function () { |
|
960 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
961 | + return new EEH_Parse_Shortcodes(); |
|
962 | + } |
|
963 | + return null; |
|
964 | + }, |
|
965 | + 'EE_Template_Config' => static function () { |
|
966 | + return EE_Config::instance()->template_settings; |
|
967 | + }, |
|
968 | + 'EE_Currency_Config' => static function () { |
|
969 | + return EE_Currency_Config::getCurrencyConfig(); |
|
970 | + }, |
|
971 | + 'EE_Registration_Config' => static function () { |
|
972 | + return EE_Config::instance()->registration; |
|
973 | + }, |
|
974 | + 'EE_Core_Config' => static function () { |
|
975 | + return EE_Config::instance()->core; |
|
976 | + }, |
|
977 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
978 | + return LoaderFactory::getLoader(); |
|
979 | + }, |
|
980 | + 'EE_Network_Config' => static function () { |
|
981 | + return EE_Network_Config::instance(); |
|
982 | + }, |
|
983 | + 'EE_Config' => static function () { |
|
984 | + return EE_Config::instance(); |
|
985 | + }, |
|
986 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
987 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
988 | + }, |
|
989 | + 'EE_Admin_Config' => static function () { |
|
990 | + return EE_Config::instance()->admin; |
|
991 | + }, |
|
992 | + 'EE_Organization_Config' => static function () { |
|
993 | + return EE_Config::instance()->organization; |
|
994 | + }, |
|
995 | + 'EE_Network_Core_Config' => static function () { |
|
996 | + return EE_Network_Config::instance()->core; |
|
997 | + }, |
|
998 | + 'EE_Environment_Config' => static function () { |
|
999 | + return EE_Config::instance()->environment; |
|
1000 | + }, |
|
1001 | + 'EED_Core_Rest_Api' => static function () { |
|
1002 | + return EED_Core_Rest_Api::instance(); |
|
1003 | + }, |
|
1004 | + 'WP_REST_Server' => static function () { |
|
1005 | + return rest_get_server(); |
|
1006 | + }, |
|
1007 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
1008 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
1009 | + }, |
|
1010 | + 'EE_Ticket_Selector_Config' => function () { |
|
1011 | + return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1012 | + }, |
|
1013 | + ]; |
|
1014 | + } |
|
1015 | + |
|
1016 | + |
|
1017 | + /** |
|
1018 | + * can be used for supplying alternate names for classes, |
|
1019 | + * or for connecting interface names to instantiable classes |
|
1020 | + * |
|
1021 | + * @throws InvalidAliasException |
|
1022 | + */ |
|
1023 | + protected function _register_core_aliases() |
|
1024 | + { |
|
1025 | + $aliases = [ |
|
1026 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1027 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1028 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1029 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1030 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1031 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1032 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1033 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1034 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1035 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1036 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1037 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1038 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1039 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1040 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1041 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1042 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1043 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1044 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1045 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1046 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1047 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1048 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1049 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1050 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1051 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1052 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1053 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1054 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1055 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1056 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1057 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1058 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1059 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1060 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1061 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1062 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1063 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1064 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1065 | + ]; |
|
1066 | + foreach ($aliases as $alias => $fqn) { |
|
1067 | + if (is_array($fqn)) { |
|
1068 | + foreach ($fqn as $class => $for_class) { |
|
1069 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1070 | + } |
|
1071 | + continue; |
|
1072 | + } |
|
1073 | + $this->class_cache->addAlias($fqn, $alias); |
|
1074 | + } |
|
1075 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1076 | + $this->class_cache->addAlias( |
|
1077 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1078 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1079 | + ); |
|
1080 | + } |
|
1081 | + } |
|
1082 | + |
|
1083 | + |
|
1084 | + public function debug($for_class = '') |
|
1085 | + { |
|
1086 | + if (method_exists($this->class_cache, 'debug')) { |
|
1087 | + $this->class_cache->debug($for_class); |
|
1088 | + } |
|
1089 | + } |
|
1090 | + |
|
1091 | + |
|
1092 | + /** |
|
1093 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1094 | + * request Primarily used by unit tests. |
|
1095 | + */ |
|
1096 | + public function reset() |
|
1097 | + { |
|
1098 | + $this->_register_core_class_loaders(); |
|
1099 | + $this->_register_core_dependencies(); |
|
1100 | + } |
|
1101 | + |
|
1102 | + |
|
1103 | + /** |
|
1104 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1105 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1106 | + * WHY? |
|
1107 | + * Because if a class is type hinting for a concretion, |
|
1108 | + * then why would we need to find another class to supply it? |
|
1109 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1110 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1111 | + * Don't go looking for some substitute. |
|
1112 | + * Whereas if a class is type hinting for an interface... |
|
1113 | + * then we need to find an actual class to use. |
|
1114 | + * So the interface IS the alias for some other FQN, |
|
1115 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1116 | + * represents some other class. |
|
1117 | + * |
|
1118 | + * @param string $fqn |
|
1119 | + * @param string $for_class |
|
1120 | + * @return bool |
|
1121 | + * @deprecated 4.9.62.p |
|
1122 | + */ |
|
1123 | + public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
1124 | + { |
|
1125 | + return $this->isAlias($fqn, $for_class); |
|
1126 | + } |
|
1127 | + |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1131 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1132 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1133 | + * for example: |
|
1134 | + * if the following two entries were added to the _aliases array: |
|
1135 | + * array( |
|
1136 | + * 'interface_alias' => 'some\namespace\interface' |
|
1137 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1138 | + * ) |
|
1139 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1140 | + * to load an instance of 'some\namespace\classname' |
|
1141 | + * |
|
1142 | + * @param string $alias |
|
1143 | + * @param string $for_class |
|
1144 | + * @return string |
|
1145 | + * @deprecated 4.9.62.p |
|
1146 | + */ |
|
1147 | + public function get_alias(string $alias = '', string $for_class = ''): string |
|
1148 | + { |
|
1149 | + return $this->getFqnForAlias($alias, $for_class); |
|
1150 | + } |
|
1151 | 1151 | } |