Completed
Branch CASC/base (79f9d1)
by
unknown
19:48 queued 09:56
created
core/domain/services/admin/events/data/PreviewDeletion.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -31,127 +31,127 @@
 block discarded – undo
31 31
  */
32 32
 class PreviewDeletion
33 33
 {
34
-    /**
35
-     * @var NodeGroupDao
36
-     */
37
-    protected $dao;
34
+	/**
35
+	 * @var NodeGroupDao
36
+	 */
37
+	protected $dao;
38 38
 
39
-    /**
40
-     * @var EEM_Event
41
-     */
42
-    protected $event_model;
39
+	/**
40
+	 * @var EEM_Event
41
+	 */
42
+	protected $event_model;
43 43
 
44
-    /**
45
-     * @var EEM_Datetime
46
-     */
47
-    protected $datetime_model;
44
+	/**
45
+	 * @var EEM_Datetime
46
+	 */
47
+	protected $datetime_model;
48 48
 
49
-    /**
50
-     * @var EEM_Registration
51
-     */
52
-    protected $registration_model;
49
+	/**
50
+	 * @var EEM_Registration
51
+	 */
52
+	protected $registration_model;
53 53
 
54
-    /**
55
-     * PreviewDeletion constructor.
56
-     * @param NodeGroupDao $dao
57
-     * @param EEM_Event $event_model
58
-     * @param EEM_Datetime $datetime_model
59
-     * @param EEM_Registration $registration_model
60
-     */
61
-    public function __construct(
62
-        NodeGroupDao $dao,
63
-        EEM_Event $event_model,
64
-        EEM_Datetime $datetime_model,
65
-        EEM_Registration $registration_model
66
-    ) {
67
-        $this->dao = $dao;
68
-        $this->event_model = $event_model;
69
-        $this->datetime_model = $datetime_model;
70
-        $this->registration_model = $registration_model;
71
-    }
54
+	/**
55
+	 * PreviewDeletion constructor.
56
+	 * @param NodeGroupDao $dao
57
+	 * @param EEM_Event $event_model
58
+	 * @param EEM_Datetime $datetime_model
59
+	 * @param EEM_Registration $registration_model
60
+	 */
61
+	public function __construct(
62
+		NodeGroupDao $dao,
63
+		EEM_Event $event_model,
64
+		EEM_Datetime $datetime_model,
65
+		EEM_Registration $registration_model
66
+	) {
67
+		$this->dao = $dao;
68
+		$this->event_model = $event_model;
69
+		$this->datetime_model = $datetime_model;
70
+		$this->registration_model = $registration_model;
71
+	}
72 72
 
73
-    /**
74
-     * Renders the preview deletion page.
75
-     * @since $VID:$
76
-     * @param $request_data
77
-     * @param $admin_base_url
78
-     * @return array
79
-     * @throws UnexpectedEntityException
80
-     * @throws DomainException
81
-     * @throws EE_Error
82
-     * @throws InvalidDataTypeException
83
-     * @throws InvalidInterfaceException
84
-     * @throws InvalidArgumentException
85
-     * @throws ReflectionException
86
-     */
87
-    public function handle($request_data, $admin_base_url)
88
-    {
89
-        $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91
-        $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
-        if (empty($event_ids) || !is_array($event_ids)) {
93
-            throw new EE_Error(
94
-                esc_html__('No Events were found to delete.', 'event_espresso')
95
-            );
96
-        }
97
-        $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
-        if (!is_array($datetime_ids)) {
99
-            throw new UnexpectedEntityException($datetime_ids, 'array');
100
-        }
101
-        $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
-        if (!is_array($registration_ids)) {
103
-            throw new UnexpectedEntityException($registration_ids, 'array');
104
-        }
105
-        $num_registrations_to_show = 10;
106
-        $reg_count = count($registration_ids);
107
-        if ($reg_count > $num_registrations_to_show) {
108
-            $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
109
-        }
110
-        $form = new ConfirmEventDeletionForm($event_ids);
111
-        $events = $this->event_model->get_all_deleted_and_undeleted(
112
-            [
113
-                [
114
-                    'EVT_ID' => ['IN', $event_ids]
115
-                ]
116
-            ]
117
-        );
118
-        $datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
119
-            [
120
-                [
121
-                    'DTT_ID' => ['IN', $datetime_ids]
122
-                ]
123
-            ]
124
-        );
125
-        $registrations = $this->registration_model->get_all_deleted_and_undeleted(
126
-            [
127
-                [
128
-                    'REG_ID' => ['IN', $registration_ids]
129
-                ]
130
-            ]
131
-        );
132
-        $confirm_deletion_args = [
133
-            'action' => 'confirm_deletion',
134
-            'deletion_job_code' => $deletion_job_code
135
-        ];
136
-        return [
137
-            'admin_page_content' => EEH_Template::display_template(
138
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
139
-                [
140
-                    'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141
-                        $confirm_deletion_args,
142
-                        $admin_base_url
143
-                    ),
144
-                    'form' => $form,
145
-                    'events' => $events,
146
-                    'datetimes' => $datetimes,
147
-                    'registrations' => $registrations,
148
-                    'reg_count' => $reg_count,
149
-                    'num_registrations_to_show' => $num_registrations_to_show
150
-                ],
151
-                true
152
-            )
153
-        ];
154
-    }
73
+	/**
74
+	 * Renders the preview deletion page.
75
+	 * @since $VID:$
76
+	 * @param $request_data
77
+	 * @param $admin_base_url
78
+	 * @return array
79
+	 * @throws UnexpectedEntityException
80
+	 * @throws DomainException
81
+	 * @throws EE_Error
82
+	 * @throws InvalidDataTypeException
83
+	 * @throws InvalidInterfaceException
84
+	 * @throws InvalidArgumentException
85
+	 * @throws ReflectionException
86
+	 */
87
+	public function handle($request_data, $admin_base_url)
88
+	{
89
+		$deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91
+		$event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
+		if (empty($event_ids) || !is_array($event_ids)) {
93
+			throw new EE_Error(
94
+				esc_html__('No Events were found to delete.', 'event_espresso')
95
+			);
96
+		}
97
+		$datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
+		if (!is_array($datetime_ids)) {
99
+			throw new UnexpectedEntityException($datetime_ids, 'array');
100
+		}
101
+		$registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
+		if (!is_array($registration_ids)) {
103
+			throw new UnexpectedEntityException($registration_ids, 'array');
104
+		}
105
+		$num_registrations_to_show = 10;
106
+		$reg_count = count($registration_ids);
107
+		if ($reg_count > $num_registrations_to_show) {
108
+			$registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
109
+		}
110
+		$form = new ConfirmEventDeletionForm($event_ids);
111
+		$events = $this->event_model->get_all_deleted_and_undeleted(
112
+			[
113
+				[
114
+					'EVT_ID' => ['IN', $event_ids]
115
+				]
116
+			]
117
+		);
118
+		$datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
119
+			[
120
+				[
121
+					'DTT_ID' => ['IN', $datetime_ids]
122
+				]
123
+			]
124
+		);
125
+		$registrations = $this->registration_model->get_all_deleted_and_undeleted(
126
+			[
127
+				[
128
+					'REG_ID' => ['IN', $registration_ids]
129
+				]
130
+			]
131
+		);
132
+		$confirm_deletion_args = [
133
+			'action' => 'confirm_deletion',
134
+			'deletion_job_code' => $deletion_job_code
135
+		];
136
+		return [
137
+			'admin_page_content' => EEH_Template::display_template(
138
+				EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
139
+				[
140
+					'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141
+						$confirm_deletion_args,
142
+						$admin_base_url
143
+					),
144
+					'form' => $form,
145
+					'events' => $events,
146
+					'datetimes' => $datetimes,
147
+					'registrations' => $registrations,
148
+					'reg_count' => $reg_count,
149
+					'num_registrations_to_show' => $num_registrations_to_show
150
+				],
151
+				true
152
+			)
153
+		];
154
+	}
155 155
 }
156 156
 // End of file PreviewDeletion.php
157 157
 // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
         $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90 90
         $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91 91
         $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
-        if (empty($event_ids) || !is_array($event_ids)) {
92
+        if (empty($event_ids) || ! is_array($event_ids)) {
93 93
             throw new EE_Error(
94 94
                 esc_html__('No Events were found to delete.', 'event_espresso')
95 95
             );
96 96
         }
97 97
         $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
-        if (!is_array($datetime_ids)) {
98
+        if ( ! is_array($datetime_ids)) {
99 99
             throw new UnexpectedEntityException($datetime_ids, 'array');
100 100
         }
101 101
         $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
-        if (!is_array($registration_ids)) {
102
+        if ( ! is_array($registration_ids)) {
103 103
             throw new UnexpectedEntityException($registration_ids, 'array');
104 104
         }
105 105
         $num_registrations_to_show = 10;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         ];
136 136
         return [
137 137
             'admin_page_content' => EEH_Template::display_template(
138
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
138
+                EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php',
139 139
                 [
140 140
                     'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141 141
                         $confirm_deletion_args,
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1139 added lines, -1139 removed lines patch added patch discarded remove patch
@@ -20,1143 +20,1143 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
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
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
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)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
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);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0' => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EE_DMS_Core_4_10_0' => array(
604
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
-                array(),
610
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
-                null,
649
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'LEGACY_MODELS'                                                                                               => array(
655
-                null,
656
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EE_Module_Request_Router'                                                                                    => array(
659
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EE_Registration_Processor'                                                                                   => array(
662
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
-                null,
666
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
674
-                null,
675
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
-            ),
682
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
-            ),
686
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
-            ),
698
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
-            ),
701
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-            ),
708
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
-            ),
715
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
-            ),
718
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-            ),
725
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
-            ),
728
-            'EE_CPT_Strategy'                                                                                             => array(
729
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
-            ),
735
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
-            ),
742
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
-            ),
749
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
-            ),
762
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
-            ),
765
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
-            ),
769
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
-                null,
771
-                null,
772
-                null,
773
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
-            ),
777
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
-                'EE_Config' => EE_Dependency_Map::load_from_cache
780
-            ),
781
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
-            ),
792
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
-            ),
806
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
-            ),
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
-            ),
814
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
-            ),
817
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
-            ),
820
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
-            ),
823
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
-            ),
827
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
-            ),
831
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
-            ),
834
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
835
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
-            ),
837
-            'EE_URL_Validation_Strategy' => array(
838
-                null,
839
-                null,
840
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
-            ),
842
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
-            ),
849
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
-            ),
853
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
-            ),
857
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
-            ),
861
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
-            ),
864
-            'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
-            ],
867
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
-                null,
869
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
-                'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
-            ],
872
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
-                'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-            'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [
889
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
890
-            ],
891
-            'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [
892
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
893
-            ],
894
-            'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [
895
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
896
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
897
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
898
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
899
-            ],
900
-            'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [
901
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
902
-            ]
903
-        );
904
-    }
905
-
906
-
907
-    /**
908
-     * Registers how core classes are loaded.
909
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
910
-     *        'EE_Request_Handler' => 'load_core'
911
-     *        'EE_Messages_Queue'  => 'load_lib'
912
-     *        'EEH_Debug_Tools'    => 'load_helper'
913
-     * or, if greater control is required, by providing a custom closure. For example:
914
-     *        'Some_Class' => function () {
915
-     *            return new Some_Class();
916
-     *        },
917
-     * This is required for instantiating dependencies
918
-     * where an interface has been type hinted in a class constructor. For example:
919
-     *        'Required_Interface' => function () {
920
-     *            return new A_Class_That_Implements_Required_Interface();
921
-     *        },
922
-     */
923
-    protected function _register_core_class_loaders()
924
-    {
925
-        $this->_class_loaders = array(
926
-            // load_core
927
-            'EE_Dependency_Map'                            => function () {
928
-                return $this;
929
-            },
930
-            'EE_Capabilities'                              => 'load_core',
931
-            'EE_Encryption'                                => 'load_core',
932
-            'EE_Front_Controller'                          => 'load_core',
933
-            'EE_Module_Request_Router'                     => 'load_core',
934
-            'EE_Registry'                                  => 'load_core',
935
-            'EE_Request'                                   => function () {
936
-                return $this->legacy_request;
937
-            },
938
-            'EventEspresso\core\services\request\Request'  => function () {
939
-                return $this->request;
940
-            },
941
-            'EventEspresso\core\services\request\Response' => function () {
942
-                return $this->response;
943
-            },
944
-            'EE_Base'                                      => 'load_core',
945
-            'EE_Request_Handler'                           => 'load_core',
946
-            'EE_Session'                                   => 'load_core',
947
-            'EE_Cron_Tasks'                                => 'load_core',
948
-            'EE_System'                                    => 'load_core',
949
-            'EE_Maintenance_Mode'                          => 'load_core',
950
-            'EE_Register_CPTs'                             => 'load_core',
951
-            'EE_Admin'                                     => 'load_core',
952
-            'EE_CPT_Strategy'                              => 'load_core',
953
-            // load_class
954
-            'EE_Registration_Processor'                    => 'load_class',
955
-            // load_lib
956
-            'EE_Message_Resource_Manager'                  => 'load_lib',
957
-            'EE_Message_Type_Collection'                   => 'load_lib',
958
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
959
-            'EE_Messenger_Collection'                      => 'load_lib',
960
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
961
-            'EE_Messages_Processor'                        => 'load_lib',
962
-            'EE_Message_Repository'                        => 'load_lib',
963
-            'EE_Messages_Queue'                            => 'load_lib',
964
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
965
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
966
-            'EE_Payment_Method_Manager'                    => 'load_lib',
967
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
968
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
969
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
970
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
971
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
972
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
973
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
974
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
975
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
976
-            'EE_Messages_Generator'                        => function () {
977
-                return EE_Registry::instance()->load_lib(
978
-                    'Messages_Generator',
979
-                    array(),
980
-                    false,
981
-                    false
982
-                );
983
-            },
984
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
985
-                return EE_Registry::instance()->load_lib(
986
-                    'Messages_Template_Defaults',
987
-                    $arguments,
988
-                    false,
989
-                    false
990
-                );
991
-            },
992
-            // load_helper
993
-            'EEH_Parse_Shortcodes'                         => function () {
994
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
995
-                    return new EEH_Parse_Shortcodes();
996
-                }
997
-                return null;
998
-            },
999
-            'EE_Template_Config'                           => function () {
1000
-                return EE_Config::instance()->template_settings;
1001
-            },
1002
-            'EE_Currency_Config'                           => function () {
1003
-                return EE_Config::instance()->currency;
1004
-            },
1005
-            'EE_Registration_Config'                       => function () {
1006
-                return EE_Config::instance()->registration;
1007
-            },
1008
-            'EE_Core_Config'                               => function () {
1009
-                return EE_Config::instance()->core;
1010
-            },
1011
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1012
-                return LoaderFactory::getLoader();
1013
-            },
1014
-            'EE_Network_Config'                            => function () {
1015
-                return EE_Network_Config::instance();
1016
-            },
1017
-            'EE_Config'                                    => function () {
1018
-                return EE_Config::instance();
1019
-            },
1020
-            'EventEspresso\core\domain\Domain'             => function () {
1021
-                return DomainFactory::getEventEspressoCoreDomain();
1022
-            },
1023
-            'EE_Admin_Config'                              => function () {
1024
-                return EE_Config::instance()->admin;
1025
-            },
1026
-            'EE_Organization_Config'                       => function () {
1027
-                return EE_Config::instance()->organization;
1028
-            },
1029
-            'EE_Network_Core_Config'                       => function () {
1030
-                return EE_Network_Config::instance()->core;
1031
-            },
1032
-            'EE_Environment_Config'                        => function () {
1033
-                return EE_Config::instance()->environment;
1034
-            },
1035
-        );
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * can be used for supplying alternate names for classes,
1041
-     * or for connecting interface names to instantiable classes
1042
-     */
1043
-    protected function _register_core_aliases()
1044
-    {
1045
-        $aliases = array(
1046
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1047
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1048
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1049
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1050
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1051
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1052
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1053
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1054
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1055
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1056
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1057
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1058
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1059
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1060
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1061
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1062
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1063
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1064
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1065
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1066
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1067
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1068
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1069
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1070
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1071
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1072
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1073
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1074
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1075
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1076
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1077
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1078
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1079
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1080
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1081
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1082
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1083
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1084
-        );
1085
-        foreach ($aliases as $alias => $fqn) {
1086
-            if (is_array($fqn)) {
1087
-                foreach ($fqn as $class => $for_class) {
1088
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1089
-                }
1090
-                continue;
1091
-            }
1092
-            $this->class_cache->addAlias($fqn, $alias);
1093
-        }
1094
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1095
-            $this->class_cache->addAlias(
1096
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1097
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1098
-            );
1099
-        }
1100
-    }
1101
-
1102
-
1103
-    /**
1104
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1105
-     * request Primarily used by unit tests.
1106
-     */
1107
-    public function reset()
1108
-    {
1109
-        $this->_register_core_class_loaders();
1110
-        $this->_register_core_dependencies();
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * PLZ NOTE: a better name for this method would be is_alias()
1116
-     * because it returns TRUE if the provided fully qualified name IS an alias
1117
-     * WHY?
1118
-     * Because if a class is type hinting for a concretion,
1119
-     * then why would we need to find another class to supply it?
1120
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1121
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1122
-     * Don't go looking for some substitute.
1123
-     * Whereas if a class is type hinting for an interface...
1124
-     * then we need to find an actual class to use.
1125
-     * So the interface IS the alias for some other FQN,
1126
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1127
-     * represents some other class.
1128
-     *
1129
-     * @deprecated 4.9.62.p
1130
-     * @param string $fqn
1131
-     * @param string $for_class
1132
-     * @return bool
1133
-     */
1134
-    public function has_alias($fqn = '', $for_class = '')
1135
-    {
1136
-        return $this->isAlias($fqn, $for_class);
1137
-    }
1138
-
1139
-
1140
-    /**
1141
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1142
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1143
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1144
-     *  for example:
1145
-     *      if the following two entries were added to the _aliases array:
1146
-     *          array(
1147
-     *              'interface_alias'           => 'some\namespace\interface'
1148
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1149
-     *          )
1150
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1151
-     *      to load an instance of 'some\namespace\classname'
1152
-     *
1153
-     * @deprecated 4.9.62.p
1154
-     * @param string $alias
1155
-     * @param string $for_class
1156
-     * @return string
1157
-     */
1158
-    public function get_alias($alias = '', $for_class = '')
1159
-    {
1160
-        return $this->getFqnForAlias($alias, $for_class);
1161
-    }
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
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
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)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
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);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0' => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EE_DMS_Core_4_10_0' => array(
604
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
+			),
608
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
+				array(),
610
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
+				null,
649
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'LEGACY_MODELS'                                                                                               => array(
655
+				null,
656
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EE_Module_Request_Router'                                                                                    => array(
659
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EE_Registration_Processor'                                                                                   => array(
662
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
+				null,
666
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
674
+				null,
675
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
+			),
682
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
+			),
686
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
+			),
698
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
+			),
701
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+			),
708
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
+			),
715
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
+			),
718
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+			),
725
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
+			),
728
+			'EE_CPT_Strategy'                                                                                             => array(
729
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
+			),
735
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
+			),
742
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
+			),
749
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
+			),
762
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
+			),
765
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
+			),
769
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
+				null,
771
+				null,
772
+				null,
773
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
+			),
777
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
+				'EE_Config' => EE_Dependency_Map::load_from_cache
780
+			),
781
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
+			),
792
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
+			),
796
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
+			),
806
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
+			),
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
+			),
814
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
+			),
817
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
+			),
820
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
+			),
823
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
+			),
827
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
+			),
831
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
+			),
834
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
835
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
+			),
837
+			'EE_URL_Validation_Strategy' => array(
838
+				null,
839
+				null,
840
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
+			),
842
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
+			),
849
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
+			),
853
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
+			),
857
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
+			),
861
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
+			),
864
+			'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
+			],
867
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
+				null,
869
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
+				'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
+			],
872
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
+				'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
+			],
888
+			'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [
889
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
890
+			],
891
+			'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [
892
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
893
+			],
894
+			'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [
895
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
896
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
897
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
898
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
899
+			],
900
+			'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [
901
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
902
+			]
903
+		);
904
+	}
905
+
906
+
907
+	/**
908
+	 * Registers how core classes are loaded.
909
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
910
+	 *        'EE_Request_Handler' => 'load_core'
911
+	 *        'EE_Messages_Queue'  => 'load_lib'
912
+	 *        'EEH_Debug_Tools'    => 'load_helper'
913
+	 * or, if greater control is required, by providing a custom closure. For example:
914
+	 *        'Some_Class' => function () {
915
+	 *            return new Some_Class();
916
+	 *        },
917
+	 * This is required for instantiating dependencies
918
+	 * where an interface has been type hinted in a class constructor. For example:
919
+	 *        'Required_Interface' => function () {
920
+	 *            return new A_Class_That_Implements_Required_Interface();
921
+	 *        },
922
+	 */
923
+	protected function _register_core_class_loaders()
924
+	{
925
+		$this->_class_loaders = array(
926
+			// load_core
927
+			'EE_Dependency_Map'                            => function () {
928
+				return $this;
929
+			},
930
+			'EE_Capabilities'                              => 'load_core',
931
+			'EE_Encryption'                                => 'load_core',
932
+			'EE_Front_Controller'                          => 'load_core',
933
+			'EE_Module_Request_Router'                     => 'load_core',
934
+			'EE_Registry'                                  => 'load_core',
935
+			'EE_Request'                                   => function () {
936
+				return $this->legacy_request;
937
+			},
938
+			'EventEspresso\core\services\request\Request'  => function () {
939
+				return $this->request;
940
+			},
941
+			'EventEspresso\core\services\request\Response' => function () {
942
+				return $this->response;
943
+			},
944
+			'EE_Base'                                      => 'load_core',
945
+			'EE_Request_Handler'                           => 'load_core',
946
+			'EE_Session'                                   => 'load_core',
947
+			'EE_Cron_Tasks'                                => 'load_core',
948
+			'EE_System'                                    => 'load_core',
949
+			'EE_Maintenance_Mode'                          => 'load_core',
950
+			'EE_Register_CPTs'                             => 'load_core',
951
+			'EE_Admin'                                     => 'load_core',
952
+			'EE_CPT_Strategy'                              => 'load_core',
953
+			// load_class
954
+			'EE_Registration_Processor'                    => 'load_class',
955
+			// load_lib
956
+			'EE_Message_Resource_Manager'                  => 'load_lib',
957
+			'EE_Message_Type_Collection'                   => 'load_lib',
958
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
959
+			'EE_Messenger_Collection'                      => 'load_lib',
960
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
961
+			'EE_Messages_Processor'                        => 'load_lib',
962
+			'EE_Message_Repository'                        => 'load_lib',
963
+			'EE_Messages_Queue'                            => 'load_lib',
964
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
965
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
966
+			'EE_Payment_Method_Manager'                    => 'load_lib',
967
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
968
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
969
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
970
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
971
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
972
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
973
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
974
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
975
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
976
+			'EE_Messages_Generator'                        => function () {
977
+				return EE_Registry::instance()->load_lib(
978
+					'Messages_Generator',
979
+					array(),
980
+					false,
981
+					false
982
+				);
983
+			},
984
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
985
+				return EE_Registry::instance()->load_lib(
986
+					'Messages_Template_Defaults',
987
+					$arguments,
988
+					false,
989
+					false
990
+				);
991
+			},
992
+			// load_helper
993
+			'EEH_Parse_Shortcodes'                         => function () {
994
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
995
+					return new EEH_Parse_Shortcodes();
996
+				}
997
+				return null;
998
+			},
999
+			'EE_Template_Config'                           => function () {
1000
+				return EE_Config::instance()->template_settings;
1001
+			},
1002
+			'EE_Currency_Config'                           => function () {
1003
+				return EE_Config::instance()->currency;
1004
+			},
1005
+			'EE_Registration_Config'                       => function () {
1006
+				return EE_Config::instance()->registration;
1007
+			},
1008
+			'EE_Core_Config'                               => function () {
1009
+				return EE_Config::instance()->core;
1010
+			},
1011
+			'EventEspresso\core\services\loaders\Loader'   => function () {
1012
+				return LoaderFactory::getLoader();
1013
+			},
1014
+			'EE_Network_Config'                            => function () {
1015
+				return EE_Network_Config::instance();
1016
+			},
1017
+			'EE_Config'                                    => function () {
1018
+				return EE_Config::instance();
1019
+			},
1020
+			'EventEspresso\core\domain\Domain'             => function () {
1021
+				return DomainFactory::getEventEspressoCoreDomain();
1022
+			},
1023
+			'EE_Admin_Config'                              => function () {
1024
+				return EE_Config::instance()->admin;
1025
+			},
1026
+			'EE_Organization_Config'                       => function () {
1027
+				return EE_Config::instance()->organization;
1028
+			},
1029
+			'EE_Network_Core_Config'                       => function () {
1030
+				return EE_Network_Config::instance()->core;
1031
+			},
1032
+			'EE_Environment_Config'                        => function () {
1033
+				return EE_Config::instance()->environment;
1034
+			},
1035
+		);
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * can be used for supplying alternate names for classes,
1041
+	 * or for connecting interface names to instantiable classes
1042
+	 */
1043
+	protected function _register_core_aliases()
1044
+	{
1045
+		$aliases = array(
1046
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1047
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1048
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1049
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1050
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1051
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1052
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1053
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1054
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1055
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1056
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1057
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1058
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1059
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1060
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1061
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1062
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1063
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1064
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1065
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1066
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1067
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1068
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1069
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1070
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1071
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1072
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1073
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1074
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1075
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1076
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1077
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1078
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1079
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1080
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1081
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1082
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1083
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1084
+		);
1085
+		foreach ($aliases as $alias => $fqn) {
1086
+			if (is_array($fqn)) {
1087
+				foreach ($fqn as $class => $for_class) {
1088
+					$this->class_cache->addAlias($class, $alias, $for_class);
1089
+				}
1090
+				continue;
1091
+			}
1092
+			$this->class_cache->addAlias($fqn, $alias);
1093
+		}
1094
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1095
+			$this->class_cache->addAlias(
1096
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1097
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1098
+			);
1099
+		}
1100
+	}
1101
+
1102
+
1103
+	/**
1104
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1105
+	 * request Primarily used by unit tests.
1106
+	 */
1107
+	public function reset()
1108
+	{
1109
+		$this->_register_core_class_loaders();
1110
+		$this->_register_core_dependencies();
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * PLZ NOTE: a better name for this method would be is_alias()
1116
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1117
+	 * WHY?
1118
+	 * Because if a class is type hinting for a concretion,
1119
+	 * then why would we need to find another class to supply it?
1120
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1121
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1122
+	 * Don't go looking for some substitute.
1123
+	 * Whereas if a class is type hinting for an interface...
1124
+	 * then we need to find an actual class to use.
1125
+	 * So the interface IS the alias for some other FQN,
1126
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1127
+	 * represents some other class.
1128
+	 *
1129
+	 * @deprecated 4.9.62.p
1130
+	 * @param string $fqn
1131
+	 * @param string $for_class
1132
+	 * @return bool
1133
+	 */
1134
+	public function has_alias($fqn = '', $for_class = '')
1135
+	{
1136
+		return $this->isAlias($fqn, $for_class);
1137
+	}
1138
+
1139
+
1140
+	/**
1141
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1142
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1143
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1144
+	 *  for example:
1145
+	 *      if the following two entries were added to the _aliases array:
1146
+	 *          array(
1147
+	 *              'interface_alias'           => 'some\namespace\interface'
1148
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1149
+	 *          )
1150
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1151
+	 *      to load an instance of 'some\namespace\classname'
1152
+	 *
1153
+	 * @deprecated 4.9.62.p
1154
+	 * @param string $alias
1155
+	 * @param string $for_class
1156
+	 * @return string
1157
+	 */
1158
+	public function get_alias($alias = '', $for_class = '')
1159
+	{
1160
+		return $this->getFqnForAlias($alias, $for_class);
1161
+	}
1162 1162
 }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/PreviewEventDeletion.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@
 block discarded – undo
199 199
             if ($units_processed >= $batch_size) {
200 200
                 break;
201 201
             }
202
-            if (!$root_node instanceof ModelObjNode) {
202
+            if ( ! $root_node instanceof ModelObjNode) {
203 203
                 throw new InvalidClassException('ModelObjNode');
204 204
             }
205 205
             if ($root_node->isComplete()) {
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -36,149 +36,149 @@  discard block
 block discarded – undo
36 36
 class PreviewEventDeletion extends JobHandler
37 37
 {
38 38
 
39
-    /**
40
-     * @var NodeGroupDao
41
-     */
42
-    protected $model_obj_node_group_persister;
39
+	/**
40
+	 * @var NodeGroupDao
41
+	 */
42
+	protected $model_obj_node_group_persister;
43 43
 
44
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
45
-    {
46
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
47
-    }
44
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
45
+	{
46
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
47
+	}
48 48
 
49
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
49
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
50 50
 
51
-    /**
52
-     *
53
-     * @param JobParameters $job_parameters
54
-     * @return JobStepResponse
55
-     * @throws EE_Error
56
-     * @throws InvalidDataTypeException
57
-     * @throws InvalidInterfaceException
58
-     * @throws InvalidArgumentException
59
-     * @throws ReflectionException
60
-     */
61
-    public function create_job(JobParameters $job_parameters)
62
-    {
63
-        // Set the "root" model objects we will want to delete (record their ID and model)
64
-        $event_ids = $job_parameters->request_datum('EVT_IDs', array());
65
-        // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
66
-        // prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
67
-        // we have no UI to access them independent of events, so they may as well get deleted too.)
68
-        $roots = [];
69
-        foreach ($event_ids as $event_id) {
70
-            $roots[] = new ModelObjNode(
71
-                $event_id,
72
-                EEM_Event::instance()
73
-            );
74
-            // Also, we want to delete their related, non-global, tickets, prices and message templates
75
-            $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
76
-                [
77
-                    [
78
-                        'TKT_is_default' => false,
79
-                        'Datetime.EVT_ID' => $event_id
80
-                    ]
81
-                ]
82
-            );
83
-            foreach ($related_non_global_tickets as $ticket) {
84
-                $roots[] = new ModelObjNode(
85
-                    $ticket->ID(),
86
-                    $ticket->get_model(),
87
-                    ['Registration']
88
-                );
89
-            }
90
-            $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
91
-                [
92
-                    [
93
-                        'PRC_is_default' => false,
94
-                        'Ticket.Datetime.EVT_ID' => $event_id
95
-                    ]
96
-                ]
97
-            );
98
-            foreach ($related_non_global_prices as $price) {
99
-                $roots[] = new ModelObjNode(
100
-                    $price->ID(),
101
-                    $price->get_model()
102
-                );
103
-            }
104
-        }
105
-        $transactions_ids = $this->getTransactionsToDelete($event_ids);
106
-        foreach ($transactions_ids as $transaction_id) {
107
-            $roots[] = new ModelObjNode(
108
-                $transaction_id,
109
-                EEM_Transaction::instance(),
110
-                ['Registration']
111
-            );
112
-        }
113
-        $job_parameters->add_extra_data('roots', $roots);
114
-        // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
115
-        // an accurate count.)
116
-        $estimated_work_per_model_obj = 10;
117
-        $count_regs = EEM_Registration::instance()->count(
118
-            [
119
-                [
120
-                    'EVT_ID' => ['IN', $event_ids]
121
-                ]
122
-            ]
123
-        );
124
-        $job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
125
-        return new JobStepResponse(
126
-            $job_parameters,
127
-            esc_html__('Generating preview of data to be deleted...', 'event_espresso')
128
-        );
129
-    }
51
+	/**
52
+	 *
53
+	 * @param JobParameters $job_parameters
54
+	 * @return JobStepResponse
55
+	 * @throws EE_Error
56
+	 * @throws InvalidDataTypeException
57
+	 * @throws InvalidInterfaceException
58
+	 * @throws InvalidArgumentException
59
+	 * @throws ReflectionException
60
+	 */
61
+	public function create_job(JobParameters $job_parameters)
62
+	{
63
+		// Set the "root" model objects we will want to delete (record their ID and model)
64
+		$event_ids = $job_parameters->request_datum('EVT_IDs', array());
65
+		// Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
66
+		// prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
67
+		// we have no UI to access them independent of events, so they may as well get deleted too.)
68
+		$roots = [];
69
+		foreach ($event_ids as $event_id) {
70
+			$roots[] = new ModelObjNode(
71
+				$event_id,
72
+				EEM_Event::instance()
73
+			);
74
+			// Also, we want to delete their related, non-global, tickets, prices and message templates
75
+			$related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
76
+				[
77
+					[
78
+						'TKT_is_default' => false,
79
+						'Datetime.EVT_ID' => $event_id
80
+					]
81
+				]
82
+			);
83
+			foreach ($related_non_global_tickets as $ticket) {
84
+				$roots[] = new ModelObjNode(
85
+					$ticket->ID(),
86
+					$ticket->get_model(),
87
+					['Registration']
88
+				);
89
+			}
90
+			$related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
91
+				[
92
+					[
93
+						'PRC_is_default' => false,
94
+						'Ticket.Datetime.EVT_ID' => $event_id
95
+					]
96
+				]
97
+			);
98
+			foreach ($related_non_global_prices as $price) {
99
+				$roots[] = new ModelObjNode(
100
+					$price->ID(),
101
+					$price->get_model()
102
+				);
103
+			}
104
+		}
105
+		$transactions_ids = $this->getTransactionsToDelete($event_ids);
106
+		foreach ($transactions_ids as $transaction_id) {
107
+			$roots[] = new ModelObjNode(
108
+				$transaction_id,
109
+				EEM_Transaction::instance(),
110
+				['Registration']
111
+			);
112
+		}
113
+		$job_parameters->add_extra_data('roots', $roots);
114
+		// Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
115
+		// an accurate count.)
116
+		$estimated_work_per_model_obj = 10;
117
+		$count_regs = EEM_Registration::instance()->count(
118
+			[
119
+				[
120
+					'EVT_ID' => ['IN', $event_ids]
121
+				]
122
+			]
123
+		);
124
+		$job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
125
+		return new JobStepResponse(
126
+			$job_parameters,
127
+			esc_html__('Generating preview of data to be deleted...', 'event_espresso')
128
+		);
129
+	}
130 130
 
131
-    /**
132
-     * @since $VID:$
133
-     * @param EE_Base_Class[] $model_objs
134
-     * @param array $dont_traverse_models
135
-     * @return array
136
-     * @throws EE_Error
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     * @throws ReflectionException
141
-     */
142
-    protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
143
-    {
144
-        $nodes = [];
145
-        foreach ($model_objs as $model_obj) {
146
-            $nodes[] = new ModelObjNode(
147
-                $model_obj->ID(),
148
-                $model_obj->get_model(),
149
-                $dont_traverse_models
150
-            );
151
-        }
152
-        return $nodes;
153
-    }
131
+	/**
132
+	 * @since $VID:$
133
+	 * @param EE_Base_Class[] $model_objs
134
+	 * @param array $dont_traverse_models
135
+	 * @return array
136
+	 * @throws EE_Error
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 * @throws ReflectionException
141
+	 */
142
+	protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
143
+	{
144
+		$nodes = [];
145
+		foreach ($model_objs as $model_obj) {
146
+			$nodes[] = new ModelObjNode(
147
+				$model_obj->ID(),
148
+				$model_obj->get_model(),
149
+				$dont_traverse_models
150
+			);
151
+		}
152
+		return $nodes;
153
+	}
154 154
 
155
-    /**
156
-     * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
157
-     * (Ones that are related to other events can stay around until those other events are deleted too.)
158
-     * @since $VID:$
159
-     * @param $event_ids
160
-     * @return array of transaction IDs
161
-     */
162
-    protected function getTransactionsToDelete($event_ids)
163
-    {
164
-        if (empty($event_ids)) {
165
-            return [];
166
-        }
167
-        global $wpdb;
168
-        $event_ids = array_map(
169
-            'intval',
170
-            $event_ids
171
-        );
172
-        $imploded_sanitized_event_ids = implode(',', $event_ids);
173
-        // Select transactions with registrations for the events $event_ids which also don't have registrations
174
-        // for any events NOT in $event_ids.
175
-        // Notice the outer query searched for transactions whose registrations ARE in $event_ids,
176
-        // whereas the inner query checks if the outer query's transaction has any registrations that are
177
-        // NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
178
-        return array_map(
179
-            'intval',
180
-            $wpdb->get_col(
181
-                "SELECT 
155
+	/**
156
+	 * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
157
+	 * (Ones that are related to other events can stay around until those other events are deleted too.)
158
+	 * @since $VID:$
159
+	 * @param $event_ids
160
+	 * @return array of transaction IDs
161
+	 */
162
+	protected function getTransactionsToDelete($event_ids)
163
+	{
164
+		if (empty($event_ids)) {
165
+			return [];
166
+		}
167
+		global $wpdb;
168
+		$event_ids = array_map(
169
+			'intval',
170
+			$event_ids
171
+		);
172
+		$imploded_sanitized_event_ids = implode(',', $event_ids);
173
+		// Select transactions with registrations for the events $event_ids which also don't have registrations
174
+		// for any events NOT in $event_ids.
175
+		// Notice the outer query searched for transactions whose registrations ARE in $event_ids,
176
+		// whereas the inner query checks if the outer query's transaction has any registrations that are
177
+		// NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
178
+		return array_map(
179
+			'intval',
180
+			$wpdb->get_col(
181
+				"SELECT 
182 182
                       DISTINCT t.TXN_ID
183 183
                     FROM 
184 184
                       {$wpdb->prefix}esp_transaction t INNER JOIN 
@@ -196,84 +196,84 @@  discard block
 block discarded – undo
196 196
                            tsub.TXN_ID=t.TXN_ID AND
197 197
                            rsub.EVT_ID NOT IN ({$imploded_sanitized_event_ids})
198 198
                        )"
199
-            )
200
-        );
201
-    }
199
+			)
200
+		);
201
+	}
202 202
 
203
-    /**
204
-     * Performs another step of the job
205
-     * @param JobParameters $job_parameters
206
-     * @param int $batch_size
207
-     * @return JobStepResponse
208
-     * @throws BatchRequestException
209
-     */
210
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
211
-    {
212
-        // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
213
-        // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
214
-        // 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
215
-        $batch_size *= 3;
216
-        $units_processed = 0;
217
-        foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
218
-            if ($units_processed >= $batch_size) {
219
-                break;
220
-            }
221
-            if (!$root_node instanceof ModelObjNode) {
222
-                throw new InvalidClassException('ModelObjNode');
223
-            }
224
-            if ($root_node->isComplete()) {
225
-                continue;
226
-            }
227
-            $units_processed += $root_node->visit($batch_size - $units_processed);
228
-        }
229
-        $job_parameters->mark_processed($units_processed);
230
-        // If the most-recently processed root node is complete, we must be all done because we're doing them
231
-        // sequentially.
232
-        if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
233
-            $job_parameters->set_status(JobParameters::status_complete);
234
-            // Show a full progress bar.
235
-            $job_parameters->set_units_processed($job_parameters->job_size());
236
-            $deletion_job_code = $job_parameters->request_datum('deletion_job_code');
237
-            $this->model_obj_node_group_persister->persistModelObjNodesGroup(
238
-                $job_parameters->extra_datum('roots'),
239
-                $deletion_job_code
240
-            );
241
-            return new JobStepResponse(
242
-                $job_parameters,
243
-                esc_html__('Finished identifying items for deletion.', 'event_espresso'),
244
-                [
245
-                    'deletion_job_code' => $deletion_job_code
246
-                ]
247
-            );
248
-        } else {
249
-            // Because the job size was a guess, it may have likely been provden wrong. We don't want to show more work
250
-            // done than we originally said there would be. So adjust the estimate.
251
-            if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
252
-                $job_parameters->set_job_size($job_parameters->job_size() * 2);
253
-            }
254
-            return new JobStepResponse(
255
-                $job_parameters,
256
-                sprintf(
257
-                    esc_html__('Identified %d items for deletion.', 'event_espresso'),
258
-                    $units_processed
259
-                )
260
-            );
261
-        }
262
-    }
203
+	/**
204
+	 * Performs another step of the job
205
+	 * @param JobParameters $job_parameters
206
+	 * @param int $batch_size
207
+	 * @return JobStepResponse
208
+	 * @throws BatchRequestException
209
+	 */
210
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
211
+	{
212
+		// Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
213
+		// about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
214
+		// 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
215
+		$batch_size *= 3;
216
+		$units_processed = 0;
217
+		foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
218
+			if ($units_processed >= $batch_size) {
219
+				break;
220
+			}
221
+			if (!$root_node instanceof ModelObjNode) {
222
+				throw new InvalidClassException('ModelObjNode');
223
+			}
224
+			if ($root_node->isComplete()) {
225
+				continue;
226
+			}
227
+			$units_processed += $root_node->visit($batch_size - $units_processed);
228
+		}
229
+		$job_parameters->mark_processed($units_processed);
230
+		// If the most-recently processed root node is complete, we must be all done because we're doing them
231
+		// sequentially.
232
+		if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
233
+			$job_parameters->set_status(JobParameters::status_complete);
234
+			// Show a full progress bar.
235
+			$job_parameters->set_units_processed($job_parameters->job_size());
236
+			$deletion_job_code = $job_parameters->request_datum('deletion_job_code');
237
+			$this->model_obj_node_group_persister->persistModelObjNodesGroup(
238
+				$job_parameters->extra_datum('roots'),
239
+				$deletion_job_code
240
+			);
241
+			return new JobStepResponse(
242
+				$job_parameters,
243
+				esc_html__('Finished identifying items for deletion.', 'event_espresso'),
244
+				[
245
+					'deletion_job_code' => $deletion_job_code
246
+				]
247
+			);
248
+		} else {
249
+			// Because the job size was a guess, it may have likely been provden wrong. We don't want to show more work
250
+			// done than we originally said there would be. So adjust the estimate.
251
+			if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
252
+				$job_parameters->set_job_size($job_parameters->job_size() * 2);
253
+			}
254
+			return new JobStepResponse(
255
+				$job_parameters,
256
+				sprintf(
257
+					esc_html__('Identified %d items for deletion.', 'event_espresso'),
258
+					$units_processed
259
+				)
260
+			);
261
+		}
262
+	}
263 263
 
264
-    /**
265
-     * Performs any clean-up logic when we know the job is completed
266
-     * @param JobParameters $job_parameters
267
-     * @return JobStepResponse
268
-     */
269
-    public function cleanup_job(JobParameters $job_parameters)
270
-    {
271
-        // Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
272
-        return new JobStepResponse(
273
-            $job_parameters,
274
-            esc_html__('All done', 'event_espresso')
275
-        );
276
-    }
264
+	/**
265
+	 * Performs any clean-up logic when we know the job is completed
266
+	 * @param JobParameters $job_parameters
267
+	 * @return JobStepResponse
268
+	 */
269
+	public function cleanup_job(JobParameters $job_parameters)
270
+	{
271
+		// Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
272
+		return new JobStepResponse(
273
+			$job_parameters,
274
+			esc_html__('All done', 'event_espresso')
275
+		);
276
+	}
277 277
 }
278 278
 // End of file EventDeletion.php
279 279
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -9,11 +9,9 @@
 block discarded – undo
9 9
 use EEM_Registration;
10 10
 use EEM_Ticket;
11 11
 use EEM_Transaction;
12
-use EETests\bootstrap\CoreLoader;
13 12
 use EventEspresso\core\exceptions\InvalidClassException;
14 13
 use EventEspresso\core\exceptions\InvalidDataTypeException;
15 14
 use EventEspresso\core\exceptions\InvalidInterfaceException;
16
-use EventEspresso\core\services\loaders\LoaderFactory;
17 15
 use EventEspresso\core\services\orm\tree_traversal\ModelObjNode;
18 16
 use EventEspresso\core\services\orm\tree_traversal\NodeGroupDao;
19 17
 use EventEspressoBatchRequest\Helpers\BatchRequestException;
Please login to merge, or discard this patch.
core/services/orm/tree_traversal/ModelObjNode.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                 continue;
69 69
             }
70 70
             if ($relation instanceof EE_Has_Many_Relation) {
71
-                $this->nodes[ $relationName ] = new RelationNode(
71
+                $this->nodes[$relationName] = new RelationNode(
72 72
                     $this->id,
73 73
                     $this->model,
74 74
                     $relation->get_other_model(),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                     $relation->get_join_model()->get_this_model_name(),
80 80
                     $this->dont_traverse_models
81 81
                 )) {
82
-                $this->nodes[ $relation->get_join_model()->get_this_model_name() ] = new RelationNode(
82
+                $this->nodes[$relation->get_join_model()->get_this_model_name()] = new RelationNode(
83 83
                     $this->id,
84 84
                     $this->model,
85 85
                     $relation->get_join_model(),
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             // To save on space when serializing, only bother keeping a record of relation nodes that actually found
128 128
             // related model objects.
129 129
             if ($relation_node->isComplete() && $relation_node->countSubNodes() === 0) {
130
-                unset($this->nodes[ $model_name ]);
130
+                unset($this->nodes[$model_name]);
131 131
             }
132 132
             if ($num_identified >= $model_objects_to_identify) {
133 133
                 // ...but admit we're wrong if the work exceeded the budget.
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $tree['rels'] = null;
159 159
         } else {
160 160
             foreach ($this->nodes as $relation_name => $relation_node) {
161
-                $tree['rels'][ $relation_name ] = $relation_node->toArray();
161
+                $tree['rels'][$relation_name] = $relation_node->toArray();
162 162
             }
163 163
         }
164 164
         return $tree;
Please login to merge, or discard this patch.
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -22,204 +22,204 @@
 block discarded – undo
22 22
  */
23 23
 class ModelObjNode extends BaseNode
24 24
 {
25
-    /**
26
-     * @var int|string
27
-     */
28
-    protected $id;
25
+	/**
26
+	 * @var int|string
27
+	 */
28
+	protected $id;
29 29
 
30
-    /**
31
-     * @var EEM_Base
32
-     */
33
-    protected $model;
30
+	/**
31
+	 * @var EEM_Base
32
+	 */
33
+	protected $model;
34 34
 
35
-    /**
36
-     * @var RelationNode[]
37
-     */
38
-    protected $nodes;
35
+	/**
36
+	 * @var RelationNode[]
37
+	 */
38
+	protected $nodes;
39 39
 
40
-    /**
41
-     * We don't pass the model objects because this needs to serialize to something tiny for effiency.
42
-     * @param $model_obj_id
43
-     * @param EEM_Base $model
44
-     * @param array $dont_traverse_models array of model names we DON'T want to traverse.
45
-     */
46
-    public function __construct($model_obj_id, EEM_Base $model, array $dont_traverse_models = [])
47
-    {
48
-        $this->id = $model_obj_id;
49
-        $this->model = $model;
50
-        $this->dont_traverse_models = $dont_traverse_models;
51
-    }
40
+	/**
41
+	 * We don't pass the model objects because this needs to serialize to something tiny for effiency.
42
+	 * @param $model_obj_id
43
+	 * @param EEM_Base $model
44
+	 * @param array $dont_traverse_models array of model names we DON'T want to traverse.
45
+	 */
46
+	public function __construct($model_obj_id, EEM_Base $model, array $dont_traverse_models = [])
47
+	{
48
+		$this->id = $model_obj_id;
49
+		$this->model = $model;
50
+		$this->dont_traverse_models = $dont_traverse_models;
51
+	}
52 52
 
53
-    /**
54
-     * Creates a relation node for each relation of this model's relations.
55
-     * Does NOT call `discover` on them yet though.
56
-     * @since $VID:$
57
-     * @throws \EE_Error
58
-     * @throws InvalidDataTypeException
59
-     * @throws InvalidInterfaceException
60
-     * @throws InvalidArgumentException
61
-     * @throws ReflectionException
62
-     */
63
-    protected function discover()
64
-    {
65
-        $this->nodes = [];
66
-        foreach ($this->model->relation_settings() as $relationName => $relation) {
67
-            // Make sure this isn't one of the models we were told to not traverse into.
68
-            if (in_array($relationName, $this->dont_traverse_models)) {
69
-                continue;
70
-            }
71
-            if ($relation instanceof EE_Has_Many_Relation) {
72
-                $this->nodes[ $relationName ] = new RelationNode(
73
-                    $this->id,
74
-                    $this->model,
75
-                    $relation->get_other_model(),
76
-                    $this->dont_traverse_models
77
-                );
78
-            } elseif ($relation instanceof EE_HABTM_Relation &&
79
-                ! in_array(
80
-                    $relation->get_join_model()->get_this_model_name(),
81
-                    $this->dont_traverse_models
82
-                )) {
83
-                $this->nodes[ $relation->get_join_model()->get_this_model_name() ] = new RelationNode(
84
-                    $this->id,
85
-                    $this->model,
86
-                    $relation->get_join_model(),
87
-                    $this->dont_traverse_models
88
-                );
89
-            }
90
-        }
91
-        ksort($this->nodes);
92
-    }
53
+	/**
54
+	 * Creates a relation node for each relation of this model's relations.
55
+	 * Does NOT call `discover` on them yet though.
56
+	 * @since $VID:$
57
+	 * @throws \EE_Error
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws InvalidInterfaceException
60
+	 * @throws InvalidArgumentException
61
+	 * @throws ReflectionException
62
+	 */
63
+	protected function discover()
64
+	{
65
+		$this->nodes = [];
66
+		foreach ($this->model->relation_settings() as $relationName => $relation) {
67
+			// Make sure this isn't one of the models we were told to not traverse into.
68
+			if (in_array($relationName, $this->dont_traverse_models)) {
69
+				continue;
70
+			}
71
+			if ($relation instanceof EE_Has_Many_Relation) {
72
+				$this->nodes[ $relationName ] = new RelationNode(
73
+					$this->id,
74
+					$this->model,
75
+					$relation->get_other_model(),
76
+					$this->dont_traverse_models
77
+				);
78
+			} elseif ($relation instanceof EE_HABTM_Relation &&
79
+				! in_array(
80
+					$relation->get_join_model()->get_this_model_name(),
81
+					$this->dont_traverse_models
82
+				)) {
83
+				$this->nodes[ $relation->get_join_model()->get_this_model_name() ] = new RelationNode(
84
+					$this->id,
85
+					$this->model,
86
+					$relation->get_join_model(),
87
+					$this->dont_traverse_models
88
+				);
89
+			}
90
+		}
91
+		ksort($this->nodes);
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * Whether this item has already been initialized
97
-     */
98
-    protected function isDiscovered()
99
-    {
100
-        return $this->nodes !== null && is_array($this->nodes);
101
-    }
95
+	/**
96
+	 * Whether this item has already been initialized
97
+	 */
98
+	protected function isDiscovered()
99
+	{
100
+		return $this->nodes !== null && is_array($this->nodes);
101
+	}
102 102
 
103
-    /**
104
-     * @since $VID:$
105
-     * @return boolean
106
-     */
107
-    public function isComplete()
108
-    {
109
-        if ($this->complete === null) {
110
-            $this->complete = false;
111
-        }
112
-        return $this->complete;
113
-    }
103
+	/**
104
+	 * @since $VID:$
105
+	 * @return boolean
106
+	 */
107
+	public function isComplete()
108
+	{
109
+		if ($this->complete === null) {
110
+			$this->complete = false;
111
+		}
112
+		return $this->complete;
113
+	}
114 114
 
115
-    /**
116
-     * Triggers working on each child relation node that has work to do.
117
-     * @since $VID:$
118
-     * @param $model_objects_to_identify
119
-     * @return int units of work done
120
-     */
121
-    protected function work($model_objects_to_identify)
122
-    {
123
-        $num_identified = 0;
124
-        // Begin assuming we'll finish all the work on this node and its children...
125
-        $this->complete = true;
126
-        foreach ($this->nodes as $model_name => $relation_node) {
127
-            $num_identified += $relation_node->visit($model_objects_to_identify - $num_identified);
128
-            // To save on space when serializing, only bother keeping a record of relation nodes that actually found
129
-            // related model objects.
130
-            if ($relation_node->isComplete() && $relation_node->countSubNodes() === 0) {
131
-                unset($this->nodes[ $model_name ]);
132
-            }
133
-            if ($num_identified >= $model_objects_to_identify) {
134
-                // ...but admit we're wrong if the work exceeded the budget.
135
-                $this->complete = false;
136
-                break;
137
-            }
138
-        }
139
-        return $num_identified;
140
-    }
115
+	/**
116
+	 * Triggers working on each child relation node that has work to do.
117
+	 * @since $VID:$
118
+	 * @param $model_objects_to_identify
119
+	 * @return int units of work done
120
+	 */
121
+	protected function work($model_objects_to_identify)
122
+	{
123
+		$num_identified = 0;
124
+		// Begin assuming we'll finish all the work on this node and its children...
125
+		$this->complete = true;
126
+		foreach ($this->nodes as $model_name => $relation_node) {
127
+			$num_identified += $relation_node->visit($model_objects_to_identify - $num_identified);
128
+			// To save on space when serializing, only bother keeping a record of relation nodes that actually found
129
+			// related model objects.
130
+			if ($relation_node->isComplete() && $relation_node->countSubNodes() === 0) {
131
+				unset($this->nodes[ $model_name ]);
132
+			}
133
+			if ($num_identified >= $model_objects_to_identify) {
134
+				// ...but admit we're wrong if the work exceeded the budget.
135
+				$this->complete = false;
136
+				break;
137
+			}
138
+		}
139
+		return $num_identified;
140
+	}
141 141
 
142
-    /**
143
-     * @since $VID:$
144
-     * @return array
145
-     * @throws \EE_Error
146
-     * @throws InvalidDataTypeException
147
-     * @throws InvalidInterfaceException
148
-     * @throws InvalidArgumentException
149
-     * @throws ReflectionException
150
-     */
151
-    public function toArray()
152
-    {
153
-        $tree = [
154
-            'id' => $this->id,
155
-            'complete' => $this->isComplete(),
156
-            'rels' => []
157
-        ];
158
-        if ($this->nodes === null) {
159
-            $tree['rels'] = null;
160
-        } else {
161
-            foreach ($this->nodes as $relation_name => $relation_node) {
162
-                $tree['rels'][ $relation_name ] = $relation_node->toArray();
163
-            }
164
-        }
165
-        return $tree;
166
-    }
142
+	/**
143
+	 * @since $VID:$
144
+	 * @return array
145
+	 * @throws \EE_Error
146
+	 * @throws InvalidDataTypeException
147
+	 * @throws InvalidInterfaceException
148
+	 * @throws InvalidArgumentException
149
+	 * @throws ReflectionException
150
+	 */
151
+	public function toArray()
152
+	{
153
+		$tree = [
154
+			'id' => $this->id,
155
+			'complete' => $this->isComplete(),
156
+			'rels' => []
157
+		];
158
+		if ($this->nodes === null) {
159
+			$tree['rels'] = null;
160
+		} else {
161
+			foreach ($this->nodes as $relation_name => $relation_node) {
162
+				$tree['rels'][ $relation_name ] = $relation_node->toArray();
163
+			}
164
+		}
165
+		return $tree;
166
+	}
167 167
 
168
-    /**
169
-     * @since $VID:$
170
-     * @return array|mixed
171
-     * @throws InvalidArgumentException
172
-     * @throws InvalidDataTypeException
173
-     * @throws InvalidInterfaceException
174
-     * @throws ReflectionException
175
-     * @throws \EE_Error
176
-     */
177
-    public function getIds()
178
-    {
179
-        $ids = [
180
-            $this->model->get_this_model_name() => [
181
-                $this->id => $this->id
182
-            ]
183
-        ];
184
-        if ($this->nodes && is_array($this->nodes)) {
185
-            foreach ($this->nodes as $relation_node) {
186
-                $ids = array_replace_recursive($ids, $relation_node->getIds());
187
-            }
188
-        }
189
-        return $ids;
190
-    }
168
+	/**
169
+	 * @since $VID:$
170
+	 * @return array|mixed
171
+	 * @throws InvalidArgumentException
172
+	 * @throws InvalidDataTypeException
173
+	 * @throws InvalidInterfaceException
174
+	 * @throws ReflectionException
175
+	 * @throws \EE_Error
176
+	 */
177
+	public function getIds()
178
+	{
179
+		$ids = [
180
+			$this->model->get_this_model_name() => [
181
+				$this->id => $this->id
182
+			]
183
+		];
184
+		if ($this->nodes && is_array($this->nodes)) {
185
+			foreach ($this->nodes as $relation_node) {
186
+				$ids = array_replace_recursive($ids, $relation_node->getIds());
187
+			}
188
+		}
189
+		return $ids;
190
+	}
191 191
 
192
-    /**
193
-     * Don't serialize the models. Just record their names on some dynamic properties.
194
-     * @since $VID:$
195
-     */
196
-    public function __sleep()
197
-    {
198
-        $this->m = $this->model->get_this_model_name();
199
-        return array_merge(
200
-            [
201
-                'm',
202
-                'id',
203
-                'nodes',
204
-            ],
205
-            parent::__sleep()
206
-        );
207
-    }
192
+	/**
193
+	 * Don't serialize the models. Just record their names on some dynamic properties.
194
+	 * @since $VID:$
195
+	 */
196
+	public function __sleep()
197
+	{
198
+		$this->m = $this->model->get_this_model_name();
199
+		return array_merge(
200
+			[
201
+				'm',
202
+				'id',
203
+				'nodes',
204
+			],
205
+			parent::__sleep()
206
+		);
207
+	}
208 208
 
209
-    /**
210
-     * Use the dynamic properties to instantiate the models we use.
211
-     * @since $VID:$
212
-     * @throws EE_Error
213
-     * @throws InvalidArgumentException
214
-     * @throws InvalidDataTypeException
215
-     * @throws InvalidInterfaceException
216
-     * @throws ReflectionException
217
-     */
218
-    public function __wakeup()
219
-    {
220
-        $this->model = EE_Registry::instance()->load_model($this->m);
221
-        parent::__wakeup();
222
-    }
209
+	/**
210
+	 * Use the dynamic properties to instantiate the models we use.
211
+	 * @since $VID:$
212
+	 * @throws EE_Error
213
+	 * @throws InvalidArgumentException
214
+	 * @throws InvalidDataTypeException
215
+	 * @throws InvalidInterfaceException
216
+	 * @throws ReflectionException
217
+	 */
218
+	public function __wakeup()
219
+	{
220
+		$this->model = EE_Registry::instance()->load_model($this->m);
221
+		parent::__wakeup();
222
+	}
223 223
 }
224 224
 // End of file Visitor.php
225 225
 // Location: EventEspresso\core\services\orm\tree_traversal/Visitor.php
Please login to merge, or discard this patch.
admin_pages/events/form_sections/ConfirmEventDeletionForm.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use EE_Checkbox_Multi_Input;
6 6
 use EE_Event;
7
-use EE_Form_Section_HTML;
8
-use EEH_HTML;
9 7
 use EEM_Event;
10 8
 use EventEspresso\core\exceptions\UnexpectedEntityException;
11 9
 
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -22,55 +22,55 @@
 block discarded – undo
22 22
  */
23 23
 class ConfirmEventDeletionForm extends \EE_Form_Section_Proper
24 24
 {
25
-    /**
26
-     * @var EE_Event[]
27
-     */
28
-    protected $events;
29
-    public function __construct($event_ids, $options_array = array())
30
-    {
31
-        if (! isset($options_array['subsections'])) {
32
-            $options_array['subsections'] = [];
33
-        }
34
-        if (! isset($options_array['subsections']['events'])) {
35
-            $events_subsection = new \EE_Form_Section_Proper();
36
-            $options_array['subsections']['events'] = $events_subsection;
37
-        }
38
-        $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39
-            [
40
-                [
41
-                    'EVT_ID' => ['IN',$event_ids]
42
-                ]
43
-            ]
44
-        );
45
-        if (! is_array($events)) {
46
-            throw new UnexpectedEntityException($event_ids, 'array');
47
-        }
48
-        $this->events = $events;
49
-        $events_inputs = [
50
-        ];
51
-        foreach ($events as $event) {
52
-            $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
53
-                [
54
-                    'yes' => $event->name(),
55
-                ],
56
-                [
57
-                    'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
58
-                    'required' => true
59
-                ]
60
-            );
61
-        }
62
-        $events_subsection->add_subsections($events_inputs);
63
-        $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
64
-            [
65
-                'yes' => esc_html__('I have backed up my database.', 'event_espresso')
66
-            ],
67
-            [
68
-                'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
69
-                'required' => true
70
-            ]
71
-        );
72
-        parent::__construct($options_array);
73
-    }
25
+	/**
26
+	 * @var EE_Event[]
27
+	 */
28
+	protected $events;
29
+	public function __construct($event_ids, $options_array = array())
30
+	{
31
+		if (! isset($options_array['subsections'])) {
32
+			$options_array['subsections'] = [];
33
+		}
34
+		if (! isset($options_array['subsections']['events'])) {
35
+			$events_subsection = new \EE_Form_Section_Proper();
36
+			$options_array['subsections']['events'] = $events_subsection;
37
+		}
38
+		$events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39
+			[
40
+				[
41
+					'EVT_ID' => ['IN',$event_ids]
42
+				]
43
+			]
44
+		);
45
+		if (! is_array($events)) {
46
+			throw new UnexpectedEntityException($event_ids, 'array');
47
+		}
48
+		$this->events = $events;
49
+		$events_inputs = [
50
+		];
51
+		foreach ($events as $event) {
52
+			$events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
53
+				[
54
+					'yes' => $event->name(),
55
+				],
56
+				[
57
+					'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
58
+					'required' => true
59
+				]
60
+			);
61
+		}
62
+		$events_subsection->add_subsections($events_inputs);
63
+		$options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
64
+			[
65
+				'yes' => esc_html__('I have backed up my database.', 'event_espresso')
66
+			],
67
+			[
68
+				'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
69
+				'required' => true
70
+			]
71
+		);
72
+		parent::__construct($options_array);
73
+	}
74 74
 }
75 75
 // End of file ConfirmEventDeletionForm.php
76 76
 // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,28 +28,28 @@
 block discarded – undo
28 28
     protected $events;
29 29
     public function __construct($event_ids, $options_array = array())
30 30
     {
31
-        if (! isset($options_array['subsections'])) {
31
+        if ( ! isset($options_array['subsections'])) {
32 32
             $options_array['subsections'] = [];
33 33
         }
34
-        if (! isset($options_array['subsections']['events'])) {
34
+        if ( ! isset($options_array['subsections']['events'])) {
35 35
             $events_subsection = new \EE_Form_Section_Proper();
36 36
             $options_array['subsections']['events'] = $events_subsection;
37 37
         }
38 38
         $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39 39
             [
40 40
                 [
41
-                    'EVT_ID' => ['IN',$event_ids]
41
+                    'EVT_ID' => ['IN', $event_ids]
42 42
                 ]
43 43
             ]
44 44
         );
45
-        if (! is_array($events)) {
45
+        if ( ! is_array($events)) {
46 46
             throw new UnexpectedEntityException($event_ids, 'array');
47 47
         }
48 48
         $this->events = $events;
49 49
         $events_inputs = [
50 50
         ];
51 51
         foreach ($events as $event) {
52
-            $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
52
+            $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input(
53 53
                 [
54 54
                     'yes' => $event->name(),
55 55
                 ],
Please login to merge, or discard this patch.
admin_pages/events/templates/event_preview_deletion.template.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,97 +1,97 @@
 block discarded – undo
1 1
 <h2><?php esc_html_e('Please Confirm You Want to Permanently Delete the Following Data', 'event_espresso'); ?></h2>
2 2
 <h3>
3 3
     <?php
4
-    printf(
5
-        esc_html(
6
-            // translators: 1: number of events
7
-            _n('%1$d Event', '%1$d Events', count($events), 'event_espresso')
8
-        ),
9
-        count($events)
10
-    );
11
-    ?>
4
+	printf(
5
+		esc_html(
6
+			// translators: 1: number of events
7
+			_n('%1$d Event', '%1$d Events', count($events), 'event_espresso')
8
+		),
9
+		count($events)
10
+	);
11
+	?>
12 12
 </h3>
13 13
 <ul>
14 14
     <?php
15
-    foreach ($events as $event) {
16
-        ?>
15
+	foreach ($events as $event) {
16
+		?>
17 17
         <li>
18 18
             <?php echo $event->name(); ?>
19 19
         </li>
20 20
         <?php
21
-    }
22
-    ?>
21
+	}
22
+	?>
23 23
 </ul>
24 24
 <h3>
25 25
     <?php
26
-    printf(
27
-        esc_html(
28
-            // translators: 1: number of datetimes
29
-            _n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso')
30
-        ),
31
-        count($datetimes)
32
-    );
33
-    ?>
26
+	printf(
27
+		esc_html(
28
+			// translators: 1: number of datetimes
29
+			_n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso')
30
+		),
31
+		count($datetimes)
32
+	);
33
+	?>
34 34
 </h3>
35 35
 <ul>
36 36
     <?php
37
-    foreach ($datetimes as $datetime) {
38
-        ?>
37
+	foreach ($datetimes as $datetime) {
38
+		?>
39 39
         <li>
40 40
             <?php echo $datetime->get_dtt_display_name(true); ?>
41 41
         </li>
42 42
         <?php
43
-    }
44
-    ?>
43
+	}
44
+	?>
45 45
 </ul>
46 46
 <h3>
47 47
     <?php
48
-    printf(
49
-        esc_html(
50
-            _n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso')
51
-        ),
52
-        $reg_count
53
-    );
54
-    ?>
48
+	printf(
49
+		esc_html(
50
+			_n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso')
51
+		),
52
+		$reg_count
53
+	);
54
+	?>
55 55
 </h3>
56 56
 <?php
57 57
 if ($reg_count > count($registrations)) {
58
-    ?>
58
+	?>
59 59
     <p class="notice">
60 60
         <?php
61
-        printf(
62
-            esc_html__('Only showing first %1$d.', 'event_espresso'),
63
-            count($registrations)
64
-        );
65
-        ?>
61
+		printf(
62
+			esc_html__('Only showing first %1$d.', 'event_espresso'),
63
+			count($registrations)
64
+		);
65
+		?>
66 66
     </p>
67 67
     <?php
68 68
 }
69 69
 ?>
70 70
 <?php
71 71
 if ($reg_count > 0) {
72
-    ?>
72
+	?>
73 73
     <p><?php esc_html_e('Note: contacts will not be deleted, only their registrations for the enumerated events.', 'event_espresso'); ?></p>
74 74
     <?php
75 75
 }
76 76
 ?>
77 77
 <ul>
78 78
     <?php
79
-    foreach ($registrations as $registration) {
80
-        ?>
79
+	foreach ($registrations as $registration) {
80
+		?>
81 81
         <li>
82 82
             <?php
83
-            printf(
84
-                esc_html(
85
-                    _x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso')
86
-                ),
87
-                $registration->attendeeName(true),
88
-                $registration->count(),
89
-                $registration->group_size()
90
-            ); ?>
83
+			printf(
84
+				esc_html(
85
+					_x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso')
86
+				),
87
+				$registration->attendeeName(true),
88
+				$registration->count(),
89
+				$registration->group_size()
90
+			); ?>
91 91
         </li>
92 92
         <?php
93
-    }
94
-    ?>
93
+	}
94
+	?>
95 95
 </ul>
96 96
 <form action="<?php echo $form_url; ?>" method="POST">
97 97
     <?php echo $form->get_html_and_js(); ?>
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 1 patch
Indentation   +2560 added lines, -2560 removed lines patch added patch discarded remove patch
@@ -13,2564 +13,2564 @@
 block discarded – undo
13 13
 class Transactions_Admin_Page extends EE_Admin_Page
14 14
 {
15 15
 
16
-    /**
17
-     * @var EE_Transaction
18
-     */
19
-    private $_transaction;
20
-
21
-    /**
22
-     * @var EE_Session
23
-     */
24
-    private $_session;
25
-
26
-    /**
27
-     * @var array $_txn_status
28
-     */
29
-    private static $_txn_status;
30
-
31
-    /**
32
-     * @var array $_pay_status
33
-     */
34
-    private static $_pay_status;
35
-
36
-    /**
37
-     * @var array $_existing_reg_payment_REG_IDs
38
-     */
39
-    protected $_existing_reg_payment_REG_IDs;
40
-
41
-
42
-    /**
43
-     *    _init_page_props
44
-     *
45
-     * @return void
46
-     */
47
-    protected function _init_page_props()
48
-    {
49
-        $this->page_slug = TXN_PG_SLUG;
50
-        $this->page_label = esc_html__('Transactions', 'event_espresso');
51
-        $this->_admin_base_url = TXN_ADMIN_URL;
52
-        $this->_admin_base_path = TXN_ADMIN;
53
-    }
54
-
55
-
56
-    /**
57
-     *    _ajax_hooks
58
-     *
59
-     * @return void
60
-     */
61
-    protected function _ajax_hooks()
62
-    {
63
-        add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
64
-        add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
65
-        add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
66
-    }
67
-
68
-
69
-    /**
70
-     *    _define_page_props
71
-     *
72
-     * @return void
73
-     */
74
-    protected function _define_page_props()
75
-    {
76
-        $this->_admin_page_title = $this->page_label;
77
-        $this->_labels = array(
78
-            'buttons' => array(
79
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
-            ),
83
-        );
84
-    }
85
-
86
-
87
-    /**
88
-     *        grab url requests and route them
89
-     *
90
-     * @access private
91
-     * @return void
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     */
97
-    public function _set_page_routes()
98
-    {
99
-
100
-        $this->_set_transaction_status_array();
101
-
102
-        $txn_id = ! empty($this->_req_data['TXN_ID'])
103
-                  && ! is_array($this->_req_data['TXN_ID'])
104
-            ? $this->_req_data['TXN_ID']
105
-            : 0;
106
-
107
-        $this->_page_routes = array(
108
-
109
-            'default' => array(
110
-                'func'       => '_transactions_overview_list_table',
111
-                'capability' => 'ee_read_transactions',
112
-            ),
113
-
114
-            'view_transaction' => array(
115
-                'func'       => '_transaction_details',
116
-                'capability' => 'ee_read_transaction',
117
-                'obj_id'     => $txn_id,
118
-            ),
119
-
120
-            'send_payment_reminder' => array(
121
-                'func'       => '_send_payment_reminder',
122
-                'noheader'   => true,
123
-                'capability' => 'ee_send_message',
124
-            ),
125
-
126
-            'espresso_apply_payment' => array(
127
-                'func'       => 'apply_payments_or_refunds',
128
-                'noheader'   => true,
129
-                'capability' => 'ee_edit_payments',
130
-            ),
131
-
132
-            'espresso_apply_refund' => array(
133
-                'func'       => 'apply_payments_or_refunds',
134
-                'noheader'   => true,
135
-                'capability' => 'ee_edit_payments',
136
-            ),
137
-
138
-            'espresso_delete_payment' => array(
139
-                'func'       => 'delete_payment',
140
-                'noheader'   => true,
141
-                'capability' => 'ee_delete_payments',
142
-            ),
143
-
144
-            'espresso_recalculate_line_items' => array(
145
-                'func'       => 'recalculateLineItems',
146
-                'noheader'   => true,
147
-                'capability' => 'ee_edit_payments',
148
-            ),
149
-
150
-        );
151
-    }
152
-
153
-
154
-    protected function _set_page_config()
155
-    {
156
-        $this->_page_config = array(
157
-            'default'          => array(
158
-                'nav'           => array(
159
-                    'label' => esc_html__('Overview', 'event_espresso'),
160
-                    'order' => 10,
161
-                ),
162
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
163
-                'help_tabs'     => array(
164
-                    'transactions_overview_help_tab'                       => array(
165
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
166
-                        'filename' => 'transactions_overview',
167
-                    ),
168
-                    'transactions_overview_table_column_headings_help_tab' => array(
169
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
170
-                        'filename' => 'transactions_overview_table_column_headings',
171
-                    ),
172
-                    'transactions_overview_views_filters_help_tab'         => array(
173
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
174
-                        'filename' => 'transactions_overview_views_filters_search',
175
-                    ),
176
-                ),
177
-                'help_tour'     => array('Transactions_Overview_Help_Tour'),
178
-                /**
179
-                 * commented out because currently we are not displaying tips for transaction list table status but this
180
-                 * may change in a later iteration so want to keep the code for then.
181
-                 */
182
-                // 'qtips' => array( 'Transactions_List_Table_Tips' ),
183
-                'require_nonce' => false,
184
-            ),
185
-            'view_transaction' => array(
186
-                'nav'       => array(
187
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
188
-                    'order'      => 5,
189
-                    'url'        => isset($this->_req_data['TXN_ID'])
190
-                        ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
191
-                        : $this->_admin_base_url,
192
-                    'persistent' => false,
193
-                ),
194
-                'help_tabs' => array(
195
-                    'transactions_view_transaction_help_tab'                                              => array(
196
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
197
-                        'filename' => 'transactions_view_transaction',
198
-                    ),
199
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
200
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
201
-                        'filename' => 'transactions_view_transaction_transaction_details_table',
202
-                    ),
203
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => array(
204
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
205
-                        'filename' => 'transactions_view_transaction_attendees_registered',
206
-                    ),
207
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
208
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
209
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
210
-                    ),
211
-                ),
212
-                'qtips'     => array('Transaction_Details_Tips'),
213
-                'help_tour' => array('Transaction_Details_Help_Tour'),
214
-                'metaboxes' => array('_transaction_details_metaboxes'),
215
-
216
-                'require_nonce' => false,
217
-            ),
218
-        );
219
-    }
220
-
221
-
222
-    /**
223
-     * The below methods aren't used by this class currently
224
-     */
225
-    protected function _add_screen_options()
226
-    {
227
-        // noop
228
-    }
229
-
230
-
231
-    protected function _add_feature_pointers()
232
-    {
233
-        // noop
234
-    }
235
-
236
-
237
-    public function admin_init()
238
-    {
239
-        // IF a registration was JUST added via the admin...
240
-        if (isset(
241
-            $this->_req_data['redirect_from'],
242
-            $this->_req_data['EVT_ID'],
243
-            $this->_req_data['event_name']
244
-        )) {
245
-            // then set a cookie so that we can block any attempts to use
246
-            // the back button as a way to enter another registration.
247
-            setcookie(
248
-                'ee_registration_added',
249
-                $this->_req_data['EVT_ID'],
250
-                time() + WEEK_IN_SECONDS,
251
-                '/'
252
-            );
253
-            // and update the global
254
-            $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
255
-        }
256
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
257
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
258
-            'event_espresso'
259
-        );
260
-        EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
261
-            'An error occurred! Please refresh the page and try again.',
262
-            'event_espresso'
263
-        );
264
-        EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
265
-        EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
266
-        EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
267
-        EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
268
-            'This transaction has been overpaid ! Payments Total',
269
-            'event_espresso'
270
-        );
271
-    }
272
-
273
-
274
-    public function admin_notices()
275
-    {
276
-        // noop
277
-    }
278
-
279
-
280
-    public function admin_footer_scripts()
281
-    {
282
-        // noop
283
-    }
284
-
285
-
286
-    /**
287
-     * _set_transaction_status_array
288
-     * sets list of transaction statuses
289
-     *
290
-     * @access private
291
-     * @return void
292
-     * @throws EE_Error
293
-     * @throws InvalidArgumentException
294
-     * @throws InvalidDataTypeException
295
-     * @throws InvalidInterfaceException
296
-     */
297
-    private function _set_transaction_status_array()
298
-    {
299
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
300
-    }
301
-
302
-
303
-    /**
304
-     * get_transaction_status_array
305
-     * return the transaction status array for wp_list_table
306
-     *
307
-     * @access public
308
-     * @return array
309
-     */
310
-    public function get_transaction_status_array()
311
-    {
312
-        return self::$_txn_status;
313
-    }
314
-
315
-
316
-    /**
317
-     *    get list of payment statuses
318
-     *
319
-     * @access private
320
-     * @return void
321
-     * @throws EE_Error
322
-     * @throws InvalidArgumentException
323
-     * @throws InvalidDataTypeException
324
-     * @throws InvalidInterfaceException
325
-     */
326
-    private function _get_payment_status_array()
327
-    {
328
-        self::$_pay_status = EEM_Payment::instance()->status_array(true);
329
-        $this->_template_args['payment_status'] = self::$_pay_status;
330
-    }
331
-
332
-
333
-    /**
334
-     *    _add_screen_options_default
335
-     *
336
-     * @access protected
337
-     * @return void
338
-     * @throws InvalidArgumentException
339
-     * @throws InvalidDataTypeException
340
-     * @throws InvalidInterfaceException
341
-     */
342
-    protected function _add_screen_options_default()
343
-    {
344
-        $this->_per_page_screen_option();
345
-    }
346
-
347
-
348
-    /**
349
-     * load_scripts_styles
350
-     *
351
-     * @access public
352
-     * @return void
353
-     */
354
-    public function load_scripts_styles()
355
-    {
356
-        // enqueue style
357
-        wp_register_style(
358
-            'espresso_txn',
359
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
360
-            array(),
361
-            EVENT_ESPRESSO_VERSION
362
-        );
363
-        wp_enqueue_style('espresso_txn');
364
-        // scripts
365
-        wp_register_script(
366
-            'espresso_txn',
367
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
368
-            array(
369
-                'ee_admin_js',
370
-                'ee-datepicker',
371
-                'jquery-ui-datepicker',
372
-                'jquery-ui-draggable',
373
-                'ee-dialog',
374
-                'ee-accounting',
375
-                'ee-serialize-full-array',
376
-            ),
377
-            EVENT_ESPRESSO_VERSION,
378
-            true
379
-        );
380
-        wp_enqueue_script('espresso_txn');
381
-    }
382
-
383
-
384
-    /**
385
-     *    load_scripts_styles_view_transaction
386
-     *
387
-     * @access public
388
-     * @return void
389
-     */
390
-    public function load_scripts_styles_view_transaction()
391
-    {
392
-        // styles
393
-        wp_enqueue_style('espresso-ui-theme');
394
-    }
395
-
396
-
397
-    /**
398
-     *    load_scripts_styles_default
399
-     *
400
-     * @access public
401
-     * @return void
402
-     */
403
-    public function load_scripts_styles_default()
404
-    {
405
-        // styles
406
-        wp_enqueue_style('espresso-ui-theme');
407
-    }
408
-
409
-
410
-    /**
411
-     *    _set_list_table_views_default
412
-     *
413
-     * @access protected
414
-     * @return void
415
-     */
416
-    protected function _set_list_table_views_default()
417
-    {
418
-        $this->_views = array(
419
-            'all'        => array(
420
-                'slug'  => 'all',
421
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
422
-                'count' => 0,
423
-            ),
424
-            'abandoned'  => array(
425
-                'slug'  => 'abandoned',
426
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
427
-                'count' => 0,
428
-            ),
429
-            'incomplete' => array(
430
-                'slug'  => 'incomplete',
431
-                'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
432
-                'count' => 0,
433
-            ),
434
-        );
435
-        if (/**
436
-         * Filters whether a link to the "Failed Transactions" list table
437
-         * appears on the Transactions Admin Page list table.
438
-         * List display can be turned back on via the following:
439
-         * add_filter(
440
-         *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
441
-         *     '__return_true'
442
-         * );
443
-         *
444
-         * @since 4.9.70.p
445
-         * @param boolean                 $display_failed_txns_list
446
-         * @param Transactions_Admin_Page $this
447
-         */
448
-        apply_filters(
449
-            'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
450
-            false,
451
-            $this
452
-        )
453
-        ) {
454
-            $this->_views['failed'] = array(
455
-                'slug'  => 'failed',
456
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
457
-                'count' => 0,
458
-            );
459
-        }
460
-    }
461
-
462
-
463
-    /**
464
-     * _set_transaction_object
465
-     * This sets the _transaction property for the transaction details screen
466
-     *
467
-     * @access private
468
-     * @return void
469
-     * @throws EE_Error
470
-     * @throws InvalidArgumentException
471
-     * @throws RuntimeException
472
-     * @throws InvalidDataTypeException
473
-     * @throws InvalidInterfaceException
474
-     * @throws ReflectionException
475
-     */
476
-    private function _set_transaction_object()
477
-    {
478
-        if ($this->_transaction instanceof EE_Transaction) {
479
-            return;
480
-        } //get out we've already set the object
481
-
482
-        $TXN_ID = ! empty($this->_req_data['TXN_ID'])
483
-            ? absint($this->_req_data['TXN_ID'])
484
-            : false;
485
-
486
-        // get transaction object
487
-        $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
488
-        $this->_session = $this->_transaction instanceof EE_Transaction
489
-            ? $this->_transaction->session_data()
490
-            : null;
491
-        if ($this->_transaction instanceof EE_Transaction) {
492
-            $this->_transaction->verify_abandoned_transaction_status();
493
-        }
494
-
495
-        if (! $this->_transaction instanceof EE_Transaction) {
496
-            $error_msg = sprintf(
497
-                esc_html__(
498
-                    'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
499
-                    'event_espresso'
500
-                ),
501
-                $TXN_ID
502
-            );
503
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
504
-        }
505
-    }
506
-
507
-
508
-    /**
509
-     *    _transaction_legend_items
510
-     *
511
-     * @access protected
512
-     * @return array
513
-     * @throws EE_Error
514
-     * @throws InvalidArgumentException
515
-     * @throws ReflectionException
516
-     * @throws InvalidDataTypeException
517
-     * @throws InvalidInterfaceException
518
-     */
519
-    protected function _transaction_legend_items()
520
-    {
521
-        EE_Registry::instance()->load_helper('MSG_Template');
522
-        $items = array();
523
-
524
-        if (EE_Registry::instance()->CAP->current_user_can(
525
-            'ee_read_global_messages',
526
-            'view_filtered_messages'
527
-        )) {
528
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
529
-            if (is_array($related_for_icon)
530
-                && isset($related_for_icon['css_class'], $related_for_icon['label'])
531
-            ) {
532
-                $items['view_related_messages'] = array(
533
-                    'class' => $related_for_icon['css_class'],
534
-                    'desc'  => $related_for_icon['label'],
535
-                );
536
-            }
537
-        }
538
-
539
-        $items = apply_filters(
540
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
541
-            array_merge(
542
-                $items,
543
-                array(
544
-                    'view_details'          => array(
545
-                        'class' => 'dashicons dashicons-cart',
546
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
547
-                    ),
548
-                    'view_invoice'          => array(
549
-                        'class' => 'dashicons dashicons-media-spreadsheet',
550
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
551
-                    ),
552
-                    'view_receipt'          => array(
553
-                        'class' => 'dashicons dashicons-media-default',
554
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
555
-                    ),
556
-                    'view_registration'     => array(
557
-                        'class' => 'dashicons dashicons-clipboard',
558
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso'),
559
-                    ),
560
-                    'payment_overview_link' => array(
561
-                        'class' => 'dashicons dashicons-money',
562
-                        'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
563
-                    ),
564
-                )
565
-            )
566
-        );
567
-
568
-        if (EEH_MSG_Template::is_mt_active('payment_reminder')
569
-            && EE_Registry::instance()->CAP->current_user_can(
570
-                'ee_send_message',
571
-                'espresso_transactions_send_payment_reminder'
572
-            )
573
-        ) {
574
-            $items['send_payment_reminder'] = array(
575
-                'class' => 'dashicons dashicons-email-alt',
576
-                'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
577
-            );
578
-        } else {
579
-            $items['blank*'] = array(
580
-                'class' => '',
581
-                'desc'  => '',
582
-            );
583
-        }
584
-        $more_items = apply_filters(
585
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
586
-            array(
587
-                'overpaid'   => array(
588
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
589
-                    'desc'  => EEH_Template::pretty_status(
590
-                        EEM_Transaction::overpaid_status_code,
591
-                        false,
592
-                        'sentence'
593
-                    ),
594
-                ),
595
-                'complete'   => array(
596
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
597
-                    'desc'  => EEH_Template::pretty_status(
598
-                        EEM_Transaction::complete_status_code,
599
-                        false,
600
-                        'sentence'
601
-                    ),
602
-                ),
603
-                'incomplete' => array(
604
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
605
-                    'desc'  => EEH_Template::pretty_status(
606
-                        EEM_Transaction::incomplete_status_code,
607
-                        false,
608
-                        'sentence'
609
-                    ),
610
-                ),
611
-                'abandoned'  => array(
612
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
613
-                    'desc'  => EEH_Template::pretty_status(
614
-                        EEM_Transaction::abandoned_status_code,
615
-                        false,
616
-                        'sentence'
617
-                    ),
618
-                ),
619
-                'failed'     => array(
620
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
621
-                    'desc'  => EEH_Template::pretty_status(
622
-                        EEM_Transaction::failed_status_code,
623
-                        false,
624
-                        'sentence'
625
-                    ),
626
-                ),
627
-            )
628
-        );
629
-
630
-        return array_merge($items, $more_items);
631
-    }
632
-
633
-
634
-    /**
635
-     *    _transactions_overview_list_table
636
-     *
637
-     * @access protected
638
-     * @return void
639
-     * @throws DomainException
640
-     * @throws EE_Error
641
-     * @throws InvalidArgumentException
642
-     * @throws InvalidDataTypeException
643
-     * @throws InvalidInterfaceException
644
-     * @throws ReflectionException
645
-     */
646
-    protected function _transactions_overview_list_table()
647
-    {
648
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
649
-        $event = isset($this->_req_data['EVT_ID'])
650
-            ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
651
-            : null;
652
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event
653
-            ? sprintf(
654
-                esc_html__(
655
-                    '%sViewing Transactions for the Event: %s%s',
656
-                    'event_espresso'
657
-                ),
658
-                '<h3>',
659
-                '<a href="'
660
-                . EE_Admin_Page::add_query_args_and_nonce(
661
-                    array('action' => 'edit', 'post' => $event->ID()),
662
-                    EVENTS_ADMIN_URL
663
-                )
664
-                . '" title="'
665
-                . esc_attr__(
666
-                    'Click to Edit event',
667
-                    'event_espresso'
668
-                )
669
-                . '">' . $event->name() . '</a>',
670
-                '</h3>'
671
-            )
672
-            : '';
673
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
674
-        $this->display_admin_list_table_page_with_no_sidebar();
675
-    }
676
-
677
-
678
-    /**
679
-     *    _transaction_details
680
-     * generates HTML for the View Transaction Details Admin page
681
-     *
682
-     * @access protected
683
-     * @return void
684
-     * @throws DomainException
685
-     * @throws EE_Error
686
-     * @throws InvalidArgumentException
687
-     * @throws InvalidDataTypeException
688
-     * @throws InvalidInterfaceException
689
-     * @throws RuntimeException
690
-     * @throws ReflectionException
691
-     */
692
-    protected function _transaction_details()
693
-    {
694
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
695
-
696
-        $this->_set_transaction_status_array();
697
-
698
-        $this->_template_args = array();
699
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
700
-
701
-        $this->_set_transaction_object();
702
-
703
-        if (! $this->_transaction instanceof EE_Transaction) {
704
-            return;
705
-        }
706
-        $primary_registration = $this->_transaction->primary_registration();
707
-        $attendee = $primary_registration instanceof EE_Registration
708
-            ? $primary_registration->attendee()
709
-            : null;
710
-
711
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
712
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
713
-
714
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
715
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
716
-
717
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
718
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
719
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
720
-
721
-        $this->_template_args['grand_total'] = $this->_transaction->total();
722
-        $this->_template_args['total_paid'] = $this->_transaction->paid();
723
-
724
-        $amount_due = $this->_transaction->total() - $this->_transaction->paid();
725
-        $this->_template_args['amount_due'] = EEH_Template::format_currency(
726
-            $amount_due,
727
-            true
728
-        );
729
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
730
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
731
-                                                  . $this->_template_args['amount_due'];
732
-        } else {
733
-            $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
734
-        }
735
-        $this->_template_args['amount_due_class'] = '';
736
-
737
-        if ($this->_transaction->paid() === $this->_transaction->total()) {
738
-            // paid in full
739
-            $this->_template_args['amount_due'] = false;
740
-        } elseif ($this->_transaction->paid() > $this->_transaction->total()) {
741
-            // overpaid
742
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
743
-        } elseif ($this->_transaction->total() > (float) 0) {
744
-            if ($this->_transaction->paid() > (float) 0) {
745
-                // monies owing
746
-                $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
747
-            } elseif ($this->_transaction->paid() === (float) 0) {
748
-                // no payments made yet
749
-                $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
750
-            }
751
-        } elseif ($this->_transaction->total() === (float) 0) {
752
-            // free event
753
-            $this->_template_args['amount_due'] = false;
754
-        }
755
-
756
-        $payment_method = $this->_transaction->payment_method();
757
-
758
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
759
-            ? $payment_method->admin_name()
760
-            : esc_html__('Unknown', 'event_espresso');
761
-
762
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
763
-        // link back to overview
764
-        $this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
765
-            ? $_SERVER['HTTP_REFERER']
766
-            : TXN_ADMIN_URL;
767
-
768
-
769
-        // next link
770
-        $next_txn = $this->_transaction->next(
771
-            null,
772
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
773
-            'TXN_ID'
774
-        );
775
-        $this->_template_args['next_transaction'] = $next_txn
776
-            ? $this->_next_link(
777
-                EE_Admin_Page::add_query_args_and_nonce(
778
-                    array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
779
-                    TXN_ADMIN_URL
780
-                ),
781
-                'dashicons dashicons-arrow-right ee-icon-size-22'
782
-            )
783
-            : '';
784
-        // previous link
785
-        $previous_txn = $this->_transaction->previous(
786
-            null,
787
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
788
-            'TXN_ID'
789
-        );
790
-        $this->_template_args['previous_transaction'] = $previous_txn
791
-            ? $this->_previous_link(
792
-                EE_Admin_Page::add_query_args_and_nonce(
793
-                    array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
794
-                    TXN_ADMIN_URL
795
-                ),
796
-                'dashicons dashicons-arrow-left ee-icon-size-22'
797
-            )
798
-            : '';
799
-
800
-        // were we just redirected here after adding a new registration ???
801
-        if (isset(
802
-            $this->_req_data['redirect_from'],
803
-            $this->_req_data['EVT_ID'],
804
-            $this->_req_data['event_name']
805
-        )) {
806
-            if (EE_Registry::instance()->CAP->current_user_can(
807
-                'ee_edit_registrations',
808
-                'espresso_registrations_new_registration',
809
-                $this->_req_data['EVT_ID']
810
-            )) {
811
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
812
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
813
-                    array(
814
-                        'page'     => 'espresso_registrations',
815
-                        'action'   => 'new_registration',
816
-                        'return'   => 'default',
817
-                        'TXN_ID'   => $this->_transaction->ID(),
818
-                        'event_id' => $this->_req_data['EVT_ID'],
819
-                    ),
820
-                    REG_ADMIN_URL
821
-                );
822
-                $this->_admin_page_title .= '">';
823
-
824
-                $this->_admin_page_title .= sprintf(
825
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
826
-                    htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
827
-                );
828
-                $this->_admin_page_title .= '</a>';
829
-            }
830
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
831
-        }
832
-        // grab messages at the last second
833
-        $this->_template_args['notices'] = EE_Error::get_notices();
834
-        // path to template
835
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
836
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template(
837
-            $template_path,
838
-            $this->_template_args,
839
-            true
840
-        );
841
-
842
-        // the details template wrapper
843
-        $this->display_admin_page_with_sidebar();
844
-    }
845
-
846
-
847
-    /**
848
-     *        _transaction_details_metaboxes
849
-     *
850
-     * @access protected
851
-     * @return void
852
-     * @throws EE_Error
853
-     * @throws InvalidArgumentException
854
-     * @throws InvalidDataTypeException
855
-     * @throws InvalidInterfaceException
856
-     * @throws RuntimeException
857
-     * @throws ReflectionException
858
-     */
859
-    protected function _transaction_details_metaboxes()
860
-    {
861
-
862
-        $this->_set_transaction_object();
863
-
864
-        if (! $this->_transaction instanceof EE_Transaction) {
865
-            return;
866
-        }
867
-        add_meta_box(
868
-            'edit-txn-details-mbox',
869
-            esc_html__('Transaction Details', 'event_espresso'),
870
-            array($this, 'txn_details_meta_box'),
871
-            $this->_wp_page_slug,
872
-            'normal',
873
-            'high'
874
-        );
875
-        add_meta_box(
876
-            'edit-txn-attendees-mbox',
877
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
878
-            array($this, 'txn_attendees_meta_box'),
879
-            $this->_wp_page_slug,
880
-            'normal',
881
-            'high',
882
-            array('TXN_ID' => $this->_transaction->ID())
883
-        );
884
-        add_meta_box(
885
-            'edit-txn-registrant-mbox',
886
-            esc_html__('Primary Contact', 'event_espresso'),
887
-            array($this, 'txn_registrant_side_meta_box'),
888
-            $this->_wp_page_slug,
889
-            'side',
890
-            'high'
891
-        );
892
-        add_meta_box(
893
-            'edit-txn-billing-info-mbox',
894
-            esc_html__('Billing Information', 'event_espresso'),
895
-            array($this, 'txn_billing_info_side_meta_box'),
896
-            $this->_wp_page_slug,
897
-            'side',
898
-            'high'
899
-        );
900
-    }
901
-
902
-
903
-    /**
904
-     * Callback for transaction actions metabox.
905
-     *
906
-     * @param EE_Transaction|null $transaction
907
-     * @return string
908
-     * @throws DomainException
909
-     * @throws EE_Error
910
-     * @throws InvalidArgumentException
911
-     * @throws InvalidDataTypeException
912
-     * @throws InvalidInterfaceException
913
-     * @throws ReflectionException
914
-     * @throws RuntimeException
915
-     */
916
-    public function getActionButtons(EE_Transaction $transaction = null)
917
-    {
918
-        $content = '';
919
-        $actions = array();
920
-        if (! $transaction instanceof EE_Transaction) {
921
-            return $content;
922
-        }
923
-        /** @var EE_Registration $primary_registration */
924
-        $primary_registration = $transaction->primary_registration();
925
-        $attendee = $primary_registration instanceof EE_Registration
926
-            ? $primary_registration->attendee()
927
-            : null;
928
-
929
-        if ($attendee instanceof EE_Attendee
930
-            && EE_Registry::instance()->CAP->current_user_can(
931
-                'ee_send_message',
932
-                'espresso_transactions_send_payment_reminder'
933
-            )
934
-        ) {
935
-            $actions['payment_reminder'] =
936
-                EEH_MSG_Template::is_mt_active('payment_reminder')
937
-                && $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
938
-                && $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
939
-                    ? EEH_Template::get_button_or_link(
940
-                        EE_Admin_Page::add_query_args_and_nonce(
941
-                            array(
942
-                                'action'      => 'send_payment_reminder',
943
-                                'TXN_ID'      => $this->_transaction->ID(),
944
-                                'redirect_to' => 'view_transaction',
945
-                            ),
946
-                            TXN_ADMIN_URL
947
-                        ),
948
-                        esc_html__(' Send Payment Reminder', 'event_espresso'),
949
-                        'button secondary-button',
950
-                        'dashicons dashicons-email-alt'
951
-                    )
952
-                    : '';
953
-        }
954
-
955
-        if (EE_Registry::instance()->CAP->current_user_can(
956
-            'ee_edit_payments',
957
-            'espresso_transactions_recalculate_line_items'
958
-        )
959
-        ) {
960
-            $actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
961
-                EE_Admin_Page::add_query_args_and_nonce(
962
-                    array(
963
-                        'action'      => 'espresso_recalculate_line_items',
964
-                        'TXN_ID'      => $this->_transaction->ID(),
965
-                        'redirect_to' => 'view_transaction',
966
-                    ),
967
-                    TXN_ADMIN_URL
968
-                ),
969
-                esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
970
-                'button secondary-button',
971
-                'dashicons dashicons-update'
972
-            );
973
-        }
974
-
975
-        if ($primary_registration instanceof EE_Registration
976
-            && EEH_MSG_Template::is_mt_active('receipt')
977
-        ) {
978
-            $actions['receipt'] = EEH_Template::get_button_or_link(
979
-                $primary_registration->receipt_url(),
980
-                esc_html__('View Receipt', 'event_espresso'),
981
-                'button secondary-button',
982
-                'dashicons dashicons-media-default'
983
-            );
984
-        }
985
-
986
-        if ($primary_registration instanceof EE_Registration
987
-            && EEH_MSG_Template::is_mt_active('invoice')
988
-        ) {
989
-            $actions['invoice'] = EEH_Template::get_button_or_link(
990
-                $primary_registration->invoice_url(),
991
-                esc_html__('View Invoice', 'event_espresso'),
992
-                'button secondary-button',
993
-                'dashicons dashicons-media-spreadsheet'
994
-            );
995
-        }
996
-        $actions = array_filter(
997
-            apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
998
-        );
999
-        if ($actions) {
1000
-            $content = '<ul>';
1001
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
1002
-            $content .= '</uL>';
1003
-        }
1004
-        return $content;
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     * txn_details_meta_box
1010
-     * generates HTML for the Transaction main meta box
1011
-     *
1012
-     * @return void
1013
-     * @throws DomainException
1014
-     * @throws EE_Error
1015
-     * @throws InvalidArgumentException
1016
-     * @throws InvalidDataTypeException
1017
-     * @throws InvalidInterfaceException
1018
-     * @throws RuntimeException
1019
-     * @throws ReflectionException
1020
-     */
1021
-    public function txn_details_meta_box()
1022
-    {
1023
-        $this->_set_transaction_object();
1024
-        $this->_template_args['TXN_ID'] = $this->_transaction->ID();
1025
-        $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
1026
-            ? $this->_transaction->primary_registration()->attendee()
1027
-            : null;
1028
-        $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
1029
-            'ee_edit_payments',
1030
-            'apply_payment_or_refund_from_registration_details'
1031
-        );
1032
-        $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1033
-            'ee_delete_payments',
1034
-            'delete_payment_from_registration_details'
1035
-        );
1036
-
1037
-        // get line table
1038
-        EEH_Autoloader::register_line_item_display_autoloaders();
1039
-        $Line_Item_Display = new EE_Line_Item_Display(
1040
-            'admin_table',
1041
-            'EE_Admin_Table_Line_Item_Display_Strategy'
1042
-        );
1043
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1044
-            $this->_transaction->total_line_item()
1045
-        );
1046
-        $this->_template_args['REG_code'] = $this->_transaction->primary_registration() instanceof EE_Registration
1047
-            ? $this->_transaction->primary_registration()->reg_code()
1048
-            : null;
1049
-        // process taxes
1050
-        $taxes = $this->_transaction->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
1051
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1052
-
1053
-        $this->_template_args['grand_total'] = EEH_Template::format_currency(
1054
-            $this->_transaction->total(),
1055
-            false,
1056
-            false
1057
-        );
1058
-        $this->_template_args['grand_raw_total'] = $this->_transaction->total();
1059
-        $this->_template_args['TXN_status'] = $this->_transaction->status_ID();
1060
-
1061
-        // process payment details
1062
-        $payments = $this->_transaction->payments();
1063
-        if (! empty($payments)) {
1064
-            $this->_template_args['payments'] = $payments;
1065
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1066
-        } else {
1067
-            $this->_template_args['payments'] = false;
1068
-            $this->_template_args['existing_reg_payments'] = array();
1069
-        }
1070
-
1071
-        $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1072
-        $this->_template_args['delete_payment_url'] = add_query_arg(
1073
-            array('action' => 'espresso_delete_payment'),
1074
-            TXN_ADMIN_URL
1075
-        );
1076
-
1077
-        if (isset($txn_details['invoice_number'])) {
1078
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1079
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1080
-                'Invoice Number',
1081
-                'event_espresso'
1082
-            );
1083
-        }
1084
-
1085
-        $this->_template_args['txn_details']['registration_session']['value']
1086
-            = $this->_transaction->primary_registration() instanceof EE_Registration
1087
-            ? $this->_transaction->primary_registration()->session_ID()
1088
-            : null;
1089
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1090
-            'Registration Session',
1091
-            'event_espresso'
1092
-        );
1093
-
1094
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1095
-            ? $this->_session['ip_address']
1096
-            : '';
1097
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1098
-            'Transaction placed from IP',
1099
-            'event_espresso'
1100
-        );
1101
-
1102
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1103
-            ? $this->_session['user_agent']
1104
-            : '';
1105
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1106
-            'Registrant User Agent',
1107
-            'event_espresso'
1108
-        );
1109
-
1110
-        $reg_steps = '<ul>';
1111
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1112
-            if ($reg_step_status === true) {
1113
-                $reg_steps .= '<li style="color:#70cc50">'
1114
-                              . sprintf(
1115
-                                  esc_html__('%1$s : Completed', 'event_espresso'),
1116
-                                  ucwords(str_replace('_', ' ', $reg_step))
1117
-                              )
1118
-                              . '</li>';
1119
-            } elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1120
-                $reg_steps .= '<li style="color:#2EA2CC">'
1121
-                              . sprintf(
1122
-                                  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1123
-                                  ucwords(str_replace('_', ' ', $reg_step)),
1124
-                                  date(
1125
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1126
-                                      $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1127
-                                  )
1128
-                              )
1129
-                              . '</li>';
1130
-            } else {
1131
-                $reg_steps .= '<li style="color:#E76700">'
1132
-                              . sprintf(
1133
-                                  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1134
-                                  ucwords(str_replace('_', ' ', $reg_step))
1135
-                              )
1136
-                              . '</li>';
1137
-            }
1138
-        }
1139
-        $reg_steps .= '</ul>';
1140
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1141
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1142
-            'Registration Step Progress',
1143
-            'event_espresso'
1144
-        );
1145
-
1146
-
1147
-        $this->_get_registrations_to_apply_payment_to();
1148
-        $this->_get_payment_methods($payments);
1149
-        $this->_get_payment_status_array();
1150
-        $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1151
-
1152
-        $this->_template_args['transaction_form_url'] = add_query_arg(
1153
-            array(
1154
-                'action'  => 'edit_transaction',
1155
-                'process' => 'transaction',
1156
-            ),
1157
-            TXN_ADMIN_URL
1158
-        );
1159
-        $this->_template_args['apply_payment_form_url'] = add_query_arg(
1160
-            array(
1161
-                'page'   => 'espresso_transactions',
1162
-                'action' => 'espresso_apply_payment',
1163
-            ),
1164
-            WP_AJAX_URL
1165
-        );
1166
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(
1167
-            array(
1168
-                'page'   => 'espresso_transactions',
1169
-                'action' => 'espresso_delete_payment',
1170
-            ),
1171
-            WP_AJAX_URL
1172
-        );
1173
-
1174
-        $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1175
-
1176
-        // 'espresso_delete_payment_nonce'
1177
-
1178
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1179
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1180
-    }
1181
-
1182
-
1183
-    /**
1184
-     * _get_registration_payment_IDs
1185
-     *    generates an array of Payment IDs and their corresponding Registration IDs
1186
-     *
1187
-     * @access protected
1188
-     * @param EE_Payment[] $payments
1189
-     * @return array
1190
-     * @throws EE_Error
1191
-     * @throws InvalidArgumentException
1192
-     * @throws InvalidDataTypeException
1193
-     * @throws InvalidInterfaceException
1194
-     * @throws ReflectionException
1195
-     */
1196
-    protected function _get_registration_payment_IDs($payments = array())
1197
-    {
1198
-        $existing_reg_payments = array();
1199
-        // get all reg payments for these payments
1200
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(
1201
-            array(
1202
-                array(
1203
-                    'PAY_ID' => array(
1204
-                        'IN',
1205
-                        array_keys($payments),
1206
-                    ),
1207
-                ),
1208
-            )
1209
-        );
1210
-        if (! empty($reg_payments)) {
1211
-            foreach ($payments as $payment) {
1212
-                if (! $payment instanceof EE_Payment) {
1213
-                    continue;
1214
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1215
-                    $existing_reg_payments[ $payment->ID() ] = array();
1216
-                }
1217
-                foreach ($reg_payments as $reg_payment) {
1218
-                    if ($reg_payment instanceof EE_Registration_Payment
1219
-                        && $reg_payment->payment_ID() === $payment->ID()
1220
-                    ) {
1221
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1222
-                    }
1223
-                }
1224
-            }
1225
-        }
1226
-
1227
-        return $existing_reg_payments;
1228
-    }
1229
-
1230
-
1231
-    /**
1232
-     * _get_registrations_to_apply_payment_to
1233
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1234
-     * which allows the admin to only apply the payment to the specific registrations
1235
-     *
1236
-     * @access protected
1237
-     * @return void
1238
-     * @throws EE_Error
1239
-     * @throws InvalidArgumentException
1240
-     * @throws InvalidDataTypeException
1241
-     * @throws InvalidInterfaceException
1242
-     * @throws ReflectionException
1243
-     */
1244
-    protected function _get_registrations_to_apply_payment_to()
1245
-    {
1246
-        // we want any registration with an active status (ie: not deleted or cancelled)
1247
-        $query_params = array(
1248
-            array(
1249
-                'STS_ID' => array(
1250
-                    'IN',
1251
-                    array(
1252
-                        EEM_Registration::status_id_approved,
1253
-                        EEM_Registration::status_id_pending_payment,
1254
-                        EEM_Registration::status_id_not_approved,
1255
-                    ),
1256
-                ),
1257
-            ),
1258
-        );
1259
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1260
-            '',
1261
-            'txn-admin-apply-payment-to-registrations-dv',
1262
-            '',
1263
-            'clear: both; margin: 1.5em 0 0; display: none;'
1264
-        );
1265
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1266
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1267
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
1268
-            EEH_HTML::tr(
1269
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1270
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1271
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1272
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1273
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1274
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1275
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1276
-            )
1277
-        );
1278
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
1279
-        // get registrations for TXN
1280
-        $registrations = $this->_transaction->registrations($query_params);
1281
-        $existing_reg_payments = $this->_template_args['existing_reg_payments'];
1282
-        foreach ($registrations as $registration) {
1283
-            if ($registration instanceof EE_Registration) {
1284
-                $attendee_name = $registration->attendee() instanceof EE_Attendee
1285
-                    ? $registration->attendee()->full_name()
1286
-                    : esc_html__('Unknown Attendee', 'event_espresso');
1287
-                $owing = $registration->final_price() - $registration->paid();
1288
-                $taxable = $registration->ticket()->taxable()
1289
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1290
-                    : '';
1291
-                $checked = empty($existing_reg_payments)
1292
-                           || in_array($registration->ID(), $existing_reg_payments, true)
1293
-                    ? ' checked="checked"'
1294
-                    : '';
1295
-                $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1296
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
1297
-                    EEH_HTML::td($registration->ID()) .
1298
-                    EEH_HTML::td($attendee_name) .
1299
-                    EEH_HTML::td(
1300
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1301
-                    ) .
1302
-                    EEH_HTML::td($registration->event_name()) .
1303
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1304
-                    EEH_HTML::td(
1305
-                        EEH_Template::format_currency($owing),
1306
-                        '',
1307
-                        'txn-admin-payment-owing-td jst-cntr'
1308
-                    ) .
1309
-                    EEH_HTML::td(
1310
-                        '<input type="checkbox" value="' . $registration->ID()
1311
-                        . '" name="txn_admin_payment[registrations]"'
1312
-                        . $checked . $disabled . '>',
1313
-                        '',
1314
-                        'jst-cntr'
1315
-                    ),
1316
-                    'apply-payment-registration-row-' . $registration->ID()
1317
-                );
1318
-            }
1319
-        }
1320
-        $registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1321
-        $registrations_to_apply_payment_to .= EEH_HTML::tablex();
1322
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1323
-        $registrations_to_apply_payment_to .= EEH_HTML::p(
1324
-            esc_html__(
1325
-                'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1326
-                'event_espresso'
1327
-            ),
1328
-            '',
1329
-            'clear description'
1330
-        );
1331
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1332
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1333
-    }
1334
-
1335
-
1336
-    /**
1337
-     * _get_reg_status_selection
1338
-     *
1339
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1340
-     *         instead of events.
1341
-     * @access protected
1342
-     * @return void
1343
-     * @throws EE_Error
1344
-     */
1345
-    protected function _get_reg_status_selection()
1346
-    {
1347
-        // first get all possible statuses
1348
-        $statuses = EEM_Registration::reg_status_array(array(), true);
1349
-        // let's add a "don't change" option.
1350
-        $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1351
-        $status_array = array_merge($status_array, $statuses);
1352
-        $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1353
-            'txn_reg_status_change[reg_status]',
1354
-            $status_array,
1355
-            'NAN',
1356
-            'id="txn-admin-payment-reg-status-inp"',
1357
-            'txn-reg-status-change-reg-status'
1358
-        );
1359
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1360
-            'delete_txn_reg_status_change[reg_status]',
1361
-            $status_array,
1362
-            'NAN',
1363
-            'delete-txn-admin-payment-reg-status-inp',
1364
-            'delete-txn-reg-status-change-reg-status'
1365
-        );
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     *    _get_payment_methods
1371
-     * Gets all the payment methods available generally, or the ones that are already
1372
-     * selected on these payments (in case their payment methods are no longer active).
1373
-     * Has the side-effect of updating the template args' payment_methods item
1374
-     *
1375
-     * @access private
1376
-     * @param EE_Payment[] to show on this page
1377
-     * @return void
1378
-     * @throws EE_Error
1379
-     * @throws InvalidArgumentException
1380
-     * @throws InvalidDataTypeException
1381
-     * @throws InvalidInterfaceException
1382
-     * @throws ReflectionException
1383
-     */
1384
-    private function _get_payment_methods($payments = array())
1385
-    {
1386
-        $payment_methods_of_payments = array();
1387
-        foreach ($payments as $payment) {
1388
-            if ($payment instanceof EE_Payment) {
1389
-                $payment_methods_of_payments[] = $payment->ID();
1390
-            }
1391
-        }
1392
-        if ($payment_methods_of_payments) {
1393
-            $query_args = array(
1394
-                array(
1395
-                    'OR*payment_method_for_payment' => array(
1396
-                        'PMD_ID'    => array('IN', $payment_methods_of_payments),
1397
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1398
-                    ),
1399
-                ),
1400
-            );
1401
-        } else {
1402
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1403
-        }
1404
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1405
-    }
1406
-
1407
-
1408
-    /**
1409
-     * txn_attendees_meta_box
1410
-     *    generates HTML for the Attendees Transaction main meta box
1411
-     *
1412
-     * @access public
1413
-     * @param WP_Post $post
1414
-     * @param array   $metabox
1415
-     * @return void
1416
-     * @throws DomainException
1417
-     * @throws EE_Error
1418
-     * @throws InvalidArgumentException
1419
-     * @throws InvalidDataTypeException
1420
-     * @throws InvalidInterfaceException
1421
-     * @throws ReflectionException
1422
-     */
1423
-    public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1424
-    {
1425
-
1426
-        /** @noinspection NonSecureExtractUsageInspection */
1427
-        extract($metabox['args']);
1428
-        $this->_template_args['post'] = $post;
1429
-        $this->_template_args['event_attendees'] = array();
1430
-        // process items in cart
1431
-        $line_items = $this->_transaction->get_many_related(
1432
-            'Line_Item',
1433
-            array(array('LIN_type' => 'line-item'))
1434
-        );
1435
-        if (! empty($line_items)) {
1436
-            foreach ($line_items as $item) {
1437
-                if ($item instanceof EE_Line_Item) {
1438
-                    switch ($item->OBJ_type()) {
1439
-                        case 'Event':
1440
-                            break;
1441
-                        case 'Ticket':
1442
-                            $ticket = $item->ticket();
1443
-                            // right now we're only handling tickets here.
1444
-                            // Cause its expected that only tickets will have attendees right?
1445
-                            if (! $ticket instanceof EE_Ticket) {
1446
-                                break;
1447
-                            }
1448
-                            try {
1449
-                                $event_name = $ticket->get_event_name();
1450
-                            } catch (Exception $e) {
1451
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1452
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1453
-                            }
1454
-                            $event_name .= ' - ' . $item->name();
1455
-                            $ticket_price = EEH_Template::format_currency($item->unit_price());
1456
-                            // now get all of the registrations for this transaction that use this ticket
1457
-                            $registrations = $ticket->registrations(
1458
-                                array(array('TXN_ID' => $this->_transaction->ID()))
1459
-                            );
1460
-                            foreach ($registrations as $registration) {
1461
-                                if (! $registration instanceof EE_Registration) {
1462
-                                    break;
1463
-                                }
1464
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1465
-                                    = $registration->status_ID();
1466
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1467
-                                    = $registration->count();
1468
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1469
-                                    = $event_name;
1470
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1471
-                                    = $ticket_price;
1472
-                                // attendee info
1473
-                                $attendee = $registration->get_first_related('Attendee');
1474
-                                if ($attendee instanceof EE_Attendee) {
1475
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1476
-                                        = $attendee->ID();
1477
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1478
-                                        = $attendee->full_name();
1479
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1480
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1481
-                                          . esc_html__(
1482
-                                              ' Event',
1483
-                                              'event_espresso'
1484
-                                          )
1485
-                                          . '">' . $attendee->email() . '</a>';
1486
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1487
-                                        = EEH_Address::format($attendee, 'inline', false, false);
1488
-                                } else {
1489
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1490
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1491
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1492
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1493
-                                }
1494
-                            }
1495
-                            break;
1496
-                    }
1497
-                }
1498
-            }
1499
-
1500
-            $this->_template_args['transaction_form_url'] = add_query_arg(
1501
-                array(
1502
-                    'action'  => 'edit_transaction',
1503
-                    'process' => 'attendees',
1504
-                ),
1505
-                TXN_ADMIN_URL
1506
-            );
1507
-            echo EEH_Template::display_template(
1508
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1509
-                $this->_template_args,
1510
-                true
1511
-            );
1512
-        } else {
1513
-            echo sprintf(
1514
-                esc_html__(
1515
-                    '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1516
-                    'event_espresso'
1517
-                ),
1518
-                '<p class="important-notice">',
1519
-                '</p>'
1520
-            );
1521
-        }
1522
-    }
1523
-
1524
-
1525
-    /**
1526
-     * txn_registrant_side_meta_box
1527
-     * generates HTML for the Edit Transaction side meta box
1528
-     *
1529
-     * @access public
1530
-     * @return void
1531
-     * @throws DomainException
1532
-     * @throws EE_Error
1533
-     * @throws InvalidArgumentException
1534
-     * @throws InvalidDataTypeException
1535
-     * @throws InvalidInterfaceException
1536
-     * @throws ReflectionException
1537
-     */
1538
-    public function txn_registrant_side_meta_box()
1539
-    {
1540
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1541
-            ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1542
-            : null;
1543
-        if (! $primary_att instanceof EE_Attendee) {
1544
-            $this->_template_args['no_attendee_message'] = esc_html__(
1545
-                'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1546
-                'event_espresso'
1547
-            );
1548
-            $primary_att = EEM_Attendee::instance()->create_default_object();
1549
-        }
1550
-        $this->_template_args['ATT_ID'] = $primary_att->ID();
1551
-        $this->_template_args['prime_reg_fname'] = $primary_att->fname();
1552
-        $this->_template_args['prime_reg_lname'] = $primary_att->lname();
1553
-        $this->_template_args['prime_reg_email'] = $primary_att->email();
1554
-        $this->_template_args['prime_reg_phone'] = $primary_att->phone();
1555
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1556
-            array(
1557
-                'action' => 'edit_attendee',
1558
-                'post'   => $primary_att->ID(),
1559
-            ),
1560
-            REG_ADMIN_URL
1561
-        );
1562
-        // get formatted address for registrant
1563
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1564
-        echo EEH_Template::display_template(
1565
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1566
-            $this->_template_args,
1567
-            true
1568
-        );
1569
-    }
1570
-
1571
-
1572
-    /**
1573
-     * txn_billing_info_side_meta_box
1574
-     *    generates HTML for the Edit Transaction side meta box
1575
-     *
1576
-     * @access public
1577
-     * @return void
1578
-     * @throws DomainException
1579
-     * @throws EE_Error
1580
-     */
1581
-    public function txn_billing_info_side_meta_box()
1582
-    {
1583
-
1584
-        $this->_template_args['billing_form'] = $this->_transaction->billing_info();
1585
-        $this->_template_args['billing_form_url'] = add_query_arg(
1586
-            array('action' => 'edit_transaction', 'process' => 'billing'),
1587
-            TXN_ADMIN_URL
1588
-        );
1589
-
1590
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1591
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1592
-    }
1593
-
1594
-
1595
-    /**
1596
-     * apply_payments_or_refunds
1597
-     *    registers a payment or refund made towards a transaction
1598
-     *
1599
-     * @access public
1600
-     * @return void
1601
-     * @throws EE_Error
1602
-     * @throws InvalidArgumentException
1603
-     * @throws ReflectionException
1604
-     * @throws RuntimeException
1605
-     * @throws InvalidDataTypeException
1606
-     * @throws InvalidInterfaceException
1607
-     */
1608
-    public function apply_payments_or_refunds()
1609
-    {
1610
-        $json_response_data = array('return_data' => false);
1611
-        $valid_data = $this->_validate_payment_request_data();
1612
-        $has_access = EE_Registry::instance()->CAP->current_user_can(
1613
-            'ee_edit_payments',
1614
-            'apply_payment_or_refund_from_registration_details'
1615
-        );
1616
-        if (! empty($valid_data) && $has_access) {
1617
-            $PAY_ID = $valid_data['PAY_ID'];
1618
-            // save  the new payment
1619
-            $payment = $this->_create_payment_from_request_data($valid_data);
1620
-            // get the TXN for this payment
1621
-            $transaction = $payment->transaction();
1622
-            // verify transaction
1623
-            if ($transaction instanceof EE_Transaction) {
1624
-                // calculate_total_payments_and_update_status
1625
-                $this->_process_transaction_payments($transaction);
1626
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1627
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1628
-                // apply payment to registrations (if applicable)
1629
-                if (! empty($REG_IDs)) {
1630
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1631
-                    $this->_maybe_send_notifications();
1632
-                    // now process status changes for the same registrations
1633
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1634
-                }
1635
-                $this->_maybe_send_notifications($payment);
1636
-                // prepare to render page
1637
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1638
-                do_action(
1639
-                    'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1640
-                    $transaction,
1641
-                    $payment
1642
-                );
1643
-            } else {
1644
-                EE_Error::add_error(
1645
-                    esc_html__(
1646
-                        'A valid Transaction for this payment could not be retrieved.',
1647
-                        'event_espresso'
1648
-                    ),
1649
-                    __FILE__,
1650
-                    __FUNCTION__,
1651
-                    __LINE__
1652
-                );
1653
-            }
1654
-        } elseif ($has_access) {
1655
-            EE_Error::add_error(
1656
-                esc_html__(
1657
-                    'The payment form data could not be processed. Please try again.',
1658
-                    'event_espresso'
1659
-                ),
1660
-                __FILE__,
1661
-                __FUNCTION__,
1662
-                __LINE__
1663
-            );
1664
-        } else {
1665
-            EE_Error::add_error(
1666
-                esc_html__(
1667
-                    'You do not have access to apply payments or refunds to a registration.',
1668
-                    'event_espresso'
1669
-                ),
1670
-                __FILE__,
1671
-                __FUNCTION__,
1672
-                __LINE__
1673
-            );
1674
-        }
1675
-        $notices = EE_Error::get_notices(
1676
-            false,
1677
-            false,
1678
-            false
1679
-        );
1680
-        $this->_template_args = array(
1681
-            'data'    => $json_response_data,
1682
-            'error'   => $notices['errors'],
1683
-            'success' => $notices['success'],
1684
-        );
1685
-        $this->_return_json();
1686
-    }
1687
-
1688
-
1689
-    /**
1690
-     * _validate_payment_request_data
1691
-     *
1692
-     * @return array
1693
-     * @throws EE_Error
1694
-     * @throws InvalidArgumentException
1695
-     * @throws InvalidDataTypeException
1696
-     * @throws InvalidInterfaceException
1697
-     */
1698
-    protected function _validate_payment_request_data()
1699
-    {
1700
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1701
-            return array();
1702
-        }
1703
-        $payment_form = $this->_generate_payment_form_section();
1704
-        try {
1705
-            if ($payment_form->was_submitted()) {
1706
-                $payment_form->receive_form_submission();
1707
-                if (! $payment_form->is_valid()) {
1708
-                    $submission_error_messages = array();
1709
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1710
-                        if ($validation_error instanceof EE_Validation_Error) {
1711
-                            $submission_error_messages[] = sprintf(
1712
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1713
-                                $validation_error->get_form_section()->html_label_text(),
1714
-                                $validation_error->getMessage()
1715
-                            );
1716
-                        }
1717
-                    }
1718
-                    EE_Error::add_error(
1719
-                        implode('<br />', $submission_error_messages),
1720
-                        __FILE__,
1721
-                        __FUNCTION__,
1722
-                        __LINE__
1723
-                    );
1724
-                    return array();
1725
-                }
1726
-            }
1727
-        } catch (EE_Error $e) {
1728
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1729
-            return array();
1730
-        }
1731
-
1732
-        return $payment_form->valid_data();
1733
-    }
1734
-
1735
-
1736
-    /**
1737
-     * _generate_payment_form_section
1738
-     *
1739
-     * @return EE_Form_Section_Proper
1740
-     * @throws EE_Error
1741
-     */
1742
-    protected function _generate_payment_form_section()
1743
-    {
1744
-        return new EE_Form_Section_Proper(
1745
-            array(
1746
-                'name'        => 'txn_admin_payment',
1747
-                'subsections' => array(
1748
-                    'PAY_ID'          => new EE_Text_Input(
1749
-                        array(
1750
-                            'default'               => 0,
1751
-                            'required'              => false,
1752
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1753
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1754
-                        )
1755
-                    ),
1756
-                    'TXN_ID'          => new EE_Text_Input(
1757
-                        array(
1758
-                            'default'               => 0,
1759
-                            'required'              => true,
1760
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1761
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1762
-                        )
1763
-                    ),
1764
-                    'type'            => new EE_Text_Input(
1765
-                        array(
1766
-                            'default'               => 1,
1767
-                            'required'              => true,
1768
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1769
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1770
-                        )
1771
-                    ),
1772
-                    'amount'          => new EE_Text_Input(
1773
-                        array(
1774
-                            'default'               => 0,
1775
-                            'required'              => true,
1776
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1777
-                            'validation_strategies' => array(new EE_Float_Normalization()),
1778
-                        )
1779
-                    ),
1780
-                    'status'          => new EE_Text_Input(
1781
-                        array(
1782
-                            'default'         => EEM_Payment::status_id_approved,
1783
-                            'required'        => true,
1784
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1785
-                        )
1786
-                    ),
1787
-                    'PMD_ID'          => new EE_Text_Input(
1788
-                        array(
1789
-                            'default'               => 2,
1790
-                            'required'              => true,
1791
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1792
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1793
-                        )
1794
-                    ),
1795
-                    'date'            => new EE_Text_Input(
1796
-                        array(
1797
-                            'default'         => time(),
1798
-                            'required'        => true,
1799
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1800
-                        )
1801
-                    ),
1802
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1803
-                        array(
1804
-                            'default'               => '',
1805
-                            'required'              => false,
1806
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1807
-                            'validation_strategies' => array(
1808
-                                new EE_Max_Length_Validation_Strategy(
1809
-                                    esc_html__('Input too long', 'event_espresso'),
1810
-                                    100
1811
-                                ),
1812
-                            ),
1813
-                        )
1814
-                    ),
1815
-                    'po_number'       => new EE_Text_Input(
1816
-                        array(
1817
-                            'default'               => '',
1818
-                            'required'              => false,
1819
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1820
-                            'validation_strategies' => array(
1821
-                                new EE_Max_Length_Validation_Strategy(
1822
-                                    esc_html__('Input too long', 'event_espresso'),
1823
-                                    100
1824
-                                ),
1825
-                            ),
1826
-                        )
1827
-                    ),
1828
-                    'accounting'      => new EE_Text_Input(
1829
-                        array(
1830
-                            'default'               => '',
1831
-                            'required'              => false,
1832
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1833
-                            'validation_strategies' => array(
1834
-                                new EE_Max_Length_Validation_Strategy(
1835
-                                    esc_html__('Input too long', 'event_espresso'),
1836
-                                    100
1837
-                                ),
1838
-                            ),
1839
-                        )
1840
-                    ),
1841
-                ),
1842
-            )
1843
-        );
1844
-    }
1845
-
1846
-
1847
-    /**
1848
-     * _create_payment_from_request_data
1849
-     *
1850
-     * @param array $valid_data
1851
-     * @return EE_Payment
1852
-     * @throws EE_Error
1853
-     * @throws InvalidArgumentException
1854
-     * @throws InvalidDataTypeException
1855
-     * @throws InvalidInterfaceException
1856
-     * @throws ReflectionException
1857
-     */
1858
-    protected function _create_payment_from_request_data($valid_data)
1859
-    {
1860
-        $PAY_ID = $valid_data['PAY_ID'];
1861
-        // get payment amount
1862
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1863
-        // payments have a type value of 1 and refunds have a type value of -1
1864
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1865
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1866
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1867
-        $date = $valid_data['date']
1868
-            ? preg_replace('/\s+/', ' ', $valid_data['date'])
1869
-            : date('Y-m-d g:i a', current_time('timestamp'));
1870
-        $payment = EE_Payment::new_instance(
1871
-            array(
1872
-                'TXN_ID'              => $valid_data['TXN_ID'],
1873
-                'STS_ID'              => $valid_data['status'],
1874
-                'PAY_timestamp'       => $date,
1875
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1876
-                'PMD_ID'              => $valid_data['PMD_ID'],
1877
-                'PAY_amount'          => $amount,
1878
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1879
-                'PAY_po_number'       => $valid_data['po_number'],
1880
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1881
-                'PAY_details'         => $valid_data,
1882
-                'PAY_ID'              => $PAY_ID,
1883
-            ),
1884
-            '',
1885
-            array('Y-m-d', 'g:i a')
1886
-        );
1887
-
1888
-        if (! $payment->save()) {
1889
-            EE_Error::add_error(
1890
-                sprintf(
1891
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1892
-                    $payment->ID()
1893
-                ),
1894
-                __FILE__,
1895
-                __FUNCTION__,
1896
-                __LINE__
1897
-            );
1898
-        }
1899
-
1900
-        return $payment;
1901
-    }
1902
-
1903
-
1904
-    /**
1905
-     * _process_transaction_payments
1906
-     *
1907
-     * @param \EE_Transaction $transaction
1908
-     * @return void
1909
-     * @throws EE_Error
1910
-     * @throws InvalidArgumentException
1911
-     * @throws ReflectionException
1912
-     * @throws InvalidDataTypeException
1913
-     * @throws InvalidInterfaceException
1914
-     */
1915
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1916
-    {
1917
-        /** @type EE_Transaction_Payments $transaction_payments */
1918
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1919
-        // update the transaction with this payment
1920
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1921
-            EE_Error::add_success(
1922
-                esc_html__(
1923
-                    'The payment has been processed successfully.',
1924
-                    'event_espresso'
1925
-                ),
1926
-                __FILE__,
1927
-                __FUNCTION__,
1928
-                __LINE__
1929
-            );
1930
-        } else {
1931
-            EE_Error::add_error(
1932
-                esc_html__(
1933
-                    'The payment was processed successfully but the amount paid for the transaction was not updated.',
1934
-                    'event_espresso'
1935
-                ),
1936
-                __FILE__,
1937
-                __FUNCTION__,
1938
-                __LINE__
1939
-            );
1940
-        }
1941
-    }
1942
-
1943
-
1944
-    /**
1945
-     * _get_REG_IDs_to_apply_payment_to
1946
-     * returns a list of registration IDs that the payment will apply to
1947
-     *
1948
-     * @param \EE_Payment $payment
1949
-     * @return array
1950
-     * @throws EE_Error
1951
-     * @throws InvalidArgumentException
1952
-     * @throws InvalidDataTypeException
1953
-     * @throws InvalidInterfaceException
1954
-     * @throws ReflectionException
1955
-     */
1956
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1957
-    {
1958
-        $REG_IDs = array();
1959
-        // grab array of IDs for specific registrations to apply changes to
1960
-        if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1961
-            $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1962
-        }
1963
-        // nothing specified ? then get all reg IDs
1964
-        if (empty($REG_IDs)) {
1965
-            $registrations = $payment->transaction()->registrations();
1966
-            $REG_IDs = ! empty($registrations)
1967
-                ? array_keys($registrations)
1968
-                : $this->_get_existing_reg_payment_REG_IDs($payment);
1969
-        }
1970
-
1971
-        // ensure that REG_IDs are integers and NOT strings
1972
-        return array_map('intval', $REG_IDs);
1973
-    }
1974
-
1975
-
1976
-    /**
1977
-     * @return array
1978
-     */
1979
-    public function existing_reg_payment_REG_IDs()
1980
-    {
1981
-        return $this->_existing_reg_payment_REG_IDs;
1982
-    }
1983
-
1984
-
1985
-    /**
1986
-     * @param array $existing_reg_payment_REG_IDs
1987
-     */
1988
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1989
-    {
1990
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1991
-    }
1992
-
1993
-
1994
-    /**
1995
-     * _get_existing_reg_payment_REG_IDs
1996
-     * returns a list of registration IDs that the payment is currently related to
1997
-     * as recorded in the database
1998
-     *
1999
-     * @param \EE_Payment $payment
2000
-     * @return array
2001
-     * @throws EE_Error
2002
-     * @throws InvalidArgumentException
2003
-     * @throws InvalidDataTypeException
2004
-     * @throws InvalidInterfaceException
2005
-     * @throws ReflectionException
2006
-     */
2007
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
2008
-    {
2009
-        if ($this->existing_reg_payment_REG_IDs() === null) {
2010
-            // let's get any existing reg payment records for this payment
2011
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2012
-            // but we only want the REG IDs, so grab the array keys
2013
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2014
-                ? array_keys($existing_reg_payment_REG_IDs)
2015
-                : array();
2016
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2017
-        }
2018
-
2019
-        return $this->existing_reg_payment_REG_IDs();
2020
-    }
2021
-
2022
-
2023
-    /**
2024
-     * _remove_existing_registration_payments
2025
-     * this calculates the difference between existing relations
2026
-     * to the supplied payment and the new list registration IDs,
2027
-     * removes any related registrations that no longer apply,
2028
-     * and then updates the registration paid fields
2029
-     *
2030
-     * @param \EE_Payment $payment
2031
-     * @param int         $PAY_ID
2032
-     * @return bool;
2033
-     * @throws EE_Error
2034
-     * @throws InvalidArgumentException
2035
-     * @throws ReflectionException
2036
-     * @throws InvalidDataTypeException
2037
-     * @throws InvalidInterfaceException
2038
-     */
2039
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2040
-    {
2041
-        // newly created payments will have nothing recorded for $PAY_ID
2042
-        if (absint($PAY_ID) === 0) {
2043
-            return false;
2044
-        }
2045
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2046
-        if (empty($existing_reg_payment_REG_IDs)) {
2047
-            return false;
2048
-        }
2049
-        /** @type EE_Transaction_Payments $transaction_payments */
2050
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2051
-
2052
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
2053
-            $payment,
2054
-            array(
2055
-                array(
2056
-                    'PAY_ID' => $payment->ID(),
2057
-                    'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
2058
-                ),
2059
-            )
2060
-        );
2061
-    }
2062
-
2063
-
2064
-    /**
2065
-     * _update_registration_payments
2066
-     * this applies the payments to the selected registrations
2067
-     * but only if they have not already been paid for
2068
-     *
2069
-     * @param  EE_Transaction $transaction
2070
-     * @param \EE_Payment     $payment
2071
-     * @param array           $REG_IDs
2072
-     * @return void
2073
-     * @throws EE_Error
2074
-     * @throws InvalidArgumentException
2075
-     * @throws ReflectionException
2076
-     * @throws RuntimeException
2077
-     * @throws InvalidDataTypeException
2078
-     * @throws InvalidInterfaceException
2079
-     */
2080
-    protected function _update_registration_payments(
2081
-        EE_Transaction $transaction,
2082
-        EE_Payment $payment,
2083
-        $REG_IDs = array()
2084
-    ) {
2085
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2086
-        // so let's do that using our set of REG_IDs from the form
2087
-        $registration_query_where_params = array(
2088
-            'REG_ID' => array('IN', $REG_IDs),
2089
-        );
2090
-        // but add in some conditions regarding payment,
2091
-        // so that we don't apply payments to registrations that are free or have already been paid for
2092
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2093
-        if (! $payment->is_a_refund()) {
2094
-            $registration_query_where_params['REG_final_price'] = array('!=', 0);
2095
-            $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2096
-        }
2097
-        $registrations = $transaction->registrations(array($registration_query_where_params));
2098
-        if (! empty($registrations)) {
2099
-            /** @type EE_Payment_Processor $payment_processor */
2100
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2101
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
2102
-        }
2103
-    }
2104
-
2105
-
2106
-    /**
2107
-     * _process_registration_status_change
2108
-     * This processes requested registration status changes for all the registrations
2109
-     * on a given transaction and (optionally) sends out notifications for the changes.
2110
-     *
2111
-     * @param  EE_Transaction $transaction
2112
-     * @param array           $REG_IDs
2113
-     * @return bool
2114
-     * @throws EE_Error
2115
-     * @throws InvalidArgumentException
2116
-     * @throws ReflectionException
2117
-     * @throws InvalidDataTypeException
2118
-     * @throws InvalidInterfaceException
2119
-     */
2120
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2121
-    {
2122
-        // first if there is no change in status then we get out.
2123
-        if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2124
-            || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2125
-        ) {
2126
-            // no error message, no change requested, just nothing to do man.
2127
-            return false;
2128
-        }
2129
-        /** @type EE_Transaction_Processor $transaction_processor */
2130
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2131
-
2132
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2133
-        return $transaction_processor->manually_update_registration_statuses(
2134
-            $transaction,
2135
-            sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2136
-            array(array('REG_ID' => array('IN', $REG_IDs)))
2137
-        );
2138
-    }
2139
-
2140
-
2141
-    /**
2142
-     * _build_payment_json_response
2143
-     *
2144
-     * @access public
2145
-     * @param \EE_Payment $payment
2146
-     * @param array       $REG_IDs
2147
-     * @param bool | null $delete_txn_reg_status_change
2148
-     * @return array
2149
-     * @throws EE_Error
2150
-     * @throws InvalidArgumentException
2151
-     * @throws InvalidDataTypeException
2152
-     * @throws InvalidInterfaceException
2153
-     * @throws ReflectionException
2154
-     */
2155
-    protected function _build_payment_json_response(
2156
-        EE_Payment $payment,
2157
-        $REG_IDs = array(),
2158
-        $delete_txn_reg_status_change = null
2159
-    ) {
2160
-        // was the payment deleted ?
2161
-        if (is_bool($delete_txn_reg_status_change)) {
2162
-            return array(
2163
-                'PAY_ID'                       => $payment->ID(),
2164
-                'amount'                       => $payment->amount(),
2165
-                'total_paid'                   => $payment->transaction()->paid(),
2166
-                'txn_status'                   => $payment->transaction()->status_ID(),
2167
-                'pay_status'                   => $payment->STS_ID(),
2168
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2169
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2170
-            );
2171
-        } else {
2172
-            $this->_get_payment_status_array();
2173
-
2174
-            return array(
2175
-                'amount'           => $payment->amount(),
2176
-                'total_paid'       => $payment->transaction()->paid(),
2177
-                'txn_status'       => $payment->transaction()->status_ID(),
2178
-                'pay_status'       => $payment->STS_ID(),
2179
-                'PAY_ID'           => $payment->ID(),
2180
-                'STS_ID'           => $payment->STS_ID(),
2181
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2182
-                'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2183
-                'method'           => strtoupper($payment->source()),
2184
-                'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2185
-                'gateway'          => $payment->payment_method()
2186
-                    ? $payment->payment_method()->admin_name()
2187
-                    : esc_html__('Unknown', 'event_espresso'),
2188
-                'gateway_response' => $payment->gateway_response(),
2189
-                'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2190
-                'po_number'        => $payment->po_number(),
2191
-                'extra_accntng'    => $payment->extra_accntng(),
2192
-                'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2193
-            );
2194
-        }
2195
-    }
2196
-
2197
-
2198
-    /**
2199
-     * delete_payment
2200
-     *    delete a payment or refund made towards a transaction
2201
-     *
2202
-     * @access public
2203
-     * @return void
2204
-     * @throws EE_Error
2205
-     * @throws InvalidArgumentException
2206
-     * @throws ReflectionException
2207
-     * @throws InvalidDataTypeException
2208
-     * @throws InvalidInterfaceException
2209
-     */
2210
-    public function delete_payment()
2211
-    {
2212
-        $json_response_data = array('return_data' => false);
2213
-        $PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2214
-            ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2215
-            : 0;
2216
-        $can_delete = EE_Registry::instance()->CAP->current_user_can(
2217
-            'ee_delete_payments',
2218
-            'delete_payment_from_registration_details'
2219
-        );
2220
-        if ($PAY_ID && $can_delete) {
2221
-            $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2222
-                ? $this->_req_data['delete_txn_reg_status_change']
2223
-                : false;
2224
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2225
-            if ($payment instanceof EE_Payment) {
2226
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2227
-                /** @type EE_Transaction_Payments $transaction_payments */
2228
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2229
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2230
-                    $json_response_data['return_data'] = $this->_build_payment_json_response(
2231
-                        $payment,
2232
-                        $REG_IDs,
2233
-                        $delete_txn_reg_status_change
2234
-                    );
2235
-                    if ($delete_txn_reg_status_change) {
2236
-                        $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2237
-                        // MAKE sure we also add the delete_txn_req_status_change to the
2238
-                        // $_REQUEST global because that's how messages will be looking for it.
2239
-                        $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2240
-                        $this->_maybe_send_notifications();
2241
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2242
-                    }
2243
-                }
2244
-            } else {
2245
-                EE_Error::add_error(
2246
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2247
-                    __FILE__,
2248
-                    __FUNCTION__,
2249
-                    __LINE__
2250
-                );
2251
-            }
2252
-        } elseif ($can_delete) {
2253
-            EE_Error::add_error(
2254
-                esc_html__(
2255
-                    'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2256
-                    'event_espresso'
2257
-                ),
2258
-                __FILE__,
2259
-                __FUNCTION__,
2260
-                __LINE__
2261
-            );
2262
-        } else {
2263
-            EE_Error::add_error(
2264
-                esc_html__(
2265
-                    'You do not have access to delete a payment.',
2266
-                    'event_espresso'
2267
-                ),
2268
-                __FILE__,
2269
-                __FUNCTION__,
2270
-                __LINE__
2271
-            );
2272
-        }
2273
-        $notices = EE_Error::get_notices(false, false, false);
2274
-        $this->_template_args = array(
2275
-            'data'      => $json_response_data,
2276
-            'success'   => $notices['success'],
2277
-            'error'     => $notices['errors'],
2278
-            'attention' => $notices['attention'],
2279
-        );
2280
-        $this->_return_json();
2281
-    }
2282
-
2283
-
2284
-    /**
2285
-     * _registration_payment_data_array
2286
-     * adds info for 'owing' and 'paid' for each registration to the json response
2287
-     *
2288
-     * @access protected
2289
-     * @param array $REG_IDs
2290
-     * @return array
2291
-     * @throws EE_Error
2292
-     * @throws InvalidArgumentException
2293
-     * @throws InvalidDataTypeException
2294
-     * @throws InvalidInterfaceException
2295
-     * @throws ReflectionException
2296
-     */
2297
-    protected function _registration_payment_data_array($REG_IDs)
2298
-    {
2299
-        $registration_payment_data = array();
2300
-        // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2301
-        if (! empty($REG_IDs)) {
2302
-            $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2303
-            foreach ($registrations as $registration) {
2304
-                if ($registration instanceof EE_Registration) {
2305
-                    $registration_payment_data[ $registration->ID() ] = array(
2306
-                        'paid'  => $registration->pretty_paid(),
2307
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2308
-                    );
2309
-                }
2310
-            }
2311
-        }
2312
-
2313
-        return $registration_payment_data;
2314
-    }
2315
-
2316
-
2317
-    /**
2318
-     * _maybe_send_notifications
2319
-     * determines whether or not the admin has indicated that notifications should be sent.
2320
-     * If so, will toggle a filter switch for delivering registration notices.
2321
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
2322
-     *
2323
-     * @access protected
2324
-     * @param \EE_Payment | null $payment
2325
-     */
2326
-    protected function _maybe_send_notifications($payment = null)
2327
-    {
2328
-        switch ($payment instanceof EE_Payment) {
2329
-            // payment notifications
2330
-            case true:
2331
-                if (isset($this->_req_data['txn_payments']['send_notifications'])
2332
-                    && filter_var(
2333
-                        $this->_req_data['txn_payments']['send_notifications'],
2334
-                        FILTER_VALIDATE_BOOLEAN
2335
-                    )
2336
-                ) {
2337
-                    $this->_process_payment_notification($payment);
2338
-                }
2339
-                break;
2340
-            // registration notifications
2341
-            case false:
2342
-                if (isset($this->_req_data['txn_reg_status_change']['send_notifications'])
2343
-                    && filter_var(
2344
-                        $this->_req_data['txn_reg_status_change']['send_notifications'],
2345
-                        FILTER_VALIDATE_BOOLEAN
2346
-                    )
2347
-                ) {
2348
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2349
-                }
2350
-                break;
2351
-        }
2352
-    }
2353
-
2354
-
2355
-    /**
2356
-     * _send_payment_reminder
2357
-     *    generates HTML for the View Transaction Details Admin page
2358
-     *
2359
-     * @access protected
2360
-     * @return void
2361
-     * @throws EE_Error
2362
-     * @throws InvalidArgumentException
2363
-     * @throws InvalidDataTypeException
2364
-     * @throws InvalidInterfaceException
2365
-     */
2366
-    protected function _send_payment_reminder()
2367
-    {
2368
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2369
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2370
-        $query_args = isset($this->_req_data['redirect_to']) ? array(
2371
-            'action' => $this->_req_data['redirect_to'],
2372
-            'TXN_ID' => $this->_req_data['TXN_ID'],
2373
-        ) : array();
2374
-        do_action(
2375
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2376
-            $transaction
2377
-        );
2378
-        $this->_redirect_after_action(
2379
-            false,
2380
-            esc_html__('payment reminder', 'event_espresso'),
2381
-            esc_html__('sent', 'event_espresso'),
2382
-            $query_args,
2383
-            true
2384
-        );
2385
-    }
2386
-
2387
-
2388
-    /**
2389
-     *  get_transactions
2390
-     *    get transactions for given parameters (used by list table)
2391
-     *
2392
-     * @param  int     $perpage how many transactions displayed per page
2393
-     * @param  boolean $count   return the count or objects
2394
-     * @param string   $view
2395
-     * @return mixed int = count || array of transaction objects
2396
-     * @throws EE_Error
2397
-     * @throws InvalidArgumentException
2398
-     * @throws InvalidDataTypeException
2399
-     * @throws InvalidInterfaceException
2400
-     */
2401
-    public function get_transactions($perpage, $count = false, $view = '')
2402
-    {
2403
-
2404
-        $TXN = EEM_Transaction::instance();
2405
-
2406
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
2407
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2408
-            : date(
2409
-                'm/d/Y',
2410
-                strtotime('-10 year')
2411
-            );
2412
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
2413
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2414
-            : date('m/d/Y');
2415
-
2416
-        // make sure our timestamps start and end right at the boundaries for each day
2417
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2418
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2419
-
2420
-
2421
-        // convert to timestamps
2422
-        $start_date = strtotime($start_date);
2423
-        $end_date = strtotime($end_date);
2424
-
2425
-        // makes sure start date is the lowest value and vice versa
2426
-        $start_date = min($start_date, $end_date);
2427
-        $end_date = max($start_date, $end_date);
2428
-
2429
-        // convert to correct format for query
2430
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2431
-            'TXN_timestamp',
2432
-            date('Y-m-d H:i:s', $start_date),
2433
-            'Y-m-d H:i:s'
2434
-        );
2435
-        $end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2436
-            'TXN_timestamp',
2437
-            date('Y-m-d H:i:s', $end_date),
2438
-            'Y-m-d H:i:s'
2439
-        );
2440
-
2441
-
2442
-        // set orderby
2443
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2444
-
2445
-        switch ($this->_req_data['orderby']) {
2446
-            case 'TXN_ID':
2447
-                $orderby = 'TXN_ID';
2448
-                break;
2449
-            case 'ATT_fname':
2450
-                $orderby = 'Registration.Attendee.ATT_fname';
2451
-                break;
2452
-            case 'event_name':
2453
-                $orderby = 'Registration.Event.EVT_name';
2454
-                break;
2455
-            default: // 'TXN_timestamp'
2456
-                $orderby = 'TXN_timestamp';
2457
-        }
2458
-
2459
-        $sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2460
-        $current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2461
-        $per_page = ! empty($perpage) ? $perpage : 10;
2462
-        $per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2463
-
2464
-        $offset = ($current_page - 1) * $per_page;
2465
-        $limit = array($offset, $per_page);
2466
-
2467
-        $_where = array(
2468
-            'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2469
-            'Registration.REG_count' => 1,
2470
-        );
2471
-
2472
-        if (isset($this->_req_data['EVT_ID'])) {
2473
-            $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2474
-        }
2475
-
2476
-        if (isset($this->_req_data['s'])) {
2477
-            $search_string = '%' . $this->_req_data['s'] . '%';
2478
-            $_where['OR'] = array(
2479
-                'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2480
-                'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2481
-                'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2482
-                'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2483
-                'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2484
-                'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2485
-                'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2486
-                'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2487
-                'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2488
-                'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2489
-                'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2490
-                'Registration.REG_final_price'        => array('LIKE', $search_string),
2491
-                'Registration.REG_code'               => array('LIKE', $search_string),
2492
-                'Registration.REG_count'              => array('LIKE', $search_string),
2493
-                'Registration.REG_group_size'         => array('LIKE', $search_string),
2494
-                'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2495
-                'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2496
-                'Payment.PAY_source'                  => array('LIKE', $search_string),
2497
-                'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2498
-                'TXN_session_data'                    => array('LIKE', $search_string),
2499
-                'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2500
-            );
2501
-        }
2502
-
2503
-        // failed transactions
2504
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2505
-                  || ($count && $view === 'failed');
2506
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2507
-                     || ($count && $view === 'abandoned');
2508
-        $incomplete = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2509
-                      || ($count && $view === 'incomplete');
2510
-
2511
-        if ($failed) {
2512
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
2513
-        } elseif ($abandoned) {
2514
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2515
-        } elseif ($incomplete) {
2516
-            $_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2517
-        } else {
2518
-            $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2519
-            $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2520
-        }
2521
-
2522
-        $query_params = apply_filters(
2523
-            'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2524
-            array(
2525
-                $_where,
2526
-                'order_by'                 => array($orderby => $sort),
2527
-                'limit'                    => $limit,
2528
-                'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2529
-            ),
2530
-            $this->_req_data,
2531
-            $view,
2532
-            $count
2533
-        );
2534
-
2535
-        $transactions = $count
2536
-            ? $TXN->count(array($query_params[0]), 'TXN_ID', true)
2537
-            : $TXN->get_all($query_params);
2538
-
2539
-        return $transactions;
2540
-    }
2541
-
2542
-
2543
-    /**
2544
-     * @since 4.9.79.p
2545
-     * @throws EE_Error
2546
-     * @throws InvalidArgumentException
2547
-     * @throws InvalidDataTypeException
2548
-     * @throws InvalidInterfaceException
2549
-     * @throws ReflectionException
2550
-     * @throws RuntimeException
2551
-     */
2552
-    public function recalculateLineItems()
2553
-    {
2554
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2555
-        /** @var EE_Transaction $transaction */
2556
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2557
-        $total_line_item = $transaction->total_line_item(false);
2558
-        $success = false;
2559
-        if ($total_line_item instanceof EE_Line_Item) {
2560
-            EEH_Line_Item::resetIsTaxableForTickets($total_line_item);
2561
-            $success = EEH_Line_Item::apply_taxes($total_line_item, true);
2562
-        }
2563
-        $this->_redirect_after_action(
2564
-            (bool) $success,
2565
-            esc_html__('Transaction taxes and totals', 'event_espresso'),
2566
-            esc_html__('recalculated', 'event_espresso'),
2567
-            isset($this->_req_data['redirect_to'])
2568
-                ? array(
2569
-                'action' => $this->_req_data['redirect_to'],
2570
-                'TXN_ID' => $this->_req_data['TXN_ID'],
2571
-            )
2572
-                : array(),
2573
-            true
2574
-        );
2575
-    }
16
+	/**
17
+	 * @var EE_Transaction
18
+	 */
19
+	private $_transaction;
20
+
21
+	/**
22
+	 * @var EE_Session
23
+	 */
24
+	private $_session;
25
+
26
+	/**
27
+	 * @var array $_txn_status
28
+	 */
29
+	private static $_txn_status;
30
+
31
+	/**
32
+	 * @var array $_pay_status
33
+	 */
34
+	private static $_pay_status;
35
+
36
+	/**
37
+	 * @var array $_existing_reg_payment_REG_IDs
38
+	 */
39
+	protected $_existing_reg_payment_REG_IDs;
40
+
41
+
42
+	/**
43
+	 *    _init_page_props
44
+	 *
45
+	 * @return void
46
+	 */
47
+	protected function _init_page_props()
48
+	{
49
+		$this->page_slug = TXN_PG_SLUG;
50
+		$this->page_label = esc_html__('Transactions', 'event_espresso');
51
+		$this->_admin_base_url = TXN_ADMIN_URL;
52
+		$this->_admin_base_path = TXN_ADMIN;
53
+	}
54
+
55
+
56
+	/**
57
+	 *    _ajax_hooks
58
+	 *
59
+	 * @return void
60
+	 */
61
+	protected function _ajax_hooks()
62
+	{
63
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
64
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
65
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
66
+	}
67
+
68
+
69
+	/**
70
+	 *    _define_page_props
71
+	 *
72
+	 * @return void
73
+	 */
74
+	protected function _define_page_props()
75
+	{
76
+		$this->_admin_page_title = $this->page_label;
77
+		$this->_labels = array(
78
+			'buttons' => array(
79
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
+			),
83
+		);
84
+	}
85
+
86
+
87
+	/**
88
+	 *        grab url requests and route them
89
+	 *
90
+	 * @access private
91
+	 * @return void
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 */
97
+	public function _set_page_routes()
98
+	{
99
+
100
+		$this->_set_transaction_status_array();
101
+
102
+		$txn_id = ! empty($this->_req_data['TXN_ID'])
103
+				  && ! is_array($this->_req_data['TXN_ID'])
104
+			? $this->_req_data['TXN_ID']
105
+			: 0;
106
+
107
+		$this->_page_routes = array(
108
+
109
+			'default' => array(
110
+				'func'       => '_transactions_overview_list_table',
111
+				'capability' => 'ee_read_transactions',
112
+			),
113
+
114
+			'view_transaction' => array(
115
+				'func'       => '_transaction_details',
116
+				'capability' => 'ee_read_transaction',
117
+				'obj_id'     => $txn_id,
118
+			),
119
+
120
+			'send_payment_reminder' => array(
121
+				'func'       => '_send_payment_reminder',
122
+				'noheader'   => true,
123
+				'capability' => 'ee_send_message',
124
+			),
125
+
126
+			'espresso_apply_payment' => array(
127
+				'func'       => 'apply_payments_or_refunds',
128
+				'noheader'   => true,
129
+				'capability' => 'ee_edit_payments',
130
+			),
131
+
132
+			'espresso_apply_refund' => array(
133
+				'func'       => 'apply_payments_or_refunds',
134
+				'noheader'   => true,
135
+				'capability' => 'ee_edit_payments',
136
+			),
137
+
138
+			'espresso_delete_payment' => array(
139
+				'func'       => 'delete_payment',
140
+				'noheader'   => true,
141
+				'capability' => 'ee_delete_payments',
142
+			),
143
+
144
+			'espresso_recalculate_line_items' => array(
145
+				'func'       => 'recalculateLineItems',
146
+				'noheader'   => true,
147
+				'capability' => 'ee_edit_payments',
148
+			),
149
+
150
+		);
151
+	}
152
+
153
+
154
+	protected function _set_page_config()
155
+	{
156
+		$this->_page_config = array(
157
+			'default'          => array(
158
+				'nav'           => array(
159
+					'label' => esc_html__('Overview', 'event_espresso'),
160
+					'order' => 10,
161
+				),
162
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
163
+				'help_tabs'     => array(
164
+					'transactions_overview_help_tab'                       => array(
165
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
166
+						'filename' => 'transactions_overview',
167
+					),
168
+					'transactions_overview_table_column_headings_help_tab' => array(
169
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
170
+						'filename' => 'transactions_overview_table_column_headings',
171
+					),
172
+					'transactions_overview_views_filters_help_tab'         => array(
173
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
174
+						'filename' => 'transactions_overview_views_filters_search',
175
+					),
176
+				),
177
+				'help_tour'     => array('Transactions_Overview_Help_Tour'),
178
+				/**
179
+				 * commented out because currently we are not displaying tips for transaction list table status but this
180
+				 * may change in a later iteration so want to keep the code for then.
181
+				 */
182
+				// 'qtips' => array( 'Transactions_List_Table_Tips' ),
183
+				'require_nonce' => false,
184
+			),
185
+			'view_transaction' => array(
186
+				'nav'       => array(
187
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
188
+					'order'      => 5,
189
+					'url'        => isset($this->_req_data['TXN_ID'])
190
+						? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
191
+						: $this->_admin_base_url,
192
+					'persistent' => false,
193
+				),
194
+				'help_tabs' => array(
195
+					'transactions_view_transaction_help_tab'                                              => array(
196
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
197
+						'filename' => 'transactions_view_transaction',
198
+					),
199
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
200
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
201
+						'filename' => 'transactions_view_transaction_transaction_details_table',
202
+					),
203
+					'transactions_view_transaction_attendees_registered_help_tab'                         => array(
204
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
205
+						'filename' => 'transactions_view_transaction_attendees_registered',
206
+					),
207
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
208
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
209
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
210
+					),
211
+				),
212
+				'qtips'     => array('Transaction_Details_Tips'),
213
+				'help_tour' => array('Transaction_Details_Help_Tour'),
214
+				'metaboxes' => array('_transaction_details_metaboxes'),
215
+
216
+				'require_nonce' => false,
217
+			),
218
+		);
219
+	}
220
+
221
+
222
+	/**
223
+	 * The below methods aren't used by this class currently
224
+	 */
225
+	protected function _add_screen_options()
226
+	{
227
+		// noop
228
+	}
229
+
230
+
231
+	protected function _add_feature_pointers()
232
+	{
233
+		// noop
234
+	}
235
+
236
+
237
+	public function admin_init()
238
+	{
239
+		// IF a registration was JUST added via the admin...
240
+		if (isset(
241
+			$this->_req_data['redirect_from'],
242
+			$this->_req_data['EVT_ID'],
243
+			$this->_req_data['event_name']
244
+		)) {
245
+			// then set a cookie so that we can block any attempts to use
246
+			// the back button as a way to enter another registration.
247
+			setcookie(
248
+				'ee_registration_added',
249
+				$this->_req_data['EVT_ID'],
250
+				time() + WEEK_IN_SECONDS,
251
+				'/'
252
+			);
253
+			// and update the global
254
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
255
+		}
256
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
257
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
258
+			'event_espresso'
259
+		);
260
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
261
+			'An error occurred! Please refresh the page and try again.',
262
+			'event_espresso'
263
+		);
264
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
265
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
266
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
267
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
268
+			'This transaction has been overpaid ! Payments Total',
269
+			'event_espresso'
270
+		);
271
+	}
272
+
273
+
274
+	public function admin_notices()
275
+	{
276
+		// noop
277
+	}
278
+
279
+
280
+	public function admin_footer_scripts()
281
+	{
282
+		// noop
283
+	}
284
+
285
+
286
+	/**
287
+	 * _set_transaction_status_array
288
+	 * sets list of transaction statuses
289
+	 *
290
+	 * @access private
291
+	 * @return void
292
+	 * @throws EE_Error
293
+	 * @throws InvalidArgumentException
294
+	 * @throws InvalidDataTypeException
295
+	 * @throws InvalidInterfaceException
296
+	 */
297
+	private function _set_transaction_status_array()
298
+	{
299
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
300
+	}
301
+
302
+
303
+	/**
304
+	 * get_transaction_status_array
305
+	 * return the transaction status array for wp_list_table
306
+	 *
307
+	 * @access public
308
+	 * @return array
309
+	 */
310
+	public function get_transaction_status_array()
311
+	{
312
+		return self::$_txn_status;
313
+	}
314
+
315
+
316
+	/**
317
+	 *    get list of payment statuses
318
+	 *
319
+	 * @access private
320
+	 * @return void
321
+	 * @throws EE_Error
322
+	 * @throws InvalidArgumentException
323
+	 * @throws InvalidDataTypeException
324
+	 * @throws InvalidInterfaceException
325
+	 */
326
+	private function _get_payment_status_array()
327
+	{
328
+		self::$_pay_status = EEM_Payment::instance()->status_array(true);
329
+		$this->_template_args['payment_status'] = self::$_pay_status;
330
+	}
331
+
332
+
333
+	/**
334
+	 *    _add_screen_options_default
335
+	 *
336
+	 * @access protected
337
+	 * @return void
338
+	 * @throws InvalidArgumentException
339
+	 * @throws InvalidDataTypeException
340
+	 * @throws InvalidInterfaceException
341
+	 */
342
+	protected function _add_screen_options_default()
343
+	{
344
+		$this->_per_page_screen_option();
345
+	}
346
+
347
+
348
+	/**
349
+	 * load_scripts_styles
350
+	 *
351
+	 * @access public
352
+	 * @return void
353
+	 */
354
+	public function load_scripts_styles()
355
+	{
356
+		// enqueue style
357
+		wp_register_style(
358
+			'espresso_txn',
359
+			TXN_ASSETS_URL . 'espresso_transactions_admin.css',
360
+			array(),
361
+			EVENT_ESPRESSO_VERSION
362
+		);
363
+		wp_enqueue_style('espresso_txn');
364
+		// scripts
365
+		wp_register_script(
366
+			'espresso_txn',
367
+			TXN_ASSETS_URL . 'espresso_transactions_admin.js',
368
+			array(
369
+				'ee_admin_js',
370
+				'ee-datepicker',
371
+				'jquery-ui-datepicker',
372
+				'jquery-ui-draggable',
373
+				'ee-dialog',
374
+				'ee-accounting',
375
+				'ee-serialize-full-array',
376
+			),
377
+			EVENT_ESPRESSO_VERSION,
378
+			true
379
+		);
380
+		wp_enqueue_script('espresso_txn');
381
+	}
382
+
383
+
384
+	/**
385
+	 *    load_scripts_styles_view_transaction
386
+	 *
387
+	 * @access public
388
+	 * @return void
389
+	 */
390
+	public function load_scripts_styles_view_transaction()
391
+	{
392
+		// styles
393
+		wp_enqueue_style('espresso-ui-theme');
394
+	}
395
+
396
+
397
+	/**
398
+	 *    load_scripts_styles_default
399
+	 *
400
+	 * @access public
401
+	 * @return void
402
+	 */
403
+	public function load_scripts_styles_default()
404
+	{
405
+		// styles
406
+		wp_enqueue_style('espresso-ui-theme');
407
+	}
408
+
409
+
410
+	/**
411
+	 *    _set_list_table_views_default
412
+	 *
413
+	 * @access protected
414
+	 * @return void
415
+	 */
416
+	protected function _set_list_table_views_default()
417
+	{
418
+		$this->_views = array(
419
+			'all'        => array(
420
+				'slug'  => 'all',
421
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
422
+				'count' => 0,
423
+			),
424
+			'abandoned'  => array(
425
+				'slug'  => 'abandoned',
426
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
427
+				'count' => 0,
428
+			),
429
+			'incomplete' => array(
430
+				'slug'  => 'incomplete',
431
+				'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
432
+				'count' => 0,
433
+			),
434
+		);
435
+		if (/**
436
+		 * Filters whether a link to the "Failed Transactions" list table
437
+		 * appears on the Transactions Admin Page list table.
438
+		 * List display can be turned back on via the following:
439
+		 * add_filter(
440
+		 *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
441
+		 *     '__return_true'
442
+		 * );
443
+		 *
444
+		 * @since 4.9.70.p
445
+		 * @param boolean                 $display_failed_txns_list
446
+		 * @param Transactions_Admin_Page $this
447
+		 */
448
+		apply_filters(
449
+			'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
450
+			false,
451
+			$this
452
+		)
453
+		) {
454
+			$this->_views['failed'] = array(
455
+				'slug'  => 'failed',
456
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
457
+				'count' => 0,
458
+			);
459
+		}
460
+	}
461
+
462
+
463
+	/**
464
+	 * _set_transaction_object
465
+	 * This sets the _transaction property for the transaction details screen
466
+	 *
467
+	 * @access private
468
+	 * @return void
469
+	 * @throws EE_Error
470
+	 * @throws InvalidArgumentException
471
+	 * @throws RuntimeException
472
+	 * @throws InvalidDataTypeException
473
+	 * @throws InvalidInterfaceException
474
+	 * @throws ReflectionException
475
+	 */
476
+	private function _set_transaction_object()
477
+	{
478
+		if ($this->_transaction instanceof EE_Transaction) {
479
+			return;
480
+		} //get out we've already set the object
481
+
482
+		$TXN_ID = ! empty($this->_req_data['TXN_ID'])
483
+			? absint($this->_req_data['TXN_ID'])
484
+			: false;
485
+
486
+		// get transaction object
487
+		$this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
488
+		$this->_session = $this->_transaction instanceof EE_Transaction
489
+			? $this->_transaction->session_data()
490
+			: null;
491
+		if ($this->_transaction instanceof EE_Transaction) {
492
+			$this->_transaction->verify_abandoned_transaction_status();
493
+		}
494
+
495
+		if (! $this->_transaction instanceof EE_Transaction) {
496
+			$error_msg = sprintf(
497
+				esc_html__(
498
+					'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
499
+					'event_espresso'
500
+				),
501
+				$TXN_ID
502
+			);
503
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
504
+		}
505
+	}
506
+
507
+
508
+	/**
509
+	 *    _transaction_legend_items
510
+	 *
511
+	 * @access protected
512
+	 * @return array
513
+	 * @throws EE_Error
514
+	 * @throws InvalidArgumentException
515
+	 * @throws ReflectionException
516
+	 * @throws InvalidDataTypeException
517
+	 * @throws InvalidInterfaceException
518
+	 */
519
+	protected function _transaction_legend_items()
520
+	{
521
+		EE_Registry::instance()->load_helper('MSG_Template');
522
+		$items = array();
523
+
524
+		if (EE_Registry::instance()->CAP->current_user_can(
525
+			'ee_read_global_messages',
526
+			'view_filtered_messages'
527
+		)) {
528
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
529
+			if (is_array($related_for_icon)
530
+				&& isset($related_for_icon['css_class'], $related_for_icon['label'])
531
+			) {
532
+				$items['view_related_messages'] = array(
533
+					'class' => $related_for_icon['css_class'],
534
+					'desc'  => $related_for_icon['label'],
535
+				);
536
+			}
537
+		}
538
+
539
+		$items = apply_filters(
540
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
541
+			array_merge(
542
+				$items,
543
+				array(
544
+					'view_details'          => array(
545
+						'class' => 'dashicons dashicons-cart',
546
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
547
+					),
548
+					'view_invoice'          => array(
549
+						'class' => 'dashicons dashicons-media-spreadsheet',
550
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
551
+					),
552
+					'view_receipt'          => array(
553
+						'class' => 'dashicons dashicons-media-default',
554
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
555
+					),
556
+					'view_registration'     => array(
557
+						'class' => 'dashicons dashicons-clipboard',
558
+						'desc'  => esc_html__('View Registration Details', 'event_espresso'),
559
+					),
560
+					'payment_overview_link' => array(
561
+						'class' => 'dashicons dashicons-money',
562
+						'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
563
+					),
564
+				)
565
+			)
566
+		);
567
+
568
+		if (EEH_MSG_Template::is_mt_active('payment_reminder')
569
+			&& EE_Registry::instance()->CAP->current_user_can(
570
+				'ee_send_message',
571
+				'espresso_transactions_send_payment_reminder'
572
+			)
573
+		) {
574
+			$items['send_payment_reminder'] = array(
575
+				'class' => 'dashicons dashicons-email-alt',
576
+				'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
577
+			);
578
+		} else {
579
+			$items['blank*'] = array(
580
+				'class' => '',
581
+				'desc'  => '',
582
+			);
583
+		}
584
+		$more_items = apply_filters(
585
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
586
+			array(
587
+				'overpaid'   => array(
588
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
589
+					'desc'  => EEH_Template::pretty_status(
590
+						EEM_Transaction::overpaid_status_code,
591
+						false,
592
+						'sentence'
593
+					),
594
+				),
595
+				'complete'   => array(
596
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
597
+					'desc'  => EEH_Template::pretty_status(
598
+						EEM_Transaction::complete_status_code,
599
+						false,
600
+						'sentence'
601
+					),
602
+				),
603
+				'incomplete' => array(
604
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
605
+					'desc'  => EEH_Template::pretty_status(
606
+						EEM_Transaction::incomplete_status_code,
607
+						false,
608
+						'sentence'
609
+					),
610
+				),
611
+				'abandoned'  => array(
612
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
613
+					'desc'  => EEH_Template::pretty_status(
614
+						EEM_Transaction::abandoned_status_code,
615
+						false,
616
+						'sentence'
617
+					),
618
+				),
619
+				'failed'     => array(
620
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
621
+					'desc'  => EEH_Template::pretty_status(
622
+						EEM_Transaction::failed_status_code,
623
+						false,
624
+						'sentence'
625
+					),
626
+				),
627
+			)
628
+		);
629
+
630
+		return array_merge($items, $more_items);
631
+	}
632
+
633
+
634
+	/**
635
+	 *    _transactions_overview_list_table
636
+	 *
637
+	 * @access protected
638
+	 * @return void
639
+	 * @throws DomainException
640
+	 * @throws EE_Error
641
+	 * @throws InvalidArgumentException
642
+	 * @throws InvalidDataTypeException
643
+	 * @throws InvalidInterfaceException
644
+	 * @throws ReflectionException
645
+	 */
646
+	protected function _transactions_overview_list_table()
647
+	{
648
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
649
+		$event = isset($this->_req_data['EVT_ID'])
650
+			? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
651
+			: null;
652
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event
653
+			? sprintf(
654
+				esc_html__(
655
+					'%sViewing Transactions for the Event: %s%s',
656
+					'event_espresso'
657
+				),
658
+				'<h3>',
659
+				'<a href="'
660
+				. EE_Admin_Page::add_query_args_and_nonce(
661
+					array('action' => 'edit', 'post' => $event->ID()),
662
+					EVENTS_ADMIN_URL
663
+				)
664
+				. '" title="'
665
+				. esc_attr__(
666
+					'Click to Edit event',
667
+					'event_espresso'
668
+				)
669
+				. '">' . $event->name() . '</a>',
670
+				'</h3>'
671
+			)
672
+			: '';
673
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
674
+		$this->display_admin_list_table_page_with_no_sidebar();
675
+	}
676
+
677
+
678
+	/**
679
+	 *    _transaction_details
680
+	 * generates HTML for the View Transaction Details Admin page
681
+	 *
682
+	 * @access protected
683
+	 * @return void
684
+	 * @throws DomainException
685
+	 * @throws EE_Error
686
+	 * @throws InvalidArgumentException
687
+	 * @throws InvalidDataTypeException
688
+	 * @throws InvalidInterfaceException
689
+	 * @throws RuntimeException
690
+	 * @throws ReflectionException
691
+	 */
692
+	protected function _transaction_details()
693
+	{
694
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
695
+
696
+		$this->_set_transaction_status_array();
697
+
698
+		$this->_template_args = array();
699
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
700
+
701
+		$this->_set_transaction_object();
702
+
703
+		if (! $this->_transaction instanceof EE_Transaction) {
704
+			return;
705
+		}
706
+		$primary_registration = $this->_transaction->primary_registration();
707
+		$attendee = $primary_registration instanceof EE_Registration
708
+			? $primary_registration->attendee()
709
+			: null;
710
+
711
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
712
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
713
+
714
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
715
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
716
+
717
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
718
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
719
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
720
+
721
+		$this->_template_args['grand_total'] = $this->_transaction->total();
722
+		$this->_template_args['total_paid'] = $this->_transaction->paid();
723
+
724
+		$amount_due = $this->_transaction->total() - $this->_transaction->paid();
725
+		$this->_template_args['amount_due'] = EEH_Template::format_currency(
726
+			$amount_due,
727
+			true
728
+		);
729
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
730
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
731
+												  . $this->_template_args['amount_due'];
732
+		} else {
733
+			$this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
734
+		}
735
+		$this->_template_args['amount_due_class'] = '';
736
+
737
+		if ($this->_transaction->paid() === $this->_transaction->total()) {
738
+			// paid in full
739
+			$this->_template_args['amount_due'] = false;
740
+		} elseif ($this->_transaction->paid() > $this->_transaction->total()) {
741
+			// overpaid
742
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
743
+		} elseif ($this->_transaction->total() > (float) 0) {
744
+			if ($this->_transaction->paid() > (float) 0) {
745
+				// monies owing
746
+				$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
747
+			} elseif ($this->_transaction->paid() === (float) 0) {
748
+				// no payments made yet
749
+				$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
750
+			}
751
+		} elseif ($this->_transaction->total() === (float) 0) {
752
+			// free event
753
+			$this->_template_args['amount_due'] = false;
754
+		}
755
+
756
+		$payment_method = $this->_transaction->payment_method();
757
+
758
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
759
+			? $payment_method->admin_name()
760
+			: esc_html__('Unknown', 'event_espresso');
761
+
762
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
763
+		// link back to overview
764
+		$this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
765
+			? $_SERVER['HTTP_REFERER']
766
+			: TXN_ADMIN_URL;
767
+
768
+
769
+		// next link
770
+		$next_txn = $this->_transaction->next(
771
+			null,
772
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
773
+			'TXN_ID'
774
+		);
775
+		$this->_template_args['next_transaction'] = $next_txn
776
+			? $this->_next_link(
777
+				EE_Admin_Page::add_query_args_and_nonce(
778
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
779
+					TXN_ADMIN_URL
780
+				),
781
+				'dashicons dashicons-arrow-right ee-icon-size-22'
782
+			)
783
+			: '';
784
+		// previous link
785
+		$previous_txn = $this->_transaction->previous(
786
+			null,
787
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
788
+			'TXN_ID'
789
+		);
790
+		$this->_template_args['previous_transaction'] = $previous_txn
791
+			? $this->_previous_link(
792
+				EE_Admin_Page::add_query_args_and_nonce(
793
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
794
+					TXN_ADMIN_URL
795
+				),
796
+				'dashicons dashicons-arrow-left ee-icon-size-22'
797
+			)
798
+			: '';
799
+
800
+		// were we just redirected here after adding a new registration ???
801
+		if (isset(
802
+			$this->_req_data['redirect_from'],
803
+			$this->_req_data['EVT_ID'],
804
+			$this->_req_data['event_name']
805
+		)) {
806
+			if (EE_Registry::instance()->CAP->current_user_can(
807
+				'ee_edit_registrations',
808
+				'espresso_registrations_new_registration',
809
+				$this->_req_data['EVT_ID']
810
+			)) {
811
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
812
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
813
+					array(
814
+						'page'     => 'espresso_registrations',
815
+						'action'   => 'new_registration',
816
+						'return'   => 'default',
817
+						'TXN_ID'   => $this->_transaction->ID(),
818
+						'event_id' => $this->_req_data['EVT_ID'],
819
+					),
820
+					REG_ADMIN_URL
821
+				);
822
+				$this->_admin_page_title .= '">';
823
+
824
+				$this->_admin_page_title .= sprintf(
825
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
826
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
827
+				);
828
+				$this->_admin_page_title .= '</a>';
829
+			}
830
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
831
+		}
832
+		// grab messages at the last second
833
+		$this->_template_args['notices'] = EE_Error::get_notices();
834
+		// path to template
835
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
836
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template(
837
+			$template_path,
838
+			$this->_template_args,
839
+			true
840
+		);
841
+
842
+		// the details template wrapper
843
+		$this->display_admin_page_with_sidebar();
844
+	}
845
+
846
+
847
+	/**
848
+	 *        _transaction_details_metaboxes
849
+	 *
850
+	 * @access protected
851
+	 * @return void
852
+	 * @throws EE_Error
853
+	 * @throws InvalidArgumentException
854
+	 * @throws InvalidDataTypeException
855
+	 * @throws InvalidInterfaceException
856
+	 * @throws RuntimeException
857
+	 * @throws ReflectionException
858
+	 */
859
+	protected function _transaction_details_metaboxes()
860
+	{
861
+
862
+		$this->_set_transaction_object();
863
+
864
+		if (! $this->_transaction instanceof EE_Transaction) {
865
+			return;
866
+		}
867
+		add_meta_box(
868
+			'edit-txn-details-mbox',
869
+			esc_html__('Transaction Details', 'event_espresso'),
870
+			array($this, 'txn_details_meta_box'),
871
+			$this->_wp_page_slug,
872
+			'normal',
873
+			'high'
874
+		);
875
+		add_meta_box(
876
+			'edit-txn-attendees-mbox',
877
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
878
+			array($this, 'txn_attendees_meta_box'),
879
+			$this->_wp_page_slug,
880
+			'normal',
881
+			'high',
882
+			array('TXN_ID' => $this->_transaction->ID())
883
+		);
884
+		add_meta_box(
885
+			'edit-txn-registrant-mbox',
886
+			esc_html__('Primary Contact', 'event_espresso'),
887
+			array($this, 'txn_registrant_side_meta_box'),
888
+			$this->_wp_page_slug,
889
+			'side',
890
+			'high'
891
+		);
892
+		add_meta_box(
893
+			'edit-txn-billing-info-mbox',
894
+			esc_html__('Billing Information', 'event_espresso'),
895
+			array($this, 'txn_billing_info_side_meta_box'),
896
+			$this->_wp_page_slug,
897
+			'side',
898
+			'high'
899
+		);
900
+	}
901
+
902
+
903
+	/**
904
+	 * Callback for transaction actions metabox.
905
+	 *
906
+	 * @param EE_Transaction|null $transaction
907
+	 * @return string
908
+	 * @throws DomainException
909
+	 * @throws EE_Error
910
+	 * @throws InvalidArgumentException
911
+	 * @throws InvalidDataTypeException
912
+	 * @throws InvalidInterfaceException
913
+	 * @throws ReflectionException
914
+	 * @throws RuntimeException
915
+	 */
916
+	public function getActionButtons(EE_Transaction $transaction = null)
917
+	{
918
+		$content = '';
919
+		$actions = array();
920
+		if (! $transaction instanceof EE_Transaction) {
921
+			return $content;
922
+		}
923
+		/** @var EE_Registration $primary_registration */
924
+		$primary_registration = $transaction->primary_registration();
925
+		$attendee = $primary_registration instanceof EE_Registration
926
+			? $primary_registration->attendee()
927
+			: null;
928
+
929
+		if ($attendee instanceof EE_Attendee
930
+			&& EE_Registry::instance()->CAP->current_user_can(
931
+				'ee_send_message',
932
+				'espresso_transactions_send_payment_reminder'
933
+			)
934
+		) {
935
+			$actions['payment_reminder'] =
936
+				EEH_MSG_Template::is_mt_active('payment_reminder')
937
+				&& $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
938
+				&& $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
939
+					? EEH_Template::get_button_or_link(
940
+						EE_Admin_Page::add_query_args_and_nonce(
941
+							array(
942
+								'action'      => 'send_payment_reminder',
943
+								'TXN_ID'      => $this->_transaction->ID(),
944
+								'redirect_to' => 'view_transaction',
945
+							),
946
+							TXN_ADMIN_URL
947
+						),
948
+						esc_html__(' Send Payment Reminder', 'event_espresso'),
949
+						'button secondary-button',
950
+						'dashicons dashicons-email-alt'
951
+					)
952
+					: '';
953
+		}
954
+
955
+		if (EE_Registry::instance()->CAP->current_user_can(
956
+			'ee_edit_payments',
957
+			'espresso_transactions_recalculate_line_items'
958
+		)
959
+		) {
960
+			$actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
961
+				EE_Admin_Page::add_query_args_and_nonce(
962
+					array(
963
+						'action'      => 'espresso_recalculate_line_items',
964
+						'TXN_ID'      => $this->_transaction->ID(),
965
+						'redirect_to' => 'view_transaction',
966
+					),
967
+					TXN_ADMIN_URL
968
+				),
969
+				esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
970
+				'button secondary-button',
971
+				'dashicons dashicons-update'
972
+			);
973
+		}
974
+
975
+		if ($primary_registration instanceof EE_Registration
976
+			&& EEH_MSG_Template::is_mt_active('receipt')
977
+		) {
978
+			$actions['receipt'] = EEH_Template::get_button_or_link(
979
+				$primary_registration->receipt_url(),
980
+				esc_html__('View Receipt', 'event_espresso'),
981
+				'button secondary-button',
982
+				'dashicons dashicons-media-default'
983
+			);
984
+		}
985
+
986
+		if ($primary_registration instanceof EE_Registration
987
+			&& EEH_MSG_Template::is_mt_active('invoice')
988
+		) {
989
+			$actions['invoice'] = EEH_Template::get_button_or_link(
990
+				$primary_registration->invoice_url(),
991
+				esc_html__('View Invoice', 'event_espresso'),
992
+				'button secondary-button',
993
+				'dashicons dashicons-media-spreadsheet'
994
+			);
995
+		}
996
+		$actions = array_filter(
997
+			apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
998
+		);
999
+		if ($actions) {
1000
+			$content = '<ul>';
1001
+			$content .= '<li>' . implode('</li><li>', $actions) . '</li>';
1002
+			$content .= '</uL>';
1003
+		}
1004
+		return $content;
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 * txn_details_meta_box
1010
+	 * generates HTML for the Transaction main meta box
1011
+	 *
1012
+	 * @return void
1013
+	 * @throws DomainException
1014
+	 * @throws EE_Error
1015
+	 * @throws InvalidArgumentException
1016
+	 * @throws InvalidDataTypeException
1017
+	 * @throws InvalidInterfaceException
1018
+	 * @throws RuntimeException
1019
+	 * @throws ReflectionException
1020
+	 */
1021
+	public function txn_details_meta_box()
1022
+	{
1023
+		$this->_set_transaction_object();
1024
+		$this->_template_args['TXN_ID'] = $this->_transaction->ID();
1025
+		$this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
1026
+			? $this->_transaction->primary_registration()->attendee()
1027
+			: null;
1028
+		$this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
1029
+			'ee_edit_payments',
1030
+			'apply_payment_or_refund_from_registration_details'
1031
+		);
1032
+		$this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1033
+			'ee_delete_payments',
1034
+			'delete_payment_from_registration_details'
1035
+		);
1036
+
1037
+		// get line table
1038
+		EEH_Autoloader::register_line_item_display_autoloaders();
1039
+		$Line_Item_Display = new EE_Line_Item_Display(
1040
+			'admin_table',
1041
+			'EE_Admin_Table_Line_Item_Display_Strategy'
1042
+		);
1043
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1044
+			$this->_transaction->total_line_item()
1045
+		);
1046
+		$this->_template_args['REG_code'] = $this->_transaction->primary_registration() instanceof EE_Registration
1047
+			? $this->_transaction->primary_registration()->reg_code()
1048
+			: null;
1049
+		// process taxes
1050
+		$taxes = $this->_transaction->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
1051
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1052
+
1053
+		$this->_template_args['grand_total'] = EEH_Template::format_currency(
1054
+			$this->_transaction->total(),
1055
+			false,
1056
+			false
1057
+		);
1058
+		$this->_template_args['grand_raw_total'] = $this->_transaction->total();
1059
+		$this->_template_args['TXN_status'] = $this->_transaction->status_ID();
1060
+
1061
+		// process payment details
1062
+		$payments = $this->_transaction->payments();
1063
+		if (! empty($payments)) {
1064
+			$this->_template_args['payments'] = $payments;
1065
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1066
+		} else {
1067
+			$this->_template_args['payments'] = false;
1068
+			$this->_template_args['existing_reg_payments'] = array();
1069
+		}
1070
+
1071
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1072
+		$this->_template_args['delete_payment_url'] = add_query_arg(
1073
+			array('action' => 'espresso_delete_payment'),
1074
+			TXN_ADMIN_URL
1075
+		);
1076
+
1077
+		if (isset($txn_details['invoice_number'])) {
1078
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1079
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1080
+				'Invoice Number',
1081
+				'event_espresso'
1082
+			);
1083
+		}
1084
+
1085
+		$this->_template_args['txn_details']['registration_session']['value']
1086
+			= $this->_transaction->primary_registration() instanceof EE_Registration
1087
+			? $this->_transaction->primary_registration()->session_ID()
1088
+			: null;
1089
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1090
+			'Registration Session',
1091
+			'event_espresso'
1092
+		);
1093
+
1094
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1095
+			? $this->_session['ip_address']
1096
+			: '';
1097
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1098
+			'Transaction placed from IP',
1099
+			'event_espresso'
1100
+		);
1101
+
1102
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1103
+			? $this->_session['user_agent']
1104
+			: '';
1105
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1106
+			'Registrant User Agent',
1107
+			'event_espresso'
1108
+		);
1109
+
1110
+		$reg_steps = '<ul>';
1111
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1112
+			if ($reg_step_status === true) {
1113
+				$reg_steps .= '<li style="color:#70cc50">'
1114
+							  . sprintf(
1115
+								  esc_html__('%1$s : Completed', 'event_espresso'),
1116
+								  ucwords(str_replace('_', ' ', $reg_step))
1117
+							  )
1118
+							  . '</li>';
1119
+			} elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1120
+				$reg_steps .= '<li style="color:#2EA2CC">'
1121
+							  . sprintf(
1122
+								  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1123
+								  ucwords(str_replace('_', ' ', $reg_step)),
1124
+								  date(
1125
+									  get_option('date_format') . ' ' . get_option('time_format'),
1126
+									  $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1127
+								  )
1128
+							  )
1129
+							  . '</li>';
1130
+			} else {
1131
+				$reg_steps .= '<li style="color:#E76700">'
1132
+							  . sprintf(
1133
+								  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1134
+								  ucwords(str_replace('_', ' ', $reg_step))
1135
+							  )
1136
+							  . '</li>';
1137
+			}
1138
+		}
1139
+		$reg_steps .= '</ul>';
1140
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1141
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1142
+			'Registration Step Progress',
1143
+			'event_espresso'
1144
+		);
1145
+
1146
+
1147
+		$this->_get_registrations_to_apply_payment_to();
1148
+		$this->_get_payment_methods($payments);
1149
+		$this->_get_payment_status_array();
1150
+		$this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1151
+
1152
+		$this->_template_args['transaction_form_url'] = add_query_arg(
1153
+			array(
1154
+				'action'  => 'edit_transaction',
1155
+				'process' => 'transaction',
1156
+			),
1157
+			TXN_ADMIN_URL
1158
+		);
1159
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(
1160
+			array(
1161
+				'page'   => 'espresso_transactions',
1162
+				'action' => 'espresso_apply_payment',
1163
+			),
1164
+			WP_AJAX_URL
1165
+		);
1166
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(
1167
+			array(
1168
+				'page'   => 'espresso_transactions',
1169
+				'action' => 'espresso_delete_payment',
1170
+			),
1171
+			WP_AJAX_URL
1172
+		);
1173
+
1174
+		$this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1175
+
1176
+		// 'espresso_delete_payment_nonce'
1177
+
1178
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1179
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1180
+	}
1181
+
1182
+
1183
+	/**
1184
+	 * _get_registration_payment_IDs
1185
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
1186
+	 *
1187
+	 * @access protected
1188
+	 * @param EE_Payment[] $payments
1189
+	 * @return array
1190
+	 * @throws EE_Error
1191
+	 * @throws InvalidArgumentException
1192
+	 * @throws InvalidDataTypeException
1193
+	 * @throws InvalidInterfaceException
1194
+	 * @throws ReflectionException
1195
+	 */
1196
+	protected function _get_registration_payment_IDs($payments = array())
1197
+	{
1198
+		$existing_reg_payments = array();
1199
+		// get all reg payments for these payments
1200
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(
1201
+			array(
1202
+				array(
1203
+					'PAY_ID' => array(
1204
+						'IN',
1205
+						array_keys($payments),
1206
+					),
1207
+				),
1208
+			)
1209
+		);
1210
+		if (! empty($reg_payments)) {
1211
+			foreach ($payments as $payment) {
1212
+				if (! $payment instanceof EE_Payment) {
1213
+					continue;
1214
+				} elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1215
+					$existing_reg_payments[ $payment->ID() ] = array();
1216
+				}
1217
+				foreach ($reg_payments as $reg_payment) {
1218
+					if ($reg_payment instanceof EE_Registration_Payment
1219
+						&& $reg_payment->payment_ID() === $payment->ID()
1220
+					) {
1221
+						$existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1222
+					}
1223
+				}
1224
+			}
1225
+		}
1226
+
1227
+		return $existing_reg_payments;
1228
+	}
1229
+
1230
+
1231
+	/**
1232
+	 * _get_registrations_to_apply_payment_to
1233
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1234
+	 * which allows the admin to only apply the payment to the specific registrations
1235
+	 *
1236
+	 * @access protected
1237
+	 * @return void
1238
+	 * @throws EE_Error
1239
+	 * @throws InvalidArgumentException
1240
+	 * @throws InvalidDataTypeException
1241
+	 * @throws InvalidInterfaceException
1242
+	 * @throws ReflectionException
1243
+	 */
1244
+	protected function _get_registrations_to_apply_payment_to()
1245
+	{
1246
+		// we want any registration with an active status (ie: not deleted or cancelled)
1247
+		$query_params = array(
1248
+			array(
1249
+				'STS_ID' => array(
1250
+					'IN',
1251
+					array(
1252
+						EEM_Registration::status_id_approved,
1253
+						EEM_Registration::status_id_pending_payment,
1254
+						EEM_Registration::status_id_not_approved,
1255
+					),
1256
+				),
1257
+			),
1258
+		);
1259
+		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1260
+			'',
1261
+			'txn-admin-apply-payment-to-registrations-dv',
1262
+			'',
1263
+			'clear: both; margin: 1.5em 0 0; display: none;'
1264
+		);
1265
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1266
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1267
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
1268
+			EEH_HTML::tr(
1269
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1270
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1271
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1272
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1273
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1274
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1275
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1276
+			)
1277
+		);
1278
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
1279
+		// get registrations for TXN
1280
+		$registrations = $this->_transaction->registrations($query_params);
1281
+		$existing_reg_payments = $this->_template_args['existing_reg_payments'];
1282
+		foreach ($registrations as $registration) {
1283
+			if ($registration instanceof EE_Registration) {
1284
+				$attendee_name = $registration->attendee() instanceof EE_Attendee
1285
+					? $registration->attendee()->full_name()
1286
+					: esc_html__('Unknown Attendee', 'event_espresso');
1287
+				$owing = $registration->final_price() - $registration->paid();
1288
+				$taxable = $registration->ticket()->taxable()
1289
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1290
+					: '';
1291
+				$checked = empty($existing_reg_payments)
1292
+						   || in_array($registration->ID(), $existing_reg_payments, true)
1293
+					? ' checked="checked"'
1294
+					: '';
1295
+				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
1296
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
1297
+					EEH_HTML::td($registration->ID()) .
1298
+					EEH_HTML::td($attendee_name) .
1299
+					EEH_HTML::td(
1300
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1301
+					) .
1302
+					EEH_HTML::td($registration->event_name()) .
1303
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1304
+					EEH_HTML::td(
1305
+						EEH_Template::format_currency($owing),
1306
+						'',
1307
+						'txn-admin-payment-owing-td jst-cntr'
1308
+					) .
1309
+					EEH_HTML::td(
1310
+						'<input type="checkbox" value="' . $registration->ID()
1311
+						. '" name="txn_admin_payment[registrations]"'
1312
+						. $checked . $disabled . '>',
1313
+						'',
1314
+						'jst-cntr'
1315
+					),
1316
+					'apply-payment-registration-row-' . $registration->ID()
1317
+				);
1318
+			}
1319
+		}
1320
+		$registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1321
+		$registrations_to_apply_payment_to .= EEH_HTML::tablex();
1322
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1323
+		$registrations_to_apply_payment_to .= EEH_HTML::p(
1324
+			esc_html__(
1325
+				'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1326
+				'event_espresso'
1327
+			),
1328
+			'',
1329
+			'clear description'
1330
+		);
1331
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1332
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1333
+	}
1334
+
1335
+
1336
+	/**
1337
+	 * _get_reg_status_selection
1338
+	 *
1339
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1340
+	 *         instead of events.
1341
+	 * @access protected
1342
+	 * @return void
1343
+	 * @throws EE_Error
1344
+	 */
1345
+	protected function _get_reg_status_selection()
1346
+	{
1347
+		// first get all possible statuses
1348
+		$statuses = EEM_Registration::reg_status_array(array(), true);
1349
+		// let's add a "don't change" option.
1350
+		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1351
+		$status_array = array_merge($status_array, $statuses);
1352
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1353
+			'txn_reg_status_change[reg_status]',
1354
+			$status_array,
1355
+			'NAN',
1356
+			'id="txn-admin-payment-reg-status-inp"',
1357
+			'txn-reg-status-change-reg-status'
1358
+		);
1359
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1360
+			'delete_txn_reg_status_change[reg_status]',
1361
+			$status_array,
1362
+			'NAN',
1363
+			'delete-txn-admin-payment-reg-status-inp',
1364
+			'delete-txn-reg-status-change-reg-status'
1365
+		);
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 *    _get_payment_methods
1371
+	 * Gets all the payment methods available generally, or the ones that are already
1372
+	 * selected on these payments (in case their payment methods are no longer active).
1373
+	 * Has the side-effect of updating the template args' payment_methods item
1374
+	 *
1375
+	 * @access private
1376
+	 * @param EE_Payment[] to show on this page
1377
+	 * @return void
1378
+	 * @throws EE_Error
1379
+	 * @throws InvalidArgumentException
1380
+	 * @throws InvalidDataTypeException
1381
+	 * @throws InvalidInterfaceException
1382
+	 * @throws ReflectionException
1383
+	 */
1384
+	private function _get_payment_methods($payments = array())
1385
+	{
1386
+		$payment_methods_of_payments = array();
1387
+		foreach ($payments as $payment) {
1388
+			if ($payment instanceof EE_Payment) {
1389
+				$payment_methods_of_payments[] = $payment->ID();
1390
+			}
1391
+		}
1392
+		if ($payment_methods_of_payments) {
1393
+			$query_args = array(
1394
+				array(
1395
+					'OR*payment_method_for_payment' => array(
1396
+						'PMD_ID'    => array('IN', $payment_methods_of_payments),
1397
+						'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1398
+					),
1399
+				),
1400
+			);
1401
+		} else {
1402
+			$query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1403
+		}
1404
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1405
+	}
1406
+
1407
+
1408
+	/**
1409
+	 * txn_attendees_meta_box
1410
+	 *    generates HTML for the Attendees Transaction main meta box
1411
+	 *
1412
+	 * @access public
1413
+	 * @param WP_Post $post
1414
+	 * @param array   $metabox
1415
+	 * @return void
1416
+	 * @throws DomainException
1417
+	 * @throws EE_Error
1418
+	 * @throws InvalidArgumentException
1419
+	 * @throws InvalidDataTypeException
1420
+	 * @throws InvalidInterfaceException
1421
+	 * @throws ReflectionException
1422
+	 */
1423
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1424
+	{
1425
+
1426
+		/** @noinspection NonSecureExtractUsageInspection */
1427
+		extract($metabox['args']);
1428
+		$this->_template_args['post'] = $post;
1429
+		$this->_template_args['event_attendees'] = array();
1430
+		// process items in cart
1431
+		$line_items = $this->_transaction->get_many_related(
1432
+			'Line_Item',
1433
+			array(array('LIN_type' => 'line-item'))
1434
+		);
1435
+		if (! empty($line_items)) {
1436
+			foreach ($line_items as $item) {
1437
+				if ($item instanceof EE_Line_Item) {
1438
+					switch ($item->OBJ_type()) {
1439
+						case 'Event':
1440
+							break;
1441
+						case 'Ticket':
1442
+							$ticket = $item->ticket();
1443
+							// right now we're only handling tickets here.
1444
+							// Cause its expected that only tickets will have attendees right?
1445
+							if (! $ticket instanceof EE_Ticket) {
1446
+								break;
1447
+							}
1448
+							try {
1449
+								$event_name = $ticket->get_event_name();
1450
+							} catch (Exception $e) {
1451
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1452
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1453
+							}
1454
+							$event_name .= ' - ' . $item->name();
1455
+							$ticket_price = EEH_Template::format_currency($item->unit_price());
1456
+							// now get all of the registrations for this transaction that use this ticket
1457
+							$registrations = $ticket->registrations(
1458
+								array(array('TXN_ID' => $this->_transaction->ID()))
1459
+							);
1460
+							foreach ($registrations as $registration) {
1461
+								if (! $registration instanceof EE_Registration) {
1462
+									break;
1463
+								}
1464
+								$this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1465
+									= $registration->status_ID();
1466
+								$this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1467
+									= $registration->count();
1468
+								$this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1469
+									= $event_name;
1470
+								$this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1471
+									= $ticket_price;
1472
+								// attendee info
1473
+								$attendee = $registration->get_first_related('Attendee');
1474
+								if ($attendee instanceof EE_Attendee) {
1475
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1476
+										= $attendee->ID();
1477
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1478
+										= $attendee->full_name();
1479
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']
1480
+										= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1481
+										  . esc_html__(
1482
+											  ' Event',
1483
+											  'event_espresso'
1484
+										  )
1485
+										  . '">' . $attendee->email() . '</a>';
1486
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']
1487
+										= EEH_Address::format($attendee, 'inline', false, false);
1488
+								} else {
1489
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1490
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1491
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1492
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1493
+								}
1494
+							}
1495
+							break;
1496
+					}
1497
+				}
1498
+			}
1499
+
1500
+			$this->_template_args['transaction_form_url'] = add_query_arg(
1501
+				array(
1502
+					'action'  => 'edit_transaction',
1503
+					'process' => 'attendees',
1504
+				),
1505
+				TXN_ADMIN_URL
1506
+			);
1507
+			echo EEH_Template::display_template(
1508
+				TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1509
+				$this->_template_args,
1510
+				true
1511
+			);
1512
+		} else {
1513
+			echo sprintf(
1514
+				esc_html__(
1515
+					'%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1516
+					'event_espresso'
1517
+				),
1518
+				'<p class="important-notice">',
1519
+				'</p>'
1520
+			);
1521
+		}
1522
+	}
1523
+
1524
+
1525
+	/**
1526
+	 * txn_registrant_side_meta_box
1527
+	 * generates HTML for the Edit Transaction side meta box
1528
+	 *
1529
+	 * @access public
1530
+	 * @return void
1531
+	 * @throws DomainException
1532
+	 * @throws EE_Error
1533
+	 * @throws InvalidArgumentException
1534
+	 * @throws InvalidDataTypeException
1535
+	 * @throws InvalidInterfaceException
1536
+	 * @throws ReflectionException
1537
+	 */
1538
+	public function txn_registrant_side_meta_box()
1539
+	{
1540
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1541
+			? $this->_transaction->primary_registration()->get_first_related('Attendee')
1542
+			: null;
1543
+		if (! $primary_att instanceof EE_Attendee) {
1544
+			$this->_template_args['no_attendee_message'] = esc_html__(
1545
+				'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1546
+				'event_espresso'
1547
+			);
1548
+			$primary_att = EEM_Attendee::instance()->create_default_object();
1549
+		}
1550
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1551
+		$this->_template_args['prime_reg_fname'] = $primary_att->fname();
1552
+		$this->_template_args['prime_reg_lname'] = $primary_att->lname();
1553
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1554
+		$this->_template_args['prime_reg_phone'] = $primary_att->phone();
1555
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1556
+			array(
1557
+				'action' => 'edit_attendee',
1558
+				'post'   => $primary_att->ID(),
1559
+			),
1560
+			REG_ADMIN_URL
1561
+		);
1562
+		// get formatted address for registrant
1563
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1564
+		echo EEH_Template::display_template(
1565
+			TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1566
+			$this->_template_args,
1567
+			true
1568
+		);
1569
+	}
1570
+
1571
+
1572
+	/**
1573
+	 * txn_billing_info_side_meta_box
1574
+	 *    generates HTML for the Edit Transaction side meta box
1575
+	 *
1576
+	 * @access public
1577
+	 * @return void
1578
+	 * @throws DomainException
1579
+	 * @throws EE_Error
1580
+	 */
1581
+	public function txn_billing_info_side_meta_box()
1582
+	{
1583
+
1584
+		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1585
+		$this->_template_args['billing_form_url'] = add_query_arg(
1586
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1587
+			TXN_ADMIN_URL
1588
+		);
1589
+
1590
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1591
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1592
+	}
1593
+
1594
+
1595
+	/**
1596
+	 * apply_payments_or_refunds
1597
+	 *    registers a payment or refund made towards a transaction
1598
+	 *
1599
+	 * @access public
1600
+	 * @return void
1601
+	 * @throws EE_Error
1602
+	 * @throws InvalidArgumentException
1603
+	 * @throws ReflectionException
1604
+	 * @throws RuntimeException
1605
+	 * @throws InvalidDataTypeException
1606
+	 * @throws InvalidInterfaceException
1607
+	 */
1608
+	public function apply_payments_or_refunds()
1609
+	{
1610
+		$json_response_data = array('return_data' => false);
1611
+		$valid_data = $this->_validate_payment_request_data();
1612
+		$has_access = EE_Registry::instance()->CAP->current_user_can(
1613
+			'ee_edit_payments',
1614
+			'apply_payment_or_refund_from_registration_details'
1615
+		);
1616
+		if (! empty($valid_data) && $has_access) {
1617
+			$PAY_ID = $valid_data['PAY_ID'];
1618
+			// save  the new payment
1619
+			$payment = $this->_create_payment_from_request_data($valid_data);
1620
+			// get the TXN for this payment
1621
+			$transaction = $payment->transaction();
1622
+			// verify transaction
1623
+			if ($transaction instanceof EE_Transaction) {
1624
+				// calculate_total_payments_and_update_status
1625
+				$this->_process_transaction_payments($transaction);
1626
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1627
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1628
+				// apply payment to registrations (if applicable)
1629
+				if (! empty($REG_IDs)) {
1630
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1631
+					$this->_maybe_send_notifications();
1632
+					// now process status changes for the same registrations
1633
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1634
+				}
1635
+				$this->_maybe_send_notifications($payment);
1636
+				// prepare to render page
1637
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1638
+				do_action(
1639
+					'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1640
+					$transaction,
1641
+					$payment
1642
+				);
1643
+			} else {
1644
+				EE_Error::add_error(
1645
+					esc_html__(
1646
+						'A valid Transaction for this payment could not be retrieved.',
1647
+						'event_espresso'
1648
+					),
1649
+					__FILE__,
1650
+					__FUNCTION__,
1651
+					__LINE__
1652
+				);
1653
+			}
1654
+		} elseif ($has_access) {
1655
+			EE_Error::add_error(
1656
+				esc_html__(
1657
+					'The payment form data could not be processed. Please try again.',
1658
+					'event_espresso'
1659
+				),
1660
+				__FILE__,
1661
+				__FUNCTION__,
1662
+				__LINE__
1663
+			);
1664
+		} else {
1665
+			EE_Error::add_error(
1666
+				esc_html__(
1667
+					'You do not have access to apply payments or refunds to a registration.',
1668
+					'event_espresso'
1669
+				),
1670
+				__FILE__,
1671
+				__FUNCTION__,
1672
+				__LINE__
1673
+			);
1674
+		}
1675
+		$notices = EE_Error::get_notices(
1676
+			false,
1677
+			false,
1678
+			false
1679
+		);
1680
+		$this->_template_args = array(
1681
+			'data'    => $json_response_data,
1682
+			'error'   => $notices['errors'],
1683
+			'success' => $notices['success'],
1684
+		);
1685
+		$this->_return_json();
1686
+	}
1687
+
1688
+
1689
+	/**
1690
+	 * _validate_payment_request_data
1691
+	 *
1692
+	 * @return array
1693
+	 * @throws EE_Error
1694
+	 * @throws InvalidArgumentException
1695
+	 * @throws InvalidDataTypeException
1696
+	 * @throws InvalidInterfaceException
1697
+	 */
1698
+	protected function _validate_payment_request_data()
1699
+	{
1700
+		if (! isset($this->_req_data['txn_admin_payment'])) {
1701
+			return array();
1702
+		}
1703
+		$payment_form = $this->_generate_payment_form_section();
1704
+		try {
1705
+			if ($payment_form->was_submitted()) {
1706
+				$payment_form->receive_form_submission();
1707
+				if (! $payment_form->is_valid()) {
1708
+					$submission_error_messages = array();
1709
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1710
+						if ($validation_error instanceof EE_Validation_Error) {
1711
+							$submission_error_messages[] = sprintf(
1712
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1713
+								$validation_error->get_form_section()->html_label_text(),
1714
+								$validation_error->getMessage()
1715
+							);
1716
+						}
1717
+					}
1718
+					EE_Error::add_error(
1719
+						implode('<br />', $submission_error_messages),
1720
+						__FILE__,
1721
+						__FUNCTION__,
1722
+						__LINE__
1723
+					);
1724
+					return array();
1725
+				}
1726
+			}
1727
+		} catch (EE_Error $e) {
1728
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1729
+			return array();
1730
+		}
1731
+
1732
+		return $payment_form->valid_data();
1733
+	}
1734
+
1735
+
1736
+	/**
1737
+	 * _generate_payment_form_section
1738
+	 *
1739
+	 * @return EE_Form_Section_Proper
1740
+	 * @throws EE_Error
1741
+	 */
1742
+	protected function _generate_payment_form_section()
1743
+	{
1744
+		return new EE_Form_Section_Proper(
1745
+			array(
1746
+				'name'        => 'txn_admin_payment',
1747
+				'subsections' => array(
1748
+					'PAY_ID'          => new EE_Text_Input(
1749
+						array(
1750
+							'default'               => 0,
1751
+							'required'              => false,
1752
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1753
+							'validation_strategies' => array(new EE_Int_Normalization()),
1754
+						)
1755
+					),
1756
+					'TXN_ID'          => new EE_Text_Input(
1757
+						array(
1758
+							'default'               => 0,
1759
+							'required'              => true,
1760
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1761
+							'validation_strategies' => array(new EE_Int_Normalization()),
1762
+						)
1763
+					),
1764
+					'type'            => new EE_Text_Input(
1765
+						array(
1766
+							'default'               => 1,
1767
+							'required'              => true,
1768
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1769
+							'validation_strategies' => array(new EE_Int_Normalization()),
1770
+						)
1771
+					),
1772
+					'amount'          => new EE_Text_Input(
1773
+						array(
1774
+							'default'               => 0,
1775
+							'required'              => true,
1776
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1777
+							'validation_strategies' => array(new EE_Float_Normalization()),
1778
+						)
1779
+					),
1780
+					'status'          => new EE_Text_Input(
1781
+						array(
1782
+							'default'         => EEM_Payment::status_id_approved,
1783
+							'required'        => true,
1784
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1785
+						)
1786
+					),
1787
+					'PMD_ID'          => new EE_Text_Input(
1788
+						array(
1789
+							'default'               => 2,
1790
+							'required'              => true,
1791
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1792
+							'validation_strategies' => array(new EE_Int_Normalization()),
1793
+						)
1794
+					),
1795
+					'date'            => new EE_Text_Input(
1796
+						array(
1797
+							'default'         => time(),
1798
+							'required'        => true,
1799
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1800
+						)
1801
+					),
1802
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1803
+						array(
1804
+							'default'               => '',
1805
+							'required'              => false,
1806
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1807
+							'validation_strategies' => array(
1808
+								new EE_Max_Length_Validation_Strategy(
1809
+									esc_html__('Input too long', 'event_espresso'),
1810
+									100
1811
+								),
1812
+							),
1813
+						)
1814
+					),
1815
+					'po_number'       => new EE_Text_Input(
1816
+						array(
1817
+							'default'               => '',
1818
+							'required'              => false,
1819
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1820
+							'validation_strategies' => array(
1821
+								new EE_Max_Length_Validation_Strategy(
1822
+									esc_html__('Input too long', 'event_espresso'),
1823
+									100
1824
+								),
1825
+							),
1826
+						)
1827
+					),
1828
+					'accounting'      => new EE_Text_Input(
1829
+						array(
1830
+							'default'               => '',
1831
+							'required'              => false,
1832
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1833
+							'validation_strategies' => array(
1834
+								new EE_Max_Length_Validation_Strategy(
1835
+									esc_html__('Input too long', 'event_espresso'),
1836
+									100
1837
+								),
1838
+							),
1839
+						)
1840
+					),
1841
+				),
1842
+			)
1843
+		);
1844
+	}
1845
+
1846
+
1847
+	/**
1848
+	 * _create_payment_from_request_data
1849
+	 *
1850
+	 * @param array $valid_data
1851
+	 * @return EE_Payment
1852
+	 * @throws EE_Error
1853
+	 * @throws InvalidArgumentException
1854
+	 * @throws InvalidDataTypeException
1855
+	 * @throws InvalidInterfaceException
1856
+	 * @throws ReflectionException
1857
+	 */
1858
+	protected function _create_payment_from_request_data($valid_data)
1859
+	{
1860
+		$PAY_ID = $valid_data['PAY_ID'];
1861
+		// get payment amount
1862
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1863
+		// payments have a type value of 1 and refunds have a type value of -1
1864
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1865
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1866
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1867
+		$date = $valid_data['date']
1868
+			? preg_replace('/\s+/', ' ', $valid_data['date'])
1869
+			: date('Y-m-d g:i a', current_time('timestamp'));
1870
+		$payment = EE_Payment::new_instance(
1871
+			array(
1872
+				'TXN_ID'              => $valid_data['TXN_ID'],
1873
+				'STS_ID'              => $valid_data['status'],
1874
+				'PAY_timestamp'       => $date,
1875
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1876
+				'PMD_ID'              => $valid_data['PMD_ID'],
1877
+				'PAY_amount'          => $amount,
1878
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1879
+				'PAY_po_number'       => $valid_data['po_number'],
1880
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1881
+				'PAY_details'         => $valid_data,
1882
+				'PAY_ID'              => $PAY_ID,
1883
+			),
1884
+			'',
1885
+			array('Y-m-d', 'g:i a')
1886
+		);
1887
+
1888
+		if (! $payment->save()) {
1889
+			EE_Error::add_error(
1890
+				sprintf(
1891
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1892
+					$payment->ID()
1893
+				),
1894
+				__FILE__,
1895
+				__FUNCTION__,
1896
+				__LINE__
1897
+			);
1898
+		}
1899
+
1900
+		return $payment;
1901
+	}
1902
+
1903
+
1904
+	/**
1905
+	 * _process_transaction_payments
1906
+	 *
1907
+	 * @param \EE_Transaction $transaction
1908
+	 * @return void
1909
+	 * @throws EE_Error
1910
+	 * @throws InvalidArgumentException
1911
+	 * @throws ReflectionException
1912
+	 * @throws InvalidDataTypeException
1913
+	 * @throws InvalidInterfaceException
1914
+	 */
1915
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1916
+	{
1917
+		/** @type EE_Transaction_Payments $transaction_payments */
1918
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1919
+		// update the transaction with this payment
1920
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1921
+			EE_Error::add_success(
1922
+				esc_html__(
1923
+					'The payment has been processed successfully.',
1924
+					'event_espresso'
1925
+				),
1926
+				__FILE__,
1927
+				__FUNCTION__,
1928
+				__LINE__
1929
+			);
1930
+		} else {
1931
+			EE_Error::add_error(
1932
+				esc_html__(
1933
+					'The payment was processed successfully but the amount paid for the transaction was not updated.',
1934
+					'event_espresso'
1935
+				),
1936
+				__FILE__,
1937
+				__FUNCTION__,
1938
+				__LINE__
1939
+			);
1940
+		}
1941
+	}
1942
+
1943
+
1944
+	/**
1945
+	 * _get_REG_IDs_to_apply_payment_to
1946
+	 * returns a list of registration IDs that the payment will apply to
1947
+	 *
1948
+	 * @param \EE_Payment $payment
1949
+	 * @return array
1950
+	 * @throws EE_Error
1951
+	 * @throws InvalidArgumentException
1952
+	 * @throws InvalidDataTypeException
1953
+	 * @throws InvalidInterfaceException
1954
+	 * @throws ReflectionException
1955
+	 */
1956
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1957
+	{
1958
+		$REG_IDs = array();
1959
+		// grab array of IDs for specific registrations to apply changes to
1960
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1961
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1962
+		}
1963
+		// nothing specified ? then get all reg IDs
1964
+		if (empty($REG_IDs)) {
1965
+			$registrations = $payment->transaction()->registrations();
1966
+			$REG_IDs = ! empty($registrations)
1967
+				? array_keys($registrations)
1968
+				: $this->_get_existing_reg_payment_REG_IDs($payment);
1969
+		}
1970
+
1971
+		// ensure that REG_IDs are integers and NOT strings
1972
+		return array_map('intval', $REG_IDs);
1973
+	}
1974
+
1975
+
1976
+	/**
1977
+	 * @return array
1978
+	 */
1979
+	public function existing_reg_payment_REG_IDs()
1980
+	{
1981
+		return $this->_existing_reg_payment_REG_IDs;
1982
+	}
1983
+
1984
+
1985
+	/**
1986
+	 * @param array $existing_reg_payment_REG_IDs
1987
+	 */
1988
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1989
+	{
1990
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1991
+	}
1992
+
1993
+
1994
+	/**
1995
+	 * _get_existing_reg_payment_REG_IDs
1996
+	 * returns a list of registration IDs that the payment is currently related to
1997
+	 * as recorded in the database
1998
+	 *
1999
+	 * @param \EE_Payment $payment
2000
+	 * @return array
2001
+	 * @throws EE_Error
2002
+	 * @throws InvalidArgumentException
2003
+	 * @throws InvalidDataTypeException
2004
+	 * @throws InvalidInterfaceException
2005
+	 * @throws ReflectionException
2006
+	 */
2007
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
2008
+	{
2009
+		if ($this->existing_reg_payment_REG_IDs() === null) {
2010
+			// let's get any existing reg payment records for this payment
2011
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2012
+			// but we only want the REG IDs, so grab the array keys
2013
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2014
+				? array_keys($existing_reg_payment_REG_IDs)
2015
+				: array();
2016
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2017
+		}
2018
+
2019
+		return $this->existing_reg_payment_REG_IDs();
2020
+	}
2021
+
2022
+
2023
+	/**
2024
+	 * _remove_existing_registration_payments
2025
+	 * this calculates the difference between existing relations
2026
+	 * to the supplied payment and the new list registration IDs,
2027
+	 * removes any related registrations that no longer apply,
2028
+	 * and then updates the registration paid fields
2029
+	 *
2030
+	 * @param \EE_Payment $payment
2031
+	 * @param int         $PAY_ID
2032
+	 * @return bool;
2033
+	 * @throws EE_Error
2034
+	 * @throws InvalidArgumentException
2035
+	 * @throws ReflectionException
2036
+	 * @throws InvalidDataTypeException
2037
+	 * @throws InvalidInterfaceException
2038
+	 */
2039
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2040
+	{
2041
+		// newly created payments will have nothing recorded for $PAY_ID
2042
+		if (absint($PAY_ID) === 0) {
2043
+			return false;
2044
+		}
2045
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2046
+		if (empty($existing_reg_payment_REG_IDs)) {
2047
+			return false;
2048
+		}
2049
+		/** @type EE_Transaction_Payments $transaction_payments */
2050
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2051
+
2052
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
2053
+			$payment,
2054
+			array(
2055
+				array(
2056
+					'PAY_ID' => $payment->ID(),
2057
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
2058
+				),
2059
+			)
2060
+		);
2061
+	}
2062
+
2063
+
2064
+	/**
2065
+	 * _update_registration_payments
2066
+	 * this applies the payments to the selected registrations
2067
+	 * but only if they have not already been paid for
2068
+	 *
2069
+	 * @param  EE_Transaction $transaction
2070
+	 * @param \EE_Payment     $payment
2071
+	 * @param array           $REG_IDs
2072
+	 * @return void
2073
+	 * @throws EE_Error
2074
+	 * @throws InvalidArgumentException
2075
+	 * @throws ReflectionException
2076
+	 * @throws RuntimeException
2077
+	 * @throws InvalidDataTypeException
2078
+	 * @throws InvalidInterfaceException
2079
+	 */
2080
+	protected function _update_registration_payments(
2081
+		EE_Transaction $transaction,
2082
+		EE_Payment $payment,
2083
+		$REG_IDs = array()
2084
+	) {
2085
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2086
+		// so let's do that using our set of REG_IDs from the form
2087
+		$registration_query_where_params = array(
2088
+			'REG_ID' => array('IN', $REG_IDs),
2089
+		);
2090
+		// but add in some conditions regarding payment,
2091
+		// so that we don't apply payments to registrations that are free or have already been paid for
2092
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2093
+		if (! $payment->is_a_refund()) {
2094
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
2095
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2096
+		}
2097
+		$registrations = $transaction->registrations(array($registration_query_where_params));
2098
+		if (! empty($registrations)) {
2099
+			/** @type EE_Payment_Processor $payment_processor */
2100
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2101
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
2102
+		}
2103
+	}
2104
+
2105
+
2106
+	/**
2107
+	 * _process_registration_status_change
2108
+	 * This processes requested registration status changes for all the registrations
2109
+	 * on a given transaction and (optionally) sends out notifications for the changes.
2110
+	 *
2111
+	 * @param  EE_Transaction $transaction
2112
+	 * @param array           $REG_IDs
2113
+	 * @return bool
2114
+	 * @throws EE_Error
2115
+	 * @throws InvalidArgumentException
2116
+	 * @throws ReflectionException
2117
+	 * @throws InvalidDataTypeException
2118
+	 * @throws InvalidInterfaceException
2119
+	 */
2120
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2121
+	{
2122
+		// first if there is no change in status then we get out.
2123
+		if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2124
+			|| $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2125
+		) {
2126
+			// no error message, no change requested, just nothing to do man.
2127
+			return false;
2128
+		}
2129
+		/** @type EE_Transaction_Processor $transaction_processor */
2130
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2131
+
2132
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2133
+		return $transaction_processor->manually_update_registration_statuses(
2134
+			$transaction,
2135
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2136
+			array(array('REG_ID' => array('IN', $REG_IDs)))
2137
+		);
2138
+	}
2139
+
2140
+
2141
+	/**
2142
+	 * _build_payment_json_response
2143
+	 *
2144
+	 * @access public
2145
+	 * @param \EE_Payment $payment
2146
+	 * @param array       $REG_IDs
2147
+	 * @param bool | null $delete_txn_reg_status_change
2148
+	 * @return array
2149
+	 * @throws EE_Error
2150
+	 * @throws InvalidArgumentException
2151
+	 * @throws InvalidDataTypeException
2152
+	 * @throws InvalidInterfaceException
2153
+	 * @throws ReflectionException
2154
+	 */
2155
+	protected function _build_payment_json_response(
2156
+		EE_Payment $payment,
2157
+		$REG_IDs = array(),
2158
+		$delete_txn_reg_status_change = null
2159
+	) {
2160
+		// was the payment deleted ?
2161
+		if (is_bool($delete_txn_reg_status_change)) {
2162
+			return array(
2163
+				'PAY_ID'                       => $payment->ID(),
2164
+				'amount'                       => $payment->amount(),
2165
+				'total_paid'                   => $payment->transaction()->paid(),
2166
+				'txn_status'                   => $payment->transaction()->status_ID(),
2167
+				'pay_status'                   => $payment->STS_ID(),
2168
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2169
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2170
+			);
2171
+		} else {
2172
+			$this->_get_payment_status_array();
2173
+
2174
+			return array(
2175
+				'amount'           => $payment->amount(),
2176
+				'total_paid'       => $payment->transaction()->paid(),
2177
+				'txn_status'       => $payment->transaction()->status_ID(),
2178
+				'pay_status'       => $payment->STS_ID(),
2179
+				'PAY_ID'           => $payment->ID(),
2180
+				'STS_ID'           => $payment->STS_ID(),
2181
+				'status'           => self::$_pay_status[ $payment->STS_ID() ],
2182
+				'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2183
+				'method'           => strtoupper($payment->source()),
2184
+				'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2185
+				'gateway'          => $payment->payment_method()
2186
+					? $payment->payment_method()->admin_name()
2187
+					: esc_html__('Unknown', 'event_espresso'),
2188
+				'gateway_response' => $payment->gateway_response(),
2189
+				'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2190
+				'po_number'        => $payment->po_number(),
2191
+				'extra_accntng'    => $payment->extra_accntng(),
2192
+				'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2193
+			);
2194
+		}
2195
+	}
2196
+
2197
+
2198
+	/**
2199
+	 * delete_payment
2200
+	 *    delete a payment or refund made towards a transaction
2201
+	 *
2202
+	 * @access public
2203
+	 * @return void
2204
+	 * @throws EE_Error
2205
+	 * @throws InvalidArgumentException
2206
+	 * @throws ReflectionException
2207
+	 * @throws InvalidDataTypeException
2208
+	 * @throws InvalidInterfaceException
2209
+	 */
2210
+	public function delete_payment()
2211
+	{
2212
+		$json_response_data = array('return_data' => false);
2213
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2214
+			? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2215
+			: 0;
2216
+		$can_delete = EE_Registry::instance()->CAP->current_user_can(
2217
+			'ee_delete_payments',
2218
+			'delete_payment_from_registration_details'
2219
+		);
2220
+		if ($PAY_ID && $can_delete) {
2221
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2222
+				? $this->_req_data['delete_txn_reg_status_change']
2223
+				: false;
2224
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2225
+			if ($payment instanceof EE_Payment) {
2226
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2227
+				/** @type EE_Transaction_Payments $transaction_payments */
2228
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2229
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2230
+					$json_response_data['return_data'] = $this->_build_payment_json_response(
2231
+						$payment,
2232
+						$REG_IDs,
2233
+						$delete_txn_reg_status_change
2234
+					);
2235
+					if ($delete_txn_reg_status_change) {
2236
+						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2237
+						// MAKE sure we also add the delete_txn_req_status_change to the
2238
+						// $_REQUEST global because that's how messages will be looking for it.
2239
+						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2240
+						$this->_maybe_send_notifications();
2241
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2242
+					}
2243
+				}
2244
+			} else {
2245
+				EE_Error::add_error(
2246
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2247
+					__FILE__,
2248
+					__FUNCTION__,
2249
+					__LINE__
2250
+				);
2251
+			}
2252
+		} elseif ($can_delete) {
2253
+			EE_Error::add_error(
2254
+				esc_html__(
2255
+					'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2256
+					'event_espresso'
2257
+				),
2258
+				__FILE__,
2259
+				__FUNCTION__,
2260
+				__LINE__
2261
+			);
2262
+		} else {
2263
+			EE_Error::add_error(
2264
+				esc_html__(
2265
+					'You do not have access to delete a payment.',
2266
+					'event_espresso'
2267
+				),
2268
+				__FILE__,
2269
+				__FUNCTION__,
2270
+				__LINE__
2271
+			);
2272
+		}
2273
+		$notices = EE_Error::get_notices(false, false, false);
2274
+		$this->_template_args = array(
2275
+			'data'      => $json_response_data,
2276
+			'success'   => $notices['success'],
2277
+			'error'     => $notices['errors'],
2278
+			'attention' => $notices['attention'],
2279
+		);
2280
+		$this->_return_json();
2281
+	}
2282
+
2283
+
2284
+	/**
2285
+	 * _registration_payment_data_array
2286
+	 * adds info for 'owing' and 'paid' for each registration to the json response
2287
+	 *
2288
+	 * @access protected
2289
+	 * @param array $REG_IDs
2290
+	 * @return array
2291
+	 * @throws EE_Error
2292
+	 * @throws InvalidArgumentException
2293
+	 * @throws InvalidDataTypeException
2294
+	 * @throws InvalidInterfaceException
2295
+	 * @throws ReflectionException
2296
+	 */
2297
+	protected function _registration_payment_data_array($REG_IDs)
2298
+	{
2299
+		$registration_payment_data = array();
2300
+		// if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2301
+		if (! empty($REG_IDs)) {
2302
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2303
+			foreach ($registrations as $registration) {
2304
+				if ($registration instanceof EE_Registration) {
2305
+					$registration_payment_data[ $registration->ID() ] = array(
2306
+						'paid'  => $registration->pretty_paid(),
2307
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2308
+					);
2309
+				}
2310
+			}
2311
+		}
2312
+
2313
+		return $registration_payment_data;
2314
+	}
2315
+
2316
+
2317
+	/**
2318
+	 * _maybe_send_notifications
2319
+	 * determines whether or not the admin has indicated that notifications should be sent.
2320
+	 * If so, will toggle a filter switch for delivering registration notices.
2321
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
2322
+	 *
2323
+	 * @access protected
2324
+	 * @param \EE_Payment | null $payment
2325
+	 */
2326
+	protected function _maybe_send_notifications($payment = null)
2327
+	{
2328
+		switch ($payment instanceof EE_Payment) {
2329
+			// payment notifications
2330
+			case true:
2331
+				if (isset($this->_req_data['txn_payments']['send_notifications'])
2332
+					&& filter_var(
2333
+						$this->_req_data['txn_payments']['send_notifications'],
2334
+						FILTER_VALIDATE_BOOLEAN
2335
+					)
2336
+				) {
2337
+					$this->_process_payment_notification($payment);
2338
+				}
2339
+				break;
2340
+			// registration notifications
2341
+			case false:
2342
+				if (isset($this->_req_data['txn_reg_status_change']['send_notifications'])
2343
+					&& filter_var(
2344
+						$this->_req_data['txn_reg_status_change']['send_notifications'],
2345
+						FILTER_VALIDATE_BOOLEAN
2346
+					)
2347
+				) {
2348
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2349
+				}
2350
+				break;
2351
+		}
2352
+	}
2353
+
2354
+
2355
+	/**
2356
+	 * _send_payment_reminder
2357
+	 *    generates HTML for the View Transaction Details Admin page
2358
+	 *
2359
+	 * @access protected
2360
+	 * @return void
2361
+	 * @throws EE_Error
2362
+	 * @throws InvalidArgumentException
2363
+	 * @throws InvalidDataTypeException
2364
+	 * @throws InvalidInterfaceException
2365
+	 */
2366
+	protected function _send_payment_reminder()
2367
+	{
2368
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2369
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2370
+		$query_args = isset($this->_req_data['redirect_to']) ? array(
2371
+			'action' => $this->_req_data['redirect_to'],
2372
+			'TXN_ID' => $this->_req_data['TXN_ID'],
2373
+		) : array();
2374
+		do_action(
2375
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2376
+			$transaction
2377
+		);
2378
+		$this->_redirect_after_action(
2379
+			false,
2380
+			esc_html__('payment reminder', 'event_espresso'),
2381
+			esc_html__('sent', 'event_espresso'),
2382
+			$query_args,
2383
+			true
2384
+		);
2385
+	}
2386
+
2387
+
2388
+	/**
2389
+	 *  get_transactions
2390
+	 *    get transactions for given parameters (used by list table)
2391
+	 *
2392
+	 * @param  int     $perpage how many transactions displayed per page
2393
+	 * @param  boolean $count   return the count or objects
2394
+	 * @param string   $view
2395
+	 * @return mixed int = count || array of transaction objects
2396
+	 * @throws EE_Error
2397
+	 * @throws InvalidArgumentException
2398
+	 * @throws InvalidDataTypeException
2399
+	 * @throws InvalidInterfaceException
2400
+	 */
2401
+	public function get_transactions($perpage, $count = false, $view = '')
2402
+	{
2403
+
2404
+		$TXN = EEM_Transaction::instance();
2405
+
2406
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
2407
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2408
+			: date(
2409
+				'm/d/Y',
2410
+				strtotime('-10 year')
2411
+			);
2412
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
2413
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2414
+			: date('m/d/Y');
2415
+
2416
+		// make sure our timestamps start and end right at the boundaries for each day
2417
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2418
+		$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2419
+
2420
+
2421
+		// convert to timestamps
2422
+		$start_date = strtotime($start_date);
2423
+		$end_date = strtotime($end_date);
2424
+
2425
+		// makes sure start date is the lowest value and vice versa
2426
+		$start_date = min($start_date, $end_date);
2427
+		$end_date = max($start_date, $end_date);
2428
+
2429
+		// convert to correct format for query
2430
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2431
+			'TXN_timestamp',
2432
+			date('Y-m-d H:i:s', $start_date),
2433
+			'Y-m-d H:i:s'
2434
+		);
2435
+		$end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2436
+			'TXN_timestamp',
2437
+			date('Y-m-d H:i:s', $end_date),
2438
+			'Y-m-d H:i:s'
2439
+		);
2440
+
2441
+
2442
+		// set orderby
2443
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2444
+
2445
+		switch ($this->_req_data['orderby']) {
2446
+			case 'TXN_ID':
2447
+				$orderby = 'TXN_ID';
2448
+				break;
2449
+			case 'ATT_fname':
2450
+				$orderby = 'Registration.Attendee.ATT_fname';
2451
+				break;
2452
+			case 'event_name':
2453
+				$orderby = 'Registration.Event.EVT_name';
2454
+				break;
2455
+			default: // 'TXN_timestamp'
2456
+				$orderby = 'TXN_timestamp';
2457
+		}
2458
+
2459
+		$sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2460
+		$current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2461
+		$per_page = ! empty($perpage) ? $perpage : 10;
2462
+		$per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2463
+
2464
+		$offset = ($current_page - 1) * $per_page;
2465
+		$limit = array($offset, $per_page);
2466
+
2467
+		$_where = array(
2468
+			'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2469
+			'Registration.REG_count' => 1,
2470
+		);
2471
+
2472
+		if (isset($this->_req_data['EVT_ID'])) {
2473
+			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2474
+		}
2475
+
2476
+		if (isset($this->_req_data['s'])) {
2477
+			$search_string = '%' . $this->_req_data['s'] . '%';
2478
+			$_where['OR'] = array(
2479
+				'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2480
+				'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2481
+				'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2482
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2483
+				'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2484
+				'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2485
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2486
+				'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2487
+				'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2488
+				'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2489
+				'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2490
+				'Registration.REG_final_price'        => array('LIKE', $search_string),
2491
+				'Registration.REG_code'               => array('LIKE', $search_string),
2492
+				'Registration.REG_count'              => array('LIKE', $search_string),
2493
+				'Registration.REG_group_size'         => array('LIKE', $search_string),
2494
+				'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2495
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2496
+				'Payment.PAY_source'                  => array('LIKE', $search_string),
2497
+				'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2498
+				'TXN_session_data'                    => array('LIKE', $search_string),
2499
+				'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2500
+			);
2501
+		}
2502
+
2503
+		// failed transactions
2504
+		$failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2505
+				  || ($count && $view === 'failed');
2506
+		$abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2507
+					 || ($count && $view === 'abandoned');
2508
+		$incomplete = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2509
+					  || ($count && $view === 'incomplete');
2510
+
2511
+		if ($failed) {
2512
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
2513
+		} elseif ($abandoned) {
2514
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2515
+		} elseif ($incomplete) {
2516
+			$_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2517
+		} else {
2518
+			$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2519
+			$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2520
+		}
2521
+
2522
+		$query_params = apply_filters(
2523
+			'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2524
+			array(
2525
+				$_where,
2526
+				'order_by'                 => array($orderby => $sort),
2527
+				'limit'                    => $limit,
2528
+				'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2529
+			),
2530
+			$this->_req_data,
2531
+			$view,
2532
+			$count
2533
+		);
2534
+
2535
+		$transactions = $count
2536
+			? $TXN->count(array($query_params[0]), 'TXN_ID', true)
2537
+			: $TXN->get_all($query_params);
2538
+
2539
+		return $transactions;
2540
+	}
2541
+
2542
+
2543
+	/**
2544
+	 * @since 4.9.79.p
2545
+	 * @throws EE_Error
2546
+	 * @throws InvalidArgumentException
2547
+	 * @throws InvalidDataTypeException
2548
+	 * @throws InvalidInterfaceException
2549
+	 * @throws ReflectionException
2550
+	 * @throws RuntimeException
2551
+	 */
2552
+	public function recalculateLineItems()
2553
+	{
2554
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2555
+		/** @var EE_Transaction $transaction */
2556
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2557
+		$total_line_item = $transaction->total_line_item(false);
2558
+		$success = false;
2559
+		if ($total_line_item instanceof EE_Line_Item) {
2560
+			EEH_Line_Item::resetIsTaxableForTickets($total_line_item);
2561
+			$success = EEH_Line_Item::apply_taxes($total_line_item, true);
2562
+		}
2563
+		$this->_redirect_after_action(
2564
+			(bool) $success,
2565
+			esc_html__('Transaction taxes and totals', 'event_espresso'),
2566
+			esc_html__('recalculated', 'event_espresso'),
2567
+			isset($this->_req_data['redirect_to'])
2568
+				? array(
2569
+				'action' => $this->_req_data['redirect_to'],
2570
+				'TXN_ID' => $this->_req_data['TXN_ID'],
2571
+			)
2572
+				: array(),
2573
+			true
2574
+		);
2575
+	}
2576 2576
 }
Please login to merge, or discard this patch.