Completed
Branch EDTR/routing (71e206)
by
unknown
58:16 queued 49:45
created
modules/core_rest_api/EED_Core_Rest_Api.module.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -780,7 +780,7 @@
 block discarded – undo
780 780
     /**
781 781
      * @param EEM_Base $source_model
782 782
      * @param EEM_Base $related_model
783
-     * @param          $version
783
+     * @param          string $version
784 784
      * @return array
785 785
      * @throws EE_Error
786 786
      * @since $VID:$
Please login to merge, or discard this patch.
Indentation   +1351 added lines, -1351 removed lines patch added patch discarded remove patch
@@ -22,1355 +22,1355 @@
 block discarded – undo
22 22
 class EED_Core_Rest_Api extends EED_Module
23 23
 {
24 24
 
25
-    const ee_api_namespace = Domain::API_NAMESPACE;
26
-
27
-    const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/';
28
-
29
-    const saved_routes_option_names = 'ee_core_routes';
30
-
31
-    /**
32
-     * string used in _links response bodies to make them globally unique.
33
-     *
34
-     * @see http://v2.wp-api.org/extending/linking/
35
-     */
36
-    const ee_api_link_namespace = 'https://api.eventespresso.com/';
37
-
38
-    /**
39
-     * @var CalculatedModelFields
40
-     */
41
-    protected static $_field_calculator;
42
-
43
-
44
-    /**
45
-     * @return EED_Core_Rest_Api|EED_Module
46
-     */
47
-    public static function instance()
48
-    {
49
-        return parent::get_instance(EED_Core_Rest_Api::class);
50
-    }
51
-
52
-
53
-    /**
54
-     *    set_hooks - for hooking into EE Core, other modules, etc
55
-     *
56
-     * @access    public
57
-     * @return    void
58
-     */
59
-    public static function set_hooks()
60
-    {
61
-        EED_Core_Rest_Api::set_hooks_both();
62
-    }
63
-
64
-
65
-    /**
66
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
67
-     *
68
-     * @access    public
69
-     * @return    void
70
-     */
71
-    public static function set_hooks_admin()
72
-    {
73
-        EED_Core_Rest_Api::set_hooks_both();
74
-    }
75
-
76
-
77
-    public static function set_hooks_both()
78
-    {
79
-        /** @var EventEspresso\core\services\request\Request $request */
80
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
81
-        if (! $request->isWordPressApi()) {
82
-            return;
83
-        }
84
-        add_action('rest_api_init', ['EED_Core_Rest_Api', 'register_routes'], 10);
85
-        add_action('rest_api_init', ['EED_Core_Rest_Api', 'set_hooks_rest_api'], 5);
86
-        add_filter('rest_route_data', ['EED_Core_Rest_Api', 'hide_old_endpoints'], 10, 2);
87
-        add_filter(
88
-            'rest_index',
89
-            ['EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filterEeMetadataIntoIndex']
90
-        );
91
-        EED_Core_Rest_Api::$_field_calculator = LoaderFactory::getLoader()->load(
92
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields'
93
-        );
94
-        EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change();
95
-    }
96
-
97
-
98
-    /**
99
-     * sets up hooks which only need to be included as part of REST API requests;
100
-     * other requests like to the frontend or admin etc don't need them
101
-     *
102
-     * @throws EE_Error
103
-     */
104
-    public static function set_hooks_rest_api()
105
-    {
106
-        // set hooks which account for changes made to the API
107
-        EED_Core_Rest_Api::_set_hooks_for_changes();
108
-    }
109
-
110
-
111
-    /**
112
-     * public wrapper of _set_hooks_for_changes.
113
-     * Loads all the hooks which make requests to old versions of the API
114
-     * appear the same as they always did
115
-     *
116
-     * @throws EE_Error
117
-     */
118
-    public static function set_hooks_for_changes()
119
-    {
120
-        EED_Core_Rest_Api::_set_hooks_for_changes();
121
-    }
122
-
123
-
124
-    /**
125
-     * Loads all the hooks which make requests to old versions of the API
126
-     * appear the same as they always did
127
-     *
128
-     * @throws EE_Error
129
-     */
130
-    protected static function _set_hooks_for_changes()
131
-    {
132
-        $folder_contents = EEH_File::get_contents_of_folders([EE_LIBRARIES . 'rest_api/changes'], false);
133
-        foreach ($folder_contents as $classname_in_namespace => $filepath) {
134
-            // ignore the base parent class
135
-            // and legacy named classes
136
-            if ($classname_in_namespace === 'ChangesInBase'
137
-                || strpos($classname_in_namespace, 'Changes_In_') === 0
138
-            ) {
139
-                continue;
140
-            }
141
-            $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
142
-            if (class_exists($full_classname)) {
143
-                $instance_of_class = new $full_classname;
144
-                if ($instance_of_class instanceof ChangesInBase) {
145
-                    $instance_of_class->setHooks();
146
-                }
147
-            }
148
-        }
149
-    }
150
-
151
-
152
-    /**
153
-     * Filters the WP routes to add our EE-related ones. This takes a bit of time
154
-     * so we actually prefer to only do it when an EE plugin is activated or upgraded
155
-     *
156
-     * @throws EE_Error
157
-     * @throws ReflectionException
158
-     */
159
-    public static function register_routes()
160
-    {
161
-        foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_routes) {
162
-            foreach ($relative_routes as $relative_route => $data_for_multiple_endpoints) {
163
-                /**
164
-                 * @var array     $data_for_multiple_endpoints numerically indexed array
165
-                 *                                         but can also contain route options like {
166
-                 * @type array    $schema                      {
167
-                 * @type callable $schema_callback
168
-                 * @type array    $callback_args               arguments that will be passed to the callback, after the
169
-                 * WP_REST_Request of course
170
-                 * }
171
-                 * }
172
-                 */
173
-                // when registering routes, register all the endpoints' data at the same time
174
-                $multiple_endpoint_args = [];
175
-                foreach ($data_for_multiple_endpoints as $endpoint_key => $data_for_single_endpoint) {
176
-                    /**
177
-                     * @var array     $data_for_single_endpoint {
178
-                     * @type callable $callback
179
-                     * @type string methods
180
-                     * @type array args
181
-                     * @type array _links
182
-                     * @type array    $callback_args            arguments that will be passed to the callback, after the
183
-                     * WP_REST_Request of course
184
-                     * }
185
-                     */
186
-                    // skip route options
187
-                    if (! is_numeric($endpoint_key)) {
188
-                        continue;
189
-                    }
190
-                    if (! isset($data_for_single_endpoint['callback'], $data_for_single_endpoint['methods'])) {
191
-                        throw new EE_Error(
192
-                            esc_html__(
193
-                            // @codingStandardsIgnoreStart
194
-                                'Endpoint configuration data needs to have entries "callback" (callable) and "methods" (comma-separated list of accepts HTTP methods).',
195
-                                // @codingStandardsIgnoreEnd
196
-                                'event_espresso'
197
-                            )
198
-                        );
199
-                    }
200
-                    $callback = $data_for_single_endpoint['callback'];
201
-                    $single_endpoint_args = [
202
-                        'methods' => $data_for_single_endpoint['methods'],
203
-                        'args'    => isset($data_for_single_endpoint['args']) ? $data_for_single_endpoint['args']
204
-                            : [],
205
-                    ];
206
-                    if (isset($data_for_single_endpoint['_links'])) {
207
-                        $single_endpoint_args['_links'] = $data_for_single_endpoint['_links'];
208
-                    }
209
-                    if (isset($data_for_single_endpoint['callback_args'])) {
210
-                        $callback_args = $data_for_single_endpoint['callback_args'];
211
-                        $single_endpoint_args['callback'] = static function (WP_REST_Request $request) use (
212
-                            $callback,
213
-                            $callback_args
214
-                        ) {
215
-                            array_unshift($callback_args, $request);
216
-                            return call_user_func_array(
217
-                                $callback,
218
-                                $callback_args
219
-                            );
220
-                        };
221
-                    } else {
222
-                        $single_endpoint_args['callback'] = $data_for_single_endpoint['callback'];
223
-                    }
224
-                    $multiple_endpoint_args[] = $single_endpoint_args;
225
-                }
226
-                if (isset($data_for_multiple_endpoints['schema'])) {
227
-                    $schema_route_data = $data_for_multiple_endpoints['schema'];
228
-                    $schema_callback = $schema_route_data['schema_callback'];
229
-                    $callback_args = $schema_route_data['callback_args'];
230
-                    $multiple_endpoint_args['schema'] = static function () use ($schema_callback, $callback_args) {
231
-                        return call_user_func_array(
232
-                            $schema_callback,
233
-                            $callback_args
234
-                        );
235
-                    };
236
-                }
237
-                register_rest_route(
238
-                    $namespace,
239
-                    $relative_route,
240
-                    $multiple_endpoint_args
241
-                );
242
-            }
243
-        }
244
-    }
245
-
246
-
247
-    /**
248
-     * Checks if there was a version change or something that merits invalidating the cached
249
-     * route data. If so, invalidates the cached route data so that it gets refreshed
250
-     * next time the WP API is used
251
-     */
252
-    public static function invalidate_cached_route_data_on_version_change()
253
-    {
254
-        if (EE_System::instance()->detect_req_type() !== EE_System::req_type_normal) {
255
-            EED_Core_Rest_Api::invalidate_cached_route_data();
256
-        }
257
-        foreach (EE_Registry::instance()->addons as $addon) {
258
-            if ($addon instanceof EE_Addon && $addon->detect_req_type() !== EE_System::req_type_normal) {
259
-                EED_Core_Rest_Api::invalidate_cached_route_data();
260
-            }
261
-        }
262
-    }
263
-
264
-
265
-    /**
266
-     * Removes the cached route data so it will get refreshed next time the WP API is used
267
-     */
268
-    public static function invalidate_cached_route_data()
269
-    {
270
-        // delete the saved EE REST API routes
271
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) {
272
-            delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version);
273
-        }
274
-    }
275
-
276
-
277
-    /**
278
-     * Gets the EE route data
279
-     *
280
-     * @return array top-level key is the namespace, next-level key is the route and its value is array{
281
-     * @throws EE_Error
282
-     * @throws ReflectionException
283
-     * @type string|array $callback
284
-     * @type string       $methods
285
-     * @type boolean      $hidden_endpoint
286
-     * }
287
-     */
288
-    public static function get_ee_route_data()
289
-    {
290
-        $ee_routes = [];
291
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoints) {
292
-            $ee_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = EED_Core_Rest_Api::_get_ee_route_data_for_version(
293
-                $version,
294
-                $hidden_endpoints
295
-            );
296
-        }
297
-        return $ee_routes;
298
-    }
299
-
300
-
301
-    /**
302
-     * Gets the EE route data from the wp options if it exists already,
303
-     * otherwise re-generates it and saves it to the option
304
-     *
305
-     * @param string  $version
306
-     * @param boolean $hidden_endpoints
307
-     * @return array
308
-     * @throws EE_Error
309
-     * @throws ReflectionException
310
-     */
311
-    protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false)
312
-    {
313
-        $ee_routes = get_option(EED_Core_Rest_Api::saved_routes_option_names . $version, null);
314
-        if (! $ee_routes || EED_Core_Rest_Api::debugMode()) {
315
-            $ee_routes = EED_Core_Rest_Api::_save_ee_route_data_for_version($version, $hidden_endpoints);
316
-        }
317
-        return $ee_routes;
318
-    }
319
-
320
-
321
-    /**
322
-     * Saves the EE REST API route data to a wp option and returns it
323
-     *
324
-     * @param string  $version
325
-     * @param boolean $hidden_endpoints
326
-     * @return mixed|null
327
-     * @throws EE_Error
328
-     * @throws ReflectionException
329
-     */
330
-    protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false)
331
-    {
332
-        $instance = EED_Core_Rest_Api::instance();
333
-        $routes = apply_filters(
334
-            'EED_Core_Rest_Api__save_ee_route_data_for_version__routes',
335
-            array_replace_recursive(
336
-                $instance->_get_config_route_data_for_version($version, $hidden_endpoints),
337
-                $instance->_get_meta_route_data_for_version($version, $hidden_endpoints),
338
-                $instance->_get_model_route_data_for_version($version, $hidden_endpoints),
339
-                $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints)
340
-            )
341
-        );
342
-        $option_name = EED_Core_Rest_Api::saved_routes_option_names . $version;
343
-        if (get_option($option_name)) {
344
-            update_option($option_name, $routes, true);
345
-        } else {
346
-            add_option($option_name, $routes, null, 'no');
347
-        }
348
-        return $routes;
349
-    }
350
-
351
-
352
-    /**
353
-     * Calculates all the EE routes and saves it to a WordPress option so we don't
354
-     * need to calculate it on every request
355
-     *
356
-     * @return void
357
-     * @deprecated since version 4.9.1
358
-     */
359
-    public static function save_ee_routes()
360
-    {
361
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
362
-            $instance = EED_Core_Rest_Api::instance();
363
-            $routes = apply_filters(
364
-                'EED_Core_Rest_Api__save_ee_routes__routes',
365
-                array_replace_recursive(
366
-                    $instance->_register_config_routes(),
367
-                    $instance->_register_meta_routes(),
368
-                    $instance->_register_model_routes(),
369
-                    $instance->_register_rpc_routes()
370
-                )
371
-            );
372
-            update_option(EED_Core_Rest_Api::saved_routes_option_names, $routes, true);
373
-        }
374
-    }
375
-
376
-
377
-    /**
378
-     * Gets all the route information relating to EE models
379
-     *
380
-     * @return array @see get_ee_route_data
381
-     * @deprecated since version 4.9.1
382
-     */
383
-    protected function _register_model_routes()
384
-    {
385
-        $model_routes = [];
386
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
387
-            $model_routes[ EED_Core_Rest_Api::ee_api_namespace
388
-                           . $version ] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
389
-        }
390
-        return $model_routes;
391
-    }
392
-
393
-
394
-    /**
395
-     * Decides whether or not to add write endpoints for this model.
396
-     * Currently, this defaults to exclude all global tables and models
397
-     * which would allow inserting WP core data (we don't want to duplicate
398
-     * what WP API does, as it's unnecessary, extra work, and potentially extra bugs)
399
-     *
400
-     * @param EEM_Base $model
401
-     * @return bool
402
-     */
403
-    public static function should_have_write_endpoints(EEM_Base $model)
404
-    {
405
-        if ($model->is_wp_core_model()) {
406
-            return false;
407
-        }
408
-        foreach ($model->get_tables() as $table) {
409
-            if ($table->is_global()) {
410
-                return false;
411
-            }
412
-        }
413
-        return true;
414
-    }
415
-
416
-
417
-    /**
418
-     * Gets the names of all models which should have plural routes (eg `ee/v4.8.36/events`)
419
-     * in this versioned namespace of EE4
420
-     *
421
-     * @param $version
422
-     * @return array keys are model names (eg 'Event') and values ar either classnames (eg 'EEM_Event')
423
-     */
424
-    public static function model_names_with_plural_routes($version)
425
-    {
426
-        $model_version_info = new ModelVersionInfo($version);
427
-        $models_to_register = $model_version_info->modelsForRequestedVersion();
428
-        // let's not bother having endpoints for extra metas
429
-        unset(
430
-            $models_to_register['Extra_Meta'],
431
-            $models_to_register['Extra_Join'],
432
-            $models_to_register['Post_Meta']
433
-        );
434
-        return apply_filters(
435
-            'FHEE__EED_Core_REST_API___register_model_routes',
436
-            $models_to_register
437
-        );
438
-    }
439
-
440
-
441
-    /**
442
-     * Gets the route data for EE models in the specified version
443
-     *
444
-     * @param string  $version
445
-     * @param boolean $hidden_endpoint
446
-     * @return array
447
-     * @throws EE_Error
448
-     * @throws ReflectionException
449
-     */
450
-    protected function _get_model_route_data_for_version($version, $hidden_endpoint = false)
451
-    {
452
-        $model_routes = [];
453
-        $model_version_info = new ModelVersionInfo($version);
454
-        foreach (EED_Core_Rest_Api::model_names_with_plural_routes($version) as $model_name => $model_classname) {
455
-            $model = EE_Registry::instance()->load_model($model_name);
456
-            // if this isn't a valid model then let's skip iterate to the next item in the loop.
457
-            if (! $model instanceof EEM_Base) {
458
-                continue;
459
-            }
460
-            // yes we could just register one route for ALL models, but then they wouldn't show up in the index
461
-            $plural_model_route = EED_Core_Rest_Api::get_collection_route($model);
462
-            $singular_model_route = EED_Core_Rest_Api::get_entity_route($model, '(?P<id>[^\/]+)');
463
-            $model_routes[ $plural_model_route ] = [
464
-                [
465
-                    'callback'        => [
466
-                        'EventEspresso\core\libraries\rest_api\controllers\model\Read',
467
-                        'handleRequestGetAll',
468
-                    ],
469
-                    'callback_args'   => [$version, $model_name],
470
-                    'methods'         => WP_REST_Server::READABLE,
471
-                    'hidden_endpoint' => $hidden_endpoint,
472
-                    'args'            => $this->_get_read_query_params($model, $version),
473
-                    '_links'          => [
474
-                        'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route),
475
-                    ],
476
-                ],
477
-                'schema' => [
478
-                    'schema_callback' => [
479
-                        'EventEspresso\core\libraries\rest_api\controllers\model\Read',
480
-                        'handleSchemaRequest',
481
-                    ],
482
-                    'callback_args'   => [$version, $model_name],
483
-                ],
484
-            ];
485
-            $model_routes[ $singular_model_route ] = [
486
-                [
487
-                    'callback'        => [
488
-                        'EventEspresso\core\libraries\rest_api\controllers\model\Read',
489
-                        'handleRequestGetOne',
490
-                    ],
491
-                    'callback_args'   => [$version, $model_name],
492
-                    'methods'         => WP_REST_Server::READABLE,
493
-                    'hidden_endpoint' => $hidden_endpoint,
494
-                    'args'            => $this->_get_response_selection_query_params($model, $version, true),
495
-                ],
496
-            ];
497
-            if (apply_filters(
498
-                'FHEE__EED_Core_Rest_Api___get_model_route_data_for_version__add_write_endpoints',
499
-                EED_Core_Rest_Api::should_have_write_endpoints($model),
500
-                $model
501
-            )) {
502
-                $model_routes[ $plural_model_route ][] = [
503
-                    'callback'        => [
504
-                        'EventEspresso\core\libraries\rest_api\controllers\model\Write',
505
-                        'handleRequestInsert',
506
-                    ],
507
-                    'callback_args'   => [$version, $model_name],
508
-                    'methods'         => WP_REST_Server::CREATABLE,
509
-                    'hidden_endpoint' => $hidden_endpoint,
510
-                    'args'            => $this->_get_write_params($model_name, $model_version_info, true),
511
-                ];
512
-                $model_routes[ $singular_model_route ] = array_merge(
513
-                    $model_routes[ $singular_model_route ],
514
-                    [
515
-                        [
516
-                            'callback'        => [
517
-                                'EventEspresso\core\libraries\rest_api\controllers\model\Write',
518
-                                'handleRequestUpdate',
519
-                            ],
520
-                            'callback_args'   => [$version, $model_name],
521
-                            'methods'         => WP_REST_Server::EDITABLE,
522
-                            'hidden_endpoint' => $hidden_endpoint,
523
-                            'args'            => $this->_get_write_params($model_name, $model_version_info),
524
-                        ],
525
-                        [
526
-                            'callback'        => [
527
-                                'EventEspresso\core\libraries\rest_api\controllers\model\Write',
528
-                                'handleRequestDelete',
529
-                            ],
530
-                            'callback_args'   => [$version, $model_name],
531
-                            'methods'         => WP_REST_Server::DELETABLE,
532
-                            'hidden_endpoint' => $hidden_endpoint,
533
-                            'args'            => $this->_get_delete_query_params($model, $version),
534
-                        ],
535
-                    ]
536
-                );
537
-            }
538
-            foreach ($model->relation_settings() as $relation_name => $relation_obj) {
539
-                $related_route = EED_Core_Rest_Api::get_relation_route_via(
540
-                    $model,
541
-                    '(?P<id>[^\/]+)',
542
-                    $relation_obj
543
-                );
544
-                $model_routes[ $related_route ] = [
545
-                    [
546
-                        'callback'        => [
547
-                            'EventEspresso\core\libraries\rest_api\controllers\model\Read',
548
-                            'handleRequestGetRelated',
549
-                        ],
550
-                        'callback_args'   => [$version, $model_name, $relation_name],
551
-                        'methods'         => WP_REST_Server::READABLE,
552
-                        'hidden_endpoint' => $hidden_endpoint,
553
-                        'args'            => $this->_get_read_query_params($relation_obj->get_other_model(), $version),
554
-                    ],
555
-                ];
556
-
557
-                $related_write_route = $related_route . '/' . '(?P<related_id>[^\/]+)';
558
-                $model_routes[ $related_write_route ] = [
559
-                    [
560
-                        'callback'        => [
561
-                            'EventEspresso\core\libraries\rest_api\controllers\model\Write',
562
-                            'handleRequestAddRelation',
563
-                        ],
564
-                        'callback_args'   => [$version, $model_name, $relation_name],
565
-                        'methods'         => WP_REST_Server::EDITABLE,
566
-                        'hidden_endpoint' => $hidden_endpoint,
567
-                        'args'            => $this->_get_add_relation_query_params($model,
568
-                            $relation_obj->get_other_model(), $version),
569
-                    ],
570
-                    [
571
-                        'callback'        => [
572
-                            'EventEspresso\core\libraries\rest_api\controllers\model\Write',
573
-                            'handleRequestRemoveRelation',
574
-                        ],
575
-                        'callback_args'   => [$version, $model_name, $relation_name],
576
-                        'methods'         => WP_REST_Server::DELETABLE,
577
-                        'hidden_endpoint' => $hidden_endpoint,
578
-                        'args'            => [],
579
-                    ],
580
-                ];
581
-            }
582
-        }
583
-        return $model_routes;
584
-    }
585
-
586
-
587
-    /**
588
-     * Gets the relative URI to a model's REST API plural route, after the EE4 versioned namespace,
589
-     * excluding the preceding slash.
590
-     * Eg you pass get_plural_route_to('Event') = 'events'
591
-     *
592
-     * @param EEM_Base $model
593
-     * @return string
594
-     */
595
-    public static function get_collection_route(EEM_Base $model)
596
-    {
597
-        return EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
598
-    }
599
-
600
-
601
-    /**
602
-     * Gets the relative URI to a model's REST API singular route, after the EE4 versioned namespace,
603
-     * excluding the preceding slash.
604
-     * Eg you pass get_plural_route_to('Event', 12) = 'events/12'
605
-     *
606
-     * @param EEM_Base $model eg Event or Venue
607
-     * @param string   $id
608
-     * @return string
609
-     */
610
-    public static function get_entity_route($model, $id)
611
-    {
612
-        return EED_Core_Rest_Api::get_collection_route($model) . '/' . $id;
613
-    }
614
-
615
-
616
-    /**
617
-     * Gets the relative URI to a model's REST API singular route, after the EE4 versioned namespace,
618
-     * excluding the preceding slash.
619
-     * Eg you pass get_plural_route_to('Event', 12) = 'events/12'
620
-     *
621
-     * @param EEM_Base               $model eg Event or Venue
622
-     * @param string                 $id
623
-     * @param EE_Model_Relation_Base $relation_obj
624
-     * @return string
625
-     */
626
-    public static function get_relation_route_via(EEM_Base $model, $id, EE_Model_Relation_Base $relation_obj)
627
-    {
628
-        $related_model_name_endpoint_part = ModelRead::getRelatedEntityName(
629
-            $relation_obj->get_other_model()->get_this_model_name(),
630
-            $relation_obj
631
-        );
632
-        return EED_Core_Rest_Api::get_entity_route($model, $id) . '/' . $related_model_name_endpoint_part;
633
-    }
634
-
635
-
636
-    /**
637
-     * Adds onto the $relative_route the EE4 REST API versioned namespace.
638
-     * Eg if given '4.8.36' and 'events', will return 'ee/v4.8.36/events'
639
-     *
640
-     * @param string $relative_route
641
-     * @param string $version
642
-     * @return string
643
-     */
644
-    public static function get_versioned_route_to($relative_route, $version = '4.8.36')
645
-    {
646
-        return '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/' . $relative_route;
647
-    }
648
-
649
-
650
-    /**
651
-     * Adds all the RPC-style routes (remote procedure call-like routes, ie
652
-     * routes that don't conform to the traditional REST CRUD-style).
653
-     *
654
-     * @deprecated since 4.9.1
655
-     */
656
-    protected function _register_rpc_routes()
657
-    {
658
-        $routes = [];
659
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
660
-            $routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version(
661
-                $version,
662
-                $hidden_endpoint
663
-            );
664
-        }
665
-        return $routes;
666
-    }
667
-
668
-
669
-    /**
670
-     * @param string  $version
671
-     * @param boolean $hidden_endpoint
672
-     * @return array
673
-     */
674
-    protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false)
675
-    {
676
-        $this_versions_routes = [];
677
-        // checkin endpoint
678
-        $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = [
679
-            [
680
-                'callback'        => [
681
-                    'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
682
-                    'handleRequestToggleCheckin',
683
-                ],
684
-                'methods'         => WP_REST_Server::CREATABLE,
685
-                'hidden_endpoint' => $hidden_endpoint,
686
-                'args'            => [
687
-                    'force' => [
688
-                        'required'    => false,
689
-                        'default'     => false,
690
-                        'description' => __(
691
-                        // @codingStandardsIgnoreStart
692
-                            'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses',
693
-                            // @codingStandardsIgnoreEnd
694
-                            'event_espresso'
695
-                        ),
696
-                    ],
697
-                ],
698
-                'callback_args'   => [$version],
699
-            ],
700
-        ];
701
-        return apply_filters(
702
-            'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
703
-            $this_versions_routes,
704
-            $version,
705
-            $hidden_endpoint
706
-        );
707
-    }
708
-
709
-
710
-    /**
711
-     * Gets the query params that can be used when request one or many
712
-     *
713
-     * @param EEM_Base $model
714
-     * @param string   $version
715
-     * @return array
716
-     */
717
-    protected function _get_response_selection_query_params(EEM_Base $model, $version, $single_only = false)
718
-    {
719
-        $query_params = [
720
-            'include'   => [
721
-                'required' => false,
722
-                'default'  => '*',
723
-                'type'     => 'string',
724
-            ],
725
-            'calculate' => [
726
-                'required'          => false,
727
-                'default'           => '',
728
-                'enum'              => EED_Core_Rest_Api::$_field_calculator->retrieveCalculatedFieldsForModel($model),
729
-                'type'              => 'string',
730
-                // because we accept a CSV'd list of the enumerated strings, WP core validation and sanitization
731
-                // freaks out. We'll just validate this argument while handling the request
732
-                'validate_callback' => null,
733
-                'sanitize_callback' => null,
734
-            ],
735
-            'password'  => [
736
-                'required' => false,
737
-                'default'  => '',
738
-                'type'     => 'string',
739
-            ],
740
-        ];
741
-        return apply_filters(
742
-            'FHEE__EED_Core_Rest_Api___get_response_selection_query_params',
743
-            $query_params,
744
-            $model,
745
-            $version
746
-        );
747
-    }
748
-
749
-
750
-    /**
751
-     * Gets the parameters acceptable for delete requests
752
-     *
753
-     * @param EEM_Base $model
754
-     * @param string   $version
755
-     * @return array
756
-     */
757
-    protected function _get_delete_query_params(EEM_Base $model, $version)
758
-    {
759
-        $params_for_delete = [
760
-            'allow_blocking' => [
761
-                'required' => false,
762
-                'default'  => true,
763
-                'type'     => 'boolean',
764
-            ],
765
-        ];
766
-        $params_for_delete['force'] = [
767
-            'required' => false,
768
-            'default'  => false,
769
-            'type'     => 'boolean',
770
-        ];
771
-        return apply_filters(
772
-            'FHEE__EED_Core_Rest_Api___get_delete_query_params',
773
-            $params_for_delete,
774
-            $model,
775
-            $version
776
-        );
777
-    }
778
-
779
-
780
-    /**
781
-     * @param EEM_Base $source_model
782
-     * @param EEM_Base $related_model
783
-     * @param          $version
784
-     * @return array
785
-     * @throws EE_Error
786
-     * @since $VID:$
787
-     */
788
-    protected function _get_add_relation_query_params(EEM_Base $source_model, EEM_Base $related_model, $version)
789
-    {
790
-        // if they're related through a HABTM relation, check for any non-FKs
791
-        $all_relation_settings = $source_model->relation_settings();
792
-        $relation_settings = $all_relation_settings[ $related_model->get_this_model_name() ];
793
-        $params = [];
794
-        if ($relation_settings instanceof EE_HABTM_Relation && $relation_settings->hasNonKeyFields()) {
795
-            foreach ($relation_settings->getNonKeyFields() as $field) {
796
-                /* @var $field EE_Model_Field_Base */
797
-                $params[ $field->get_name() ] = [
798
-                    'required'          => ! $field->is_nullable(),
799
-                    'default'           => ModelDataTranslator::prepareFieldValueForJson($field,
800
-                        $field->get_default_value(), $version),
801
-                    'type'              => $field->getSchemaType(),
802
-                    'validate_callback' => null,
803
-                    'sanitize_callback' => null,
804
-                ];
805
-            }
806
-        }
807
-        return $params;
808
-    }
809
-
810
-
811
-    /**
812
-     * Gets info about reading query params that are acceptable
813
-     *
814
-     * @param EEM_Base $model eg 'Event' or 'Venue'
815
-     * @param string   $version
816
-     * @return array    describing the args acceptable when querying this model
817
-     * @throws EE_Error
818
-     */
819
-    protected function _get_read_query_params(EEM_Base $model, $version)
820
-    {
821
-        $default_orderby = [];
822
-        foreach ($model->get_combined_primary_key_fields() as $key_field) {
823
-            $default_orderby[ $key_field->get_name() ] = 'ASC';
824
-        }
825
-        return array_merge(
826
-            $this->_get_response_selection_query_params($model, $version),
827
-            [
828
-                'where'    => [
829
-                    'required'          => false,
830
-                    'default'           => [],
831
-                    'type'              => 'object',
832
-                    // because we accept an almost infinite list of possible where conditions, WP
833
-                    // core validation and sanitization freaks out. We'll just validate this argument
834
-                    // while handling the request
835
-                    'validate_callback' => null,
836
-                    'sanitize_callback' => null,
837
-                ],
838
-                'limit'    => [
839
-                    'required'          => false,
840
-                    'default'           => EED_Core_Rest_Api::get_default_query_limit(),
841
-                    'type'              => [
842
-                        'array',
843
-                        'string',
844
-                        'integer',
845
-                    ],
846
-                    // because we accept a variety of types, WP core validation and sanitization
847
-                    // freaks out. We'll just validate this argument while handling the request
848
-                    'validate_callback' => null,
849
-                    'sanitize_callback' => null,
850
-                ],
851
-                'order_by' => [
852
-                    'required'          => false,
853
-                    'default'           => $default_orderby,
854
-                    'type'              => [
855
-                        'object',
856
-                        'string',
857
-                    ],// because we accept a variety of types, WP core validation and sanitization
858
-                    // freaks out. We'll just validate this argument while handling the request
859
-                    'validate_callback' => null,
860
-                    'sanitize_callback' => null,
861
-                ],
862
-                'group_by' => [
863
-                    'required'          => false,
864
-                    'default'           => null,
865
-                    'type'              => [
866
-                        'object',
867
-                        'string',
868
-                    ],
869
-                    // because we accept  an almost infinite list of possible groupings,
870
-                    // WP core validation and sanitization
871
-                    // freaks out. We'll just validate this argument while handling the request
872
-                    'validate_callback' => null,
873
-                    'sanitize_callback' => null,
874
-                ],
875
-                'having'   => [
876
-                    'required'          => false,
877
-                    'default'           => null,
878
-                    'type'              => 'object',
879
-                    // because we accept an almost infinite list of possible where conditions, WP
880
-                    // core validation and sanitization freaks out. We'll just validate this argument
881
-                    // while handling the request
882
-                    'validate_callback' => null,
883
-                    'sanitize_callback' => null,
884
-                ],
885
-                'caps'     => [
886
-                    'required' => false,
887
-                    'default'  => EEM_Base::caps_read,
888
-                    'type'     => 'string',
889
-                    'enum'     => [
890
-                        EEM_Base::caps_read,
891
-                        EEM_Base::caps_read_admin,
892
-                        EEM_Base::caps_edit,
893
-                        EEM_Base::caps_delete,
894
-                    ],
895
-                ],
896
-            ]
897
-        );
898
-    }
899
-
900
-
901
-    /**
902
-     * Gets parameter information for a model regarding writing data
903
-     *
904
-     * @param string           $model_name
905
-     * @param ModelVersionInfo $model_version_info
906
-     * @param boolean          $create                                       whether this is for request to create (in
907
-     *                                                                       which case we need all required params) or
908
-     *                                                                       just to update (in which case we don't
909
-     *                                                                       need those on every request)
910
-     * @return array
911
-     * @throws EE_Error
912
-     * @throws ReflectionException
913
-     */
914
-    protected function _get_write_params(
915
-        $model_name,
916
-        ModelVersionInfo $model_version_info,
917
-        $create = false
918
-    ) {
919
-        $model = EE_Registry::instance()->load_model($model_name);
920
-        $fields = $model_version_info->fieldsOnModelInThisVersion($model);
921
-
922
-        // we do our own validation and sanitization within the controller
923
-        $sanitize_callback = function_exists('rest_validate_value_from_schema')
924
-            ? ['EED_Core_Rest_Api', 'default_sanitize_callback']
925
-            : null;
926
-        $args_info = [];
927
-        foreach ($fields as $field_name => $field_obj) {
928
-            if ($field_obj->is_auto_increment()) {
929
-                // totally ignore auto increment IDs
930
-                continue;
931
-            }
932
-            $arg_info = $field_obj->getSchema();
933
-            $required = $create && ! $field_obj->is_nullable() && $field_obj->get_default_value() === null;
934
-            $arg_info['required'] = $required;
935
-            // remove the read-only flag. If it were read-only we wouldn't list it as an argument while writing, right?
936
-            unset($arg_info['readonly']);
937
-            $schema_properties = $field_obj->getSchemaProperties();
938
-            if (isset($schema_properties['raw'])
939
-                && $field_obj->getSchemaType() === 'object'
940
-            ) {
941
-                // if there's a "raw" form of this argument, use those properties instead
942
-                $arg_info = array_replace(
943
-                    $arg_info,
944
-                    $schema_properties['raw']
945
-                );
946
-            }
947
-            $arg_info['default'] = ModelDataTranslator::prepareFieldValueForJson(
948
-                $field_obj,
949
-                $field_obj->get_default_value(),
950
-                $model_version_info->requestedVersion()
951
-            );
952
-            $arg_info['sanitize_callback'] = $sanitize_callback;
953
-            $args_info[ $field_name ] = $arg_info;
954
-            if ($field_obj instanceof EE_Datetime_Field) {
955
-                $gmt_arg_info = $arg_info;
956
-                $gmt_arg_info['description'] = sprintf(
957
-                    esc_html__(
958
-                        '%1$s - the value for this field in UTC. Ignored if %2$s is provided.',
959
-                        'event_espresso'
960
-                    ),
961
-                    $field_obj->get_nicename(),
962
-                    $field_name
963
-                );
964
-                $args_info[ $field_name . '_gmt' ] = $gmt_arg_info;
965
-            }
966
-        }
967
-        return $args_info;
968
-    }
969
-
970
-
971
-    /**
972
-     * Replacement for WP API's 'rest_parse_request_arg'.
973
-     * If the value is blank but not required, don't bother validating it.
974
-     * Also, it uses our email validation instead of WP API's default.
975
-     *
976
-     * @param                 $value
977
-     * @param WP_REST_Request $request
978
-     * @param                 $param
979
-     * @return bool|true|WP_Error
980
-     * @throws InvalidArgumentException
981
-     * @throws InvalidInterfaceException
982
-     * @throws InvalidDataTypeException
983
-     */
984
-    public static function default_sanitize_callback($value, WP_REST_Request $request, $param)
985
-    {
986
-        $attributes = $request->get_attributes();
987
-        if (! isset($attributes['args'][ $param ])
988
-            || ! is_array($attributes['args'][ $param ])) {
989
-            $validation_result = true;
990
-        } else {
991
-            $args = $attributes['args'][ $param ];
992
-            if ((
993
-                    $value === ''
994
-                    || $value === null
995
-                )
996
-                && (! isset($args['required'])
997
-                    || $args['required'] === false
998
-                )
999
-            ) {
1000
-                // not required and not provided? that's cool
1001
-                $validation_result = true;
1002
-            } elseif (isset($args['format'])
1003
-                      && $args['format'] === 'email'
1004
-            ) {
1005
-                $validation_result = true;
1006
-                if (! EED_Core_Rest_Api::_validate_email($value)) {
1007
-                    $validation_result = new WP_Error(
1008
-                        'rest_invalid_param',
1009
-                        esc_html__(
1010
-                            'The email address is not valid or does not exist.',
1011
-                            'event_espresso'
1012
-                        )
1013
-                    );
1014
-                }
1015
-            } else {
1016
-                $validation_result = rest_validate_value_from_schema($value, $args, $param);
1017
-            }
1018
-        }
1019
-        if (is_wp_error($validation_result)) {
1020
-            return $validation_result;
1021
-        }
1022
-        return rest_sanitize_request_arg($value, $request, $param);
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * Returns whether or not this email address is valid. Copied from EE_Email_Validation_Strategy::_validate_email()
1028
-     *
1029
-     * @param $email
1030
-     * @return bool
1031
-     * @throws InvalidArgumentException
1032
-     * @throws InvalidInterfaceException
1033
-     * @throws InvalidDataTypeException
1034
-     */
1035
-    protected static function _validate_email($email)
1036
-    {
1037
-        try {
1038
-            EmailAddressFactory::create($email);
1039
-            return true;
1040
-        } catch (EmailValidationException $e) {
1041
-            return false;
1042
-        }
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     * Gets routes for the config
1048
-     *
1049
-     * @return array @see _register_model_routes
1050
-     * @deprecated since version 4.9.1
1051
-     */
1052
-    protected function _register_config_routes()
1053
-    {
1054
-        $config_routes = [];
1055
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1056
-            $config_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version(
1057
-                $version,
1058
-                $hidden_endpoint
1059
-            );
1060
-        }
1061
-        return $config_routes;
1062
-    }
1063
-
1064
-
1065
-    /**
1066
-     * Gets routes for the config for the specified version
1067
-     *
1068
-     * @param string  $version
1069
-     * @param boolean $hidden_endpoint
1070
-     * @return array
1071
-     */
1072
-    protected function _get_config_route_data_for_version($version, $hidden_endpoint)
1073
-    {
1074
-        return [
1075
-            'config'    => [
1076
-                [
1077
-                    'callback'        => [
1078
-                        'EventEspresso\core\libraries\rest_api\controllers\config\Read',
1079
-                        'handleRequest',
1080
-                    ],
1081
-                    'methods'         => WP_REST_Server::READABLE,
1082
-                    'hidden_endpoint' => $hidden_endpoint,
1083
-                    'callback_args'   => [$version],
1084
-                ],
1085
-            ],
1086
-            'site_info' => [
1087
-                [
1088
-                    'callback'        => [
1089
-                        'EventEspresso\core\libraries\rest_api\controllers\config\Read',
1090
-                        'handleRequestSiteInfo',
1091
-                    ],
1092
-                    'methods'         => WP_REST_Server::READABLE,
1093
-                    'hidden_endpoint' => $hidden_endpoint,
1094
-                    'callback_args'   => [$version],
1095
-                ],
1096
-            ],
1097
-        ];
1098
-    }
1099
-
1100
-
1101
-    /**
1102
-     * Gets the meta info routes
1103
-     *
1104
-     * @return array @see _register_model_routes
1105
-     * @deprecated since version 4.9.1
1106
-     */
1107
-    protected function _register_meta_routes()
1108
-    {
1109
-        $meta_routes = [];
1110
-        foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1111
-            $meta_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version(
1112
-                $version,
1113
-                $hidden_endpoint
1114
-            );
1115
-        }
1116
-        return $meta_routes;
1117
-    }
1118
-
1119
-
1120
-    /**
1121
-     * @param string  $version
1122
-     * @param boolean $hidden_endpoint
1123
-     * @return array
1124
-     */
1125
-    protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false)
1126
-    {
1127
-        return [
1128
-            'resources' => [
1129
-                [
1130
-                    'callback'        => [
1131
-                        'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
1132
-                        'handleRequestModelsMeta',
1133
-                    ],
1134
-                    'methods'         => WP_REST_Server::READABLE,
1135
-                    'hidden_endpoint' => $hidden_endpoint,
1136
-                    'callback_args'   => [$version],
1137
-                ],
1138
-            ],
1139
-        ];
1140
-    }
1141
-
1142
-
1143
-    /**
1144
-     * Tries to hide old 4.6 endpoints from the
1145
-     *
1146
-     * @param array $route_data
1147
-     * @return array
1148
-     * @throws EE_Error
1149
-     * @throws ReflectionException
1150
-     */
1151
-    public static function hide_old_endpoints($route_data)
1152
-    {
1153
-        // allow API clients to override which endpoints get hidden, in case
1154
-        // they want to discover particular endpoints
1155
-        // also, we don't have access to the request so we have to just grab it from the superglobal
1156
-        $force_show_ee_namespace = ltrim(
1157
-            EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''),
1158
-            '/'
1159
-        );
1160
-        foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
1161
-            foreach ($relative_urls as $resource_name => $endpoints) {
1162
-                foreach ($endpoints as $key => $endpoint) {
1163
-                    // skip schema and other route options
1164
-                    if (! is_numeric($key)) {
1165
-                        continue;
1166
-                    }
1167
-                    // by default, hide "hidden_endpoint"s, unless the request indicates
1168
-                    // to $force_show_ee_namespace, in which case only show that one
1169
-                    // namespace's endpoints (and hide all others)
1170
-                    if (($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace)
1171
-                        || ($endpoint['hidden_endpoint'] && $force_show_ee_namespace === '')
1172
-                    ) {
1173
-                        $full_route = '/' . ltrim($namespace, '/');
1174
-                        $full_route .= '/' . ltrim($resource_name, '/');
1175
-                        unset($route_data[ $full_route ]);
1176
-                    }
1177
-                }
1178
-            }
1179
-        }
1180
-        return $route_data;
1181
-    }
1182
-
1183
-
1184
-    /**
1185
-     * Returns an array describing which versions of core support serving requests for.
1186
-     * Keys are core versions' major and minor version, and values are the
1187
-     * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like
1188
-     * data by just removing a few models and fields from the responses. However, 4.15 might remove
1189
-     * the answers table entirely, in which case it would be very difficult for
1190
-     * it to serve 4.6-style responses.
1191
-     * Versions of core that are missing from this array are unknowns.
1192
-     * previous ver
1193
-     *
1194
-     * @return array
1195
-     */
1196
-    public static function version_compatibilities()
1197
-    {
1198
-        return apply_filters(
1199
-            'FHEE__EED_Core_REST_API__version_compatibilities',
1200
-            [
1201
-                '4.8.29' => '4.8.29',
1202
-                '4.8.33' => '4.8.29',
1203
-                '4.8.34' => '4.8.29',
1204
-                '4.8.36' => '4.8.29',
1205
-            ]
1206
-        );
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * Gets the latest API version served. Eg if there
1212
-     * are two versions served of the API, 4.8.29 and 4.8.32, and
1213
-     * we are on core version 4.8.34, it will return the string "4.8.32"
1214
-     *
1215
-     * @return string
1216
-     */
1217
-    public static function latest_rest_api_version()
1218
-    {
1219
-        $versions_served = EED_Core_Rest_Api::versions_served();
1220
-        $versions_served_keys = array_keys($versions_served);
1221
-        return end($versions_served_keys);
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of
1227
-     * EE the API can serve requests for. Eg, if we are on 4.15 of core, and
1228
-     * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ).
1229
-     * We also indicate whether or not this version should be put in the index or not
1230
-     *
1231
-     * @return array keys are API version numbers (just major and minor numbers), and values
1232
-     * are whether or not they should be hidden
1233
-     */
1234
-    public static function versions_served()
1235
-    {
1236
-        $versions_served = [];
1237
-        $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
1238
-        $lowest_compatible_version = end($possibly_served_versions);
1239
-        reset($possibly_served_versions);
1240
-        $versions_served_historically = array_keys($possibly_served_versions);
1241
-        $latest_version = end($versions_served_historically);
1242
-        reset($versions_served_historically);
1243
-        // for each version of core we have ever served:
1244
-        foreach ($versions_served_historically as $key_versioned_endpoint) {
1245
-            // if it's not above the current core version, and it's compatible with the current version of core
1246
-
1247
-            if ($key_versioned_endpoint === $latest_version) {
1248
-                // don't hide the latest version in the index
1249
-                $versions_served[ $key_versioned_endpoint ] = false;
1250
-            } elseif (version_compare($key_versioned_endpoint, $lowest_compatible_version, '>=')
1251
-                      && version_compare($key_versioned_endpoint, EED_Core_Rest_Api::core_version(), '<')
1252
-            ) {
1253
-                // include, but hide, previous versions which are still supported
1254
-                $versions_served[ $key_versioned_endpoint ] = true;
1255
-            } elseif (apply_filters(
1256
-                'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
1257
-                false,
1258
-                $possibly_served_versions
1259
-            )) {
1260
-                // if a version is no longer supported, don't include it in index or list of versions served
1261
-                $versions_served[ $key_versioned_endpoint ] = true;
1262
-            }
1263
-        }
1264
-        return $versions_served;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * Gets the major and minor version of EE core's version string
1270
-     *
1271
-     * @return string
1272
-     */
1273
-    public static function core_version()
1274
-    {
1275
-        return apply_filters(
1276
-            'FHEE__EED_Core_REST_API__core_version',
1277
-            implode(
1278
-                '.',
1279
-                array_slice(
1280
-                    explode(
1281
-                        '.',
1282
-                        espresso_version()
1283
-                    ),
1284
-                    0,
1285
-                    3
1286
-                )
1287
-            )
1288
-        );
1289
-    }
1290
-
1291
-
1292
-    /**
1293
-     * Gets the default limit that should be used when querying for resources
1294
-     *
1295
-     * @return int
1296
-     */
1297
-    public static function get_default_query_limit()
1298
-    {
1299
-        // we actually don't use a const because we want folks to always use
1300
-        // this method, not the const directly
1301
-        return apply_filters(
1302
-            'FHEE__EED_Core_Rest_Api__get_default_query_limit',
1303
-            50
1304
-        );
1305
-    }
1306
-
1307
-
1308
-    /**
1309
-     * @param string $version api version string (i.e. '4.8.36')
1310
-     * @return array
1311
-     */
1312
-    public static function getCollectionRoutesIndexedByModelName($version = '')
1313
-    {
1314
-        $version = empty($version) ? EED_Core_Rest_Api::latest_rest_api_version() : $version;
1315
-        $model_names = EED_Core_Rest_Api::model_names_with_plural_routes($version);
1316
-        $collection_routes = [];
1317
-        foreach ($model_names as $model_name => $model_class_name) {
1318
-            $collection_routes[ strtolower($model_name) ] = '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/'
1319
-                                                            . EEH_Inflector::pluralize_and_lower($model_name);
1320
-        }
1321
-        return $collection_routes;
1322
-    }
1323
-
1324
-
1325
-    /**
1326
-     * Returns an array of primary key names indexed by model names.
1327
-     *
1328
-     * @param string $version
1329
-     * @return array
1330
-     */
1331
-    public static function getPrimaryKeyNamesIndexedByModelName($version = '')
1332
-    {
1333
-        $version = empty($version) ? EED_Core_Rest_Api::latest_rest_api_version() : $version;
1334
-        $model_names = EED_Core_Rest_Api::model_names_with_plural_routes($version);
1335
-        $primary_key_items = [];
1336
-        foreach ($model_names as $model_name => $model_class_name) {
1337
-            $primary_keys = $model_class_name::instance()->get_combined_primary_key_fields();
1338
-            foreach ($primary_keys as $primary_key_name => $primary_key_field) {
1339
-                if (count($primary_keys) > 1) {
1340
-                    $primary_key_items[ strtolower($model_name) ][] = $primary_key_name;
1341
-                } else {
1342
-                    $primary_key_items[ strtolower($model_name) ] = $primary_key_name;
1343
-                }
1344
-            }
1345
-        }
1346
-        return $primary_key_items;
1347
-    }
1348
-
1349
-
1350
-    /**
1351
-     * Determines the EE REST API debug mode is activated, or not.
1352
-     *
1353
-     * @return bool
1354
-     * @since 4.9.76.p
1355
-     */
1356
-    public static function debugMode()
1357
-    {
1358
-        static $debug_mode = null; // could be class prop
1359
-        if ($debug_mode === null) {
1360
-            $debug_mode = defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE;
1361
-        }
1362
-        return $debug_mode;
1363
-    }
1364
-
1365
-
1366
-    /**
1367
-     *    run - initial module setup
1368
-     *
1369
-     * @access    public
1370
-     * @param WP $WP
1371
-     * @return    void
1372
-     */
1373
-    public function run($WP)
1374
-    {
1375
-    }
25
+	const ee_api_namespace = Domain::API_NAMESPACE;
26
+
27
+	const ee_api_namespace_for_regex = 'ee\/v([^/]*)\/';
28
+
29
+	const saved_routes_option_names = 'ee_core_routes';
30
+
31
+	/**
32
+	 * string used in _links response bodies to make them globally unique.
33
+	 *
34
+	 * @see http://v2.wp-api.org/extending/linking/
35
+	 */
36
+	const ee_api_link_namespace = 'https://api.eventespresso.com/';
37
+
38
+	/**
39
+	 * @var CalculatedModelFields
40
+	 */
41
+	protected static $_field_calculator;
42
+
43
+
44
+	/**
45
+	 * @return EED_Core_Rest_Api|EED_Module
46
+	 */
47
+	public static function instance()
48
+	{
49
+		return parent::get_instance(EED_Core_Rest_Api::class);
50
+	}
51
+
52
+
53
+	/**
54
+	 *    set_hooks - for hooking into EE Core, other modules, etc
55
+	 *
56
+	 * @access    public
57
+	 * @return    void
58
+	 */
59
+	public static function set_hooks()
60
+	{
61
+		EED_Core_Rest_Api::set_hooks_both();
62
+	}
63
+
64
+
65
+	/**
66
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
67
+	 *
68
+	 * @access    public
69
+	 * @return    void
70
+	 */
71
+	public static function set_hooks_admin()
72
+	{
73
+		EED_Core_Rest_Api::set_hooks_both();
74
+	}
75
+
76
+
77
+	public static function set_hooks_both()
78
+	{
79
+		/** @var EventEspresso\core\services\request\Request $request */
80
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
81
+		if (! $request->isWordPressApi()) {
82
+			return;
83
+		}
84
+		add_action('rest_api_init', ['EED_Core_Rest_Api', 'register_routes'], 10);
85
+		add_action('rest_api_init', ['EED_Core_Rest_Api', 'set_hooks_rest_api'], 5);
86
+		add_filter('rest_route_data', ['EED_Core_Rest_Api', 'hide_old_endpoints'], 10, 2);
87
+		add_filter(
88
+			'rest_index',
89
+			['EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filterEeMetadataIntoIndex']
90
+		);
91
+		EED_Core_Rest_Api::$_field_calculator = LoaderFactory::getLoader()->load(
92
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields'
93
+		);
94
+		EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change();
95
+	}
96
+
97
+
98
+	/**
99
+	 * sets up hooks which only need to be included as part of REST API requests;
100
+	 * other requests like to the frontend or admin etc don't need them
101
+	 *
102
+	 * @throws EE_Error
103
+	 */
104
+	public static function set_hooks_rest_api()
105
+	{
106
+		// set hooks which account for changes made to the API
107
+		EED_Core_Rest_Api::_set_hooks_for_changes();
108
+	}
109
+
110
+
111
+	/**
112
+	 * public wrapper of _set_hooks_for_changes.
113
+	 * Loads all the hooks which make requests to old versions of the API
114
+	 * appear the same as they always did
115
+	 *
116
+	 * @throws EE_Error
117
+	 */
118
+	public static function set_hooks_for_changes()
119
+	{
120
+		EED_Core_Rest_Api::_set_hooks_for_changes();
121
+	}
122
+
123
+
124
+	/**
125
+	 * Loads all the hooks which make requests to old versions of the API
126
+	 * appear the same as they always did
127
+	 *
128
+	 * @throws EE_Error
129
+	 */
130
+	protected static function _set_hooks_for_changes()
131
+	{
132
+		$folder_contents = EEH_File::get_contents_of_folders([EE_LIBRARIES . 'rest_api/changes'], false);
133
+		foreach ($folder_contents as $classname_in_namespace => $filepath) {
134
+			// ignore the base parent class
135
+			// and legacy named classes
136
+			if ($classname_in_namespace === 'ChangesInBase'
137
+				|| strpos($classname_in_namespace, 'Changes_In_') === 0
138
+			) {
139
+				continue;
140
+			}
141
+			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
142
+			if (class_exists($full_classname)) {
143
+				$instance_of_class = new $full_classname;
144
+				if ($instance_of_class instanceof ChangesInBase) {
145
+					$instance_of_class->setHooks();
146
+				}
147
+			}
148
+		}
149
+	}
150
+
151
+
152
+	/**
153
+	 * Filters the WP routes to add our EE-related ones. This takes a bit of time
154
+	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
155
+	 *
156
+	 * @throws EE_Error
157
+	 * @throws ReflectionException
158
+	 */
159
+	public static function register_routes()
160
+	{
161
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_routes) {
162
+			foreach ($relative_routes as $relative_route => $data_for_multiple_endpoints) {
163
+				/**
164
+				 * @var array     $data_for_multiple_endpoints numerically indexed array
165
+				 *                                         but can also contain route options like {
166
+				 * @type array    $schema                      {
167
+				 * @type callable $schema_callback
168
+				 * @type array    $callback_args               arguments that will be passed to the callback, after the
169
+				 * WP_REST_Request of course
170
+				 * }
171
+				 * }
172
+				 */
173
+				// when registering routes, register all the endpoints' data at the same time
174
+				$multiple_endpoint_args = [];
175
+				foreach ($data_for_multiple_endpoints as $endpoint_key => $data_for_single_endpoint) {
176
+					/**
177
+					 * @var array     $data_for_single_endpoint {
178
+					 * @type callable $callback
179
+					 * @type string methods
180
+					 * @type array args
181
+					 * @type array _links
182
+					 * @type array    $callback_args            arguments that will be passed to the callback, after the
183
+					 * WP_REST_Request of course
184
+					 * }
185
+					 */
186
+					// skip route options
187
+					if (! is_numeric($endpoint_key)) {
188
+						continue;
189
+					}
190
+					if (! isset($data_for_single_endpoint['callback'], $data_for_single_endpoint['methods'])) {
191
+						throw new EE_Error(
192
+							esc_html__(
193
+							// @codingStandardsIgnoreStart
194
+								'Endpoint configuration data needs to have entries "callback" (callable) and "methods" (comma-separated list of accepts HTTP methods).',
195
+								// @codingStandardsIgnoreEnd
196
+								'event_espresso'
197
+							)
198
+						);
199
+					}
200
+					$callback = $data_for_single_endpoint['callback'];
201
+					$single_endpoint_args = [
202
+						'methods' => $data_for_single_endpoint['methods'],
203
+						'args'    => isset($data_for_single_endpoint['args']) ? $data_for_single_endpoint['args']
204
+							: [],
205
+					];
206
+					if (isset($data_for_single_endpoint['_links'])) {
207
+						$single_endpoint_args['_links'] = $data_for_single_endpoint['_links'];
208
+					}
209
+					if (isset($data_for_single_endpoint['callback_args'])) {
210
+						$callback_args = $data_for_single_endpoint['callback_args'];
211
+						$single_endpoint_args['callback'] = static function (WP_REST_Request $request) use (
212
+							$callback,
213
+							$callback_args
214
+						) {
215
+							array_unshift($callback_args, $request);
216
+							return call_user_func_array(
217
+								$callback,
218
+								$callback_args
219
+							);
220
+						};
221
+					} else {
222
+						$single_endpoint_args['callback'] = $data_for_single_endpoint['callback'];
223
+					}
224
+					$multiple_endpoint_args[] = $single_endpoint_args;
225
+				}
226
+				if (isset($data_for_multiple_endpoints['schema'])) {
227
+					$schema_route_data = $data_for_multiple_endpoints['schema'];
228
+					$schema_callback = $schema_route_data['schema_callback'];
229
+					$callback_args = $schema_route_data['callback_args'];
230
+					$multiple_endpoint_args['schema'] = static function () use ($schema_callback, $callback_args) {
231
+						return call_user_func_array(
232
+							$schema_callback,
233
+							$callback_args
234
+						);
235
+					};
236
+				}
237
+				register_rest_route(
238
+					$namespace,
239
+					$relative_route,
240
+					$multiple_endpoint_args
241
+				);
242
+			}
243
+		}
244
+	}
245
+
246
+
247
+	/**
248
+	 * Checks if there was a version change or something that merits invalidating the cached
249
+	 * route data. If so, invalidates the cached route data so that it gets refreshed
250
+	 * next time the WP API is used
251
+	 */
252
+	public static function invalidate_cached_route_data_on_version_change()
253
+	{
254
+		if (EE_System::instance()->detect_req_type() !== EE_System::req_type_normal) {
255
+			EED_Core_Rest_Api::invalidate_cached_route_data();
256
+		}
257
+		foreach (EE_Registry::instance()->addons as $addon) {
258
+			if ($addon instanceof EE_Addon && $addon->detect_req_type() !== EE_System::req_type_normal) {
259
+				EED_Core_Rest_Api::invalidate_cached_route_data();
260
+			}
261
+		}
262
+	}
263
+
264
+
265
+	/**
266
+	 * Removes the cached route data so it will get refreshed next time the WP API is used
267
+	 */
268
+	public static function invalidate_cached_route_data()
269
+	{
270
+		// delete the saved EE REST API routes
271
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) {
272
+			delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version);
273
+		}
274
+	}
275
+
276
+
277
+	/**
278
+	 * Gets the EE route data
279
+	 *
280
+	 * @return array top-level key is the namespace, next-level key is the route and its value is array{
281
+	 * @throws EE_Error
282
+	 * @throws ReflectionException
283
+	 * @type string|array $callback
284
+	 * @type string       $methods
285
+	 * @type boolean      $hidden_endpoint
286
+	 * }
287
+	 */
288
+	public static function get_ee_route_data()
289
+	{
290
+		$ee_routes = [];
291
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoints) {
292
+			$ee_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = EED_Core_Rest_Api::_get_ee_route_data_for_version(
293
+				$version,
294
+				$hidden_endpoints
295
+			);
296
+		}
297
+		return $ee_routes;
298
+	}
299
+
300
+
301
+	/**
302
+	 * Gets the EE route data from the wp options if it exists already,
303
+	 * otherwise re-generates it and saves it to the option
304
+	 *
305
+	 * @param string  $version
306
+	 * @param boolean $hidden_endpoints
307
+	 * @return array
308
+	 * @throws EE_Error
309
+	 * @throws ReflectionException
310
+	 */
311
+	protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false)
312
+	{
313
+		$ee_routes = get_option(EED_Core_Rest_Api::saved_routes_option_names . $version, null);
314
+		if (! $ee_routes || EED_Core_Rest_Api::debugMode()) {
315
+			$ee_routes = EED_Core_Rest_Api::_save_ee_route_data_for_version($version, $hidden_endpoints);
316
+		}
317
+		return $ee_routes;
318
+	}
319
+
320
+
321
+	/**
322
+	 * Saves the EE REST API route data to a wp option and returns it
323
+	 *
324
+	 * @param string  $version
325
+	 * @param boolean $hidden_endpoints
326
+	 * @return mixed|null
327
+	 * @throws EE_Error
328
+	 * @throws ReflectionException
329
+	 */
330
+	protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false)
331
+	{
332
+		$instance = EED_Core_Rest_Api::instance();
333
+		$routes = apply_filters(
334
+			'EED_Core_Rest_Api__save_ee_route_data_for_version__routes',
335
+			array_replace_recursive(
336
+				$instance->_get_config_route_data_for_version($version, $hidden_endpoints),
337
+				$instance->_get_meta_route_data_for_version($version, $hidden_endpoints),
338
+				$instance->_get_model_route_data_for_version($version, $hidden_endpoints),
339
+				$instance->_get_rpc_route_data_for_version($version, $hidden_endpoints)
340
+			)
341
+		);
342
+		$option_name = EED_Core_Rest_Api::saved_routes_option_names . $version;
343
+		if (get_option($option_name)) {
344
+			update_option($option_name, $routes, true);
345
+		} else {
346
+			add_option($option_name, $routes, null, 'no');
347
+		}
348
+		return $routes;
349
+	}
350
+
351
+
352
+	/**
353
+	 * Calculates all the EE routes and saves it to a WordPress option so we don't
354
+	 * need to calculate it on every request
355
+	 *
356
+	 * @return void
357
+	 * @deprecated since version 4.9.1
358
+	 */
359
+	public static function save_ee_routes()
360
+	{
361
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
362
+			$instance = EED_Core_Rest_Api::instance();
363
+			$routes = apply_filters(
364
+				'EED_Core_Rest_Api__save_ee_routes__routes',
365
+				array_replace_recursive(
366
+					$instance->_register_config_routes(),
367
+					$instance->_register_meta_routes(),
368
+					$instance->_register_model_routes(),
369
+					$instance->_register_rpc_routes()
370
+				)
371
+			);
372
+			update_option(EED_Core_Rest_Api::saved_routes_option_names, $routes, true);
373
+		}
374
+	}
375
+
376
+
377
+	/**
378
+	 * Gets all the route information relating to EE models
379
+	 *
380
+	 * @return array @see get_ee_route_data
381
+	 * @deprecated since version 4.9.1
382
+	 */
383
+	protected function _register_model_routes()
384
+	{
385
+		$model_routes = [];
386
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
387
+			$model_routes[ EED_Core_Rest_Api::ee_api_namespace
388
+						   . $version ] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
389
+		}
390
+		return $model_routes;
391
+	}
392
+
393
+
394
+	/**
395
+	 * Decides whether or not to add write endpoints for this model.
396
+	 * Currently, this defaults to exclude all global tables and models
397
+	 * which would allow inserting WP core data (we don't want to duplicate
398
+	 * what WP API does, as it's unnecessary, extra work, and potentially extra bugs)
399
+	 *
400
+	 * @param EEM_Base $model
401
+	 * @return bool
402
+	 */
403
+	public static function should_have_write_endpoints(EEM_Base $model)
404
+	{
405
+		if ($model->is_wp_core_model()) {
406
+			return false;
407
+		}
408
+		foreach ($model->get_tables() as $table) {
409
+			if ($table->is_global()) {
410
+				return false;
411
+			}
412
+		}
413
+		return true;
414
+	}
415
+
416
+
417
+	/**
418
+	 * Gets the names of all models which should have plural routes (eg `ee/v4.8.36/events`)
419
+	 * in this versioned namespace of EE4
420
+	 *
421
+	 * @param $version
422
+	 * @return array keys are model names (eg 'Event') and values ar either classnames (eg 'EEM_Event')
423
+	 */
424
+	public static function model_names_with_plural_routes($version)
425
+	{
426
+		$model_version_info = new ModelVersionInfo($version);
427
+		$models_to_register = $model_version_info->modelsForRequestedVersion();
428
+		// let's not bother having endpoints for extra metas
429
+		unset(
430
+			$models_to_register['Extra_Meta'],
431
+			$models_to_register['Extra_Join'],
432
+			$models_to_register['Post_Meta']
433
+		);
434
+		return apply_filters(
435
+			'FHEE__EED_Core_REST_API___register_model_routes',
436
+			$models_to_register
437
+		);
438
+	}
439
+
440
+
441
+	/**
442
+	 * Gets the route data for EE models in the specified version
443
+	 *
444
+	 * @param string  $version
445
+	 * @param boolean $hidden_endpoint
446
+	 * @return array
447
+	 * @throws EE_Error
448
+	 * @throws ReflectionException
449
+	 */
450
+	protected function _get_model_route_data_for_version($version, $hidden_endpoint = false)
451
+	{
452
+		$model_routes = [];
453
+		$model_version_info = new ModelVersionInfo($version);
454
+		foreach (EED_Core_Rest_Api::model_names_with_plural_routes($version) as $model_name => $model_classname) {
455
+			$model = EE_Registry::instance()->load_model($model_name);
456
+			// if this isn't a valid model then let's skip iterate to the next item in the loop.
457
+			if (! $model instanceof EEM_Base) {
458
+				continue;
459
+			}
460
+			// yes we could just register one route for ALL models, but then they wouldn't show up in the index
461
+			$plural_model_route = EED_Core_Rest_Api::get_collection_route($model);
462
+			$singular_model_route = EED_Core_Rest_Api::get_entity_route($model, '(?P<id>[^\/]+)');
463
+			$model_routes[ $plural_model_route ] = [
464
+				[
465
+					'callback'        => [
466
+						'EventEspresso\core\libraries\rest_api\controllers\model\Read',
467
+						'handleRequestGetAll',
468
+					],
469
+					'callback_args'   => [$version, $model_name],
470
+					'methods'         => WP_REST_Server::READABLE,
471
+					'hidden_endpoint' => $hidden_endpoint,
472
+					'args'            => $this->_get_read_query_params($model, $version),
473
+					'_links'          => [
474
+						'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route),
475
+					],
476
+				],
477
+				'schema' => [
478
+					'schema_callback' => [
479
+						'EventEspresso\core\libraries\rest_api\controllers\model\Read',
480
+						'handleSchemaRequest',
481
+					],
482
+					'callback_args'   => [$version, $model_name],
483
+				],
484
+			];
485
+			$model_routes[ $singular_model_route ] = [
486
+				[
487
+					'callback'        => [
488
+						'EventEspresso\core\libraries\rest_api\controllers\model\Read',
489
+						'handleRequestGetOne',
490
+					],
491
+					'callback_args'   => [$version, $model_name],
492
+					'methods'         => WP_REST_Server::READABLE,
493
+					'hidden_endpoint' => $hidden_endpoint,
494
+					'args'            => $this->_get_response_selection_query_params($model, $version, true),
495
+				],
496
+			];
497
+			if (apply_filters(
498
+				'FHEE__EED_Core_Rest_Api___get_model_route_data_for_version__add_write_endpoints',
499
+				EED_Core_Rest_Api::should_have_write_endpoints($model),
500
+				$model
501
+			)) {
502
+				$model_routes[ $plural_model_route ][] = [
503
+					'callback'        => [
504
+						'EventEspresso\core\libraries\rest_api\controllers\model\Write',
505
+						'handleRequestInsert',
506
+					],
507
+					'callback_args'   => [$version, $model_name],
508
+					'methods'         => WP_REST_Server::CREATABLE,
509
+					'hidden_endpoint' => $hidden_endpoint,
510
+					'args'            => $this->_get_write_params($model_name, $model_version_info, true),
511
+				];
512
+				$model_routes[ $singular_model_route ] = array_merge(
513
+					$model_routes[ $singular_model_route ],
514
+					[
515
+						[
516
+							'callback'        => [
517
+								'EventEspresso\core\libraries\rest_api\controllers\model\Write',
518
+								'handleRequestUpdate',
519
+							],
520
+							'callback_args'   => [$version, $model_name],
521
+							'methods'         => WP_REST_Server::EDITABLE,
522
+							'hidden_endpoint' => $hidden_endpoint,
523
+							'args'            => $this->_get_write_params($model_name, $model_version_info),
524
+						],
525
+						[
526
+							'callback'        => [
527
+								'EventEspresso\core\libraries\rest_api\controllers\model\Write',
528
+								'handleRequestDelete',
529
+							],
530
+							'callback_args'   => [$version, $model_name],
531
+							'methods'         => WP_REST_Server::DELETABLE,
532
+							'hidden_endpoint' => $hidden_endpoint,
533
+							'args'            => $this->_get_delete_query_params($model, $version),
534
+						],
535
+					]
536
+				);
537
+			}
538
+			foreach ($model->relation_settings() as $relation_name => $relation_obj) {
539
+				$related_route = EED_Core_Rest_Api::get_relation_route_via(
540
+					$model,
541
+					'(?P<id>[^\/]+)',
542
+					$relation_obj
543
+				);
544
+				$model_routes[ $related_route ] = [
545
+					[
546
+						'callback'        => [
547
+							'EventEspresso\core\libraries\rest_api\controllers\model\Read',
548
+							'handleRequestGetRelated',
549
+						],
550
+						'callback_args'   => [$version, $model_name, $relation_name],
551
+						'methods'         => WP_REST_Server::READABLE,
552
+						'hidden_endpoint' => $hidden_endpoint,
553
+						'args'            => $this->_get_read_query_params($relation_obj->get_other_model(), $version),
554
+					],
555
+				];
556
+
557
+				$related_write_route = $related_route . '/' . '(?P<related_id>[^\/]+)';
558
+				$model_routes[ $related_write_route ] = [
559
+					[
560
+						'callback'        => [
561
+							'EventEspresso\core\libraries\rest_api\controllers\model\Write',
562
+							'handleRequestAddRelation',
563
+						],
564
+						'callback_args'   => [$version, $model_name, $relation_name],
565
+						'methods'         => WP_REST_Server::EDITABLE,
566
+						'hidden_endpoint' => $hidden_endpoint,
567
+						'args'            => $this->_get_add_relation_query_params($model,
568
+							$relation_obj->get_other_model(), $version),
569
+					],
570
+					[
571
+						'callback'        => [
572
+							'EventEspresso\core\libraries\rest_api\controllers\model\Write',
573
+							'handleRequestRemoveRelation',
574
+						],
575
+						'callback_args'   => [$version, $model_name, $relation_name],
576
+						'methods'         => WP_REST_Server::DELETABLE,
577
+						'hidden_endpoint' => $hidden_endpoint,
578
+						'args'            => [],
579
+					],
580
+				];
581
+			}
582
+		}
583
+		return $model_routes;
584
+	}
585
+
586
+
587
+	/**
588
+	 * Gets the relative URI to a model's REST API plural route, after the EE4 versioned namespace,
589
+	 * excluding the preceding slash.
590
+	 * Eg you pass get_plural_route_to('Event') = 'events'
591
+	 *
592
+	 * @param EEM_Base $model
593
+	 * @return string
594
+	 */
595
+	public static function get_collection_route(EEM_Base $model)
596
+	{
597
+		return EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
598
+	}
599
+
600
+
601
+	/**
602
+	 * Gets the relative URI to a model's REST API singular route, after the EE4 versioned namespace,
603
+	 * excluding the preceding slash.
604
+	 * Eg you pass get_plural_route_to('Event', 12) = 'events/12'
605
+	 *
606
+	 * @param EEM_Base $model eg Event or Venue
607
+	 * @param string   $id
608
+	 * @return string
609
+	 */
610
+	public static function get_entity_route($model, $id)
611
+	{
612
+		return EED_Core_Rest_Api::get_collection_route($model) . '/' . $id;
613
+	}
614
+
615
+
616
+	/**
617
+	 * Gets the relative URI to a model's REST API singular route, after the EE4 versioned namespace,
618
+	 * excluding the preceding slash.
619
+	 * Eg you pass get_plural_route_to('Event', 12) = 'events/12'
620
+	 *
621
+	 * @param EEM_Base               $model eg Event or Venue
622
+	 * @param string                 $id
623
+	 * @param EE_Model_Relation_Base $relation_obj
624
+	 * @return string
625
+	 */
626
+	public static function get_relation_route_via(EEM_Base $model, $id, EE_Model_Relation_Base $relation_obj)
627
+	{
628
+		$related_model_name_endpoint_part = ModelRead::getRelatedEntityName(
629
+			$relation_obj->get_other_model()->get_this_model_name(),
630
+			$relation_obj
631
+		);
632
+		return EED_Core_Rest_Api::get_entity_route($model, $id) . '/' . $related_model_name_endpoint_part;
633
+	}
634
+
635
+
636
+	/**
637
+	 * Adds onto the $relative_route the EE4 REST API versioned namespace.
638
+	 * Eg if given '4.8.36' and 'events', will return 'ee/v4.8.36/events'
639
+	 *
640
+	 * @param string $relative_route
641
+	 * @param string $version
642
+	 * @return string
643
+	 */
644
+	public static function get_versioned_route_to($relative_route, $version = '4.8.36')
645
+	{
646
+		return '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/' . $relative_route;
647
+	}
648
+
649
+
650
+	/**
651
+	 * Adds all the RPC-style routes (remote procedure call-like routes, ie
652
+	 * routes that don't conform to the traditional REST CRUD-style).
653
+	 *
654
+	 * @deprecated since 4.9.1
655
+	 */
656
+	protected function _register_rpc_routes()
657
+	{
658
+		$routes = [];
659
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
660
+			$routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version(
661
+				$version,
662
+				$hidden_endpoint
663
+			);
664
+		}
665
+		return $routes;
666
+	}
667
+
668
+
669
+	/**
670
+	 * @param string  $version
671
+	 * @param boolean $hidden_endpoint
672
+	 * @return array
673
+	 */
674
+	protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false)
675
+	{
676
+		$this_versions_routes = [];
677
+		// checkin endpoint
678
+		$this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = [
679
+			[
680
+				'callback'        => [
681
+					'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
682
+					'handleRequestToggleCheckin',
683
+				],
684
+				'methods'         => WP_REST_Server::CREATABLE,
685
+				'hidden_endpoint' => $hidden_endpoint,
686
+				'args'            => [
687
+					'force' => [
688
+						'required'    => false,
689
+						'default'     => false,
690
+						'description' => __(
691
+						// @codingStandardsIgnoreStart
692
+							'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses',
693
+							// @codingStandardsIgnoreEnd
694
+							'event_espresso'
695
+						),
696
+					],
697
+				],
698
+				'callback_args'   => [$version],
699
+			],
700
+		];
701
+		return apply_filters(
702
+			'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
703
+			$this_versions_routes,
704
+			$version,
705
+			$hidden_endpoint
706
+		);
707
+	}
708
+
709
+
710
+	/**
711
+	 * Gets the query params that can be used when request one or many
712
+	 *
713
+	 * @param EEM_Base $model
714
+	 * @param string   $version
715
+	 * @return array
716
+	 */
717
+	protected function _get_response_selection_query_params(EEM_Base $model, $version, $single_only = false)
718
+	{
719
+		$query_params = [
720
+			'include'   => [
721
+				'required' => false,
722
+				'default'  => '*',
723
+				'type'     => 'string',
724
+			],
725
+			'calculate' => [
726
+				'required'          => false,
727
+				'default'           => '',
728
+				'enum'              => EED_Core_Rest_Api::$_field_calculator->retrieveCalculatedFieldsForModel($model),
729
+				'type'              => 'string',
730
+				// because we accept a CSV'd list of the enumerated strings, WP core validation and sanitization
731
+				// freaks out. We'll just validate this argument while handling the request
732
+				'validate_callback' => null,
733
+				'sanitize_callback' => null,
734
+			],
735
+			'password'  => [
736
+				'required' => false,
737
+				'default'  => '',
738
+				'type'     => 'string',
739
+			],
740
+		];
741
+		return apply_filters(
742
+			'FHEE__EED_Core_Rest_Api___get_response_selection_query_params',
743
+			$query_params,
744
+			$model,
745
+			$version
746
+		);
747
+	}
748
+
749
+
750
+	/**
751
+	 * Gets the parameters acceptable for delete requests
752
+	 *
753
+	 * @param EEM_Base $model
754
+	 * @param string   $version
755
+	 * @return array
756
+	 */
757
+	protected function _get_delete_query_params(EEM_Base $model, $version)
758
+	{
759
+		$params_for_delete = [
760
+			'allow_blocking' => [
761
+				'required' => false,
762
+				'default'  => true,
763
+				'type'     => 'boolean',
764
+			],
765
+		];
766
+		$params_for_delete['force'] = [
767
+			'required' => false,
768
+			'default'  => false,
769
+			'type'     => 'boolean',
770
+		];
771
+		return apply_filters(
772
+			'FHEE__EED_Core_Rest_Api___get_delete_query_params',
773
+			$params_for_delete,
774
+			$model,
775
+			$version
776
+		);
777
+	}
778
+
779
+
780
+	/**
781
+	 * @param EEM_Base $source_model
782
+	 * @param EEM_Base $related_model
783
+	 * @param          $version
784
+	 * @return array
785
+	 * @throws EE_Error
786
+	 * @since $VID:$
787
+	 */
788
+	protected function _get_add_relation_query_params(EEM_Base $source_model, EEM_Base $related_model, $version)
789
+	{
790
+		// if they're related through a HABTM relation, check for any non-FKs
791
+		$all_relation_settings = $source_model->relation_settings();
792
+		$relation_settings = $all_relation_settings[ $related_model->get_this_model_name() ];
793
+		$params = [];
794
+		if ($relation_settings instanceof EE_HABTM_Relation && $relation_settings->hasNonKeyFields()) {
795
+			foreach ($relation_settings->getNonKeyFields() as $field) {
796
+				/* @var $field EE_Model_Field_Base */
797
+				$params[ $field->get_name() ] = [
798
+					'required'          => ! $field->is_nullable(),
799
+					'default'           => ModelDataTranslator::prepareFieldValueForJson($field,
800
+						$field->get_default_value(), $version),
801
+					'type'              => $field->getSchemaType(),
802
+					'validate_callback' => null,
803
+					'sanitize_callback' => null,
804
+				];
805
+			}
806
+		}
807
+		return $params;
808
+	}
809
+
810
+
811
+	/**
812
+	 * Gets info about reading query params that are acceptable
813
+	 *
814
+	 * @param EEM_Base $model eg 'Event' or 'Venue'
815
+	 * @param string   $version
816
+	 * @return array    describing the args acceptable when querying this model
817
+	 * @throws EE_Error
818
+	 */
819
+	protected function _get_read_query_params(EEM_Base $model, $version)
820
+	{
821
+		$default_orderby = [];
822
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
823
+			$default_orderby[ $key_field->get_name() ] = 'ASC';
824
+		}
825
+		return array_merge(
826
+			$this->_get_response_selection_query_params($model, $version),
827
+			[
828
+				'where'    => [
829
+					'required'          => false,
830
+					'default'           => [],
831
+					'type'              => 'object',
832
+					// because we accept an almost infinite list of possible where conditions, WP
833
+					// core validation and sanitization freaks out. We'll just validate this argument
834
+					// while handling the request
835
+					'validate_callback' => null,
836
+					'sanitize_callback' => null,
837
+				],
838
+				'limit'    => [
839
+					'required'          => false,
840
+					'default'           => EED_Core_Rest_Api::get_default_query_limit(),
841
+					'type'              => [
842
+						'array',
843
+						'string',
844
+						'integer',
845
+					],
846
+					// because we accept a variety of types, WP core validation and sanitization
847
+					// freaks out. We'll just validate this argument while handling the request
848
+					'validate_callback' => null,
849
+					'sanitize_callback' => null,
850
+				],
851
+				'order_by' => [
852
+					'required'          => false,
853
+					'default'           => $default_orderby,
854
+					'type'              => [
855
+						'object',
856
+						'string',
857
+					],// because we accept a variety of types, WP core validation and sanitization
858
+					// freaks out. We'll just validate this argument while handling the request
859
+					'validate_callback' => null,
860
+					'sanitize_callback' => null,
861
+				],
862
+				'group_by' => [
863
+					'required'          => false,
864
+					'default'           => null,
865
+					'type'              => [
866
+						'object',
867
+						'string',
868
+					],
869
+					// because we accept  an almost infinite list of possible groupings,
870
+					// WP core validation and sanitization
871
+					// freaks out. We'll just validate this argument while handling the request
872
+					'validate_callback' => null,
873
+					'sanitize_callback' => null,
874
+				],
875
+				'having'   => [
876
+					'required'          => false,
877
+					'default'           => null,
878
+					'type'              => 'object',
879
+					// because we accept an almost infinite list of possible where conditions, WP
880
+					// core validation and sanitization freaks out. We'll just validate this argument
881
+					// while handling the request
882
+					'validate_callback' => null,
883
+					'sanitize_callback' => null,
884
+				],
885
+				'caps'     => [
886
+					'required' => false,
887
+					'default'  => EEM_Base::caps_read,
888
+					'type'     => 'string',
889
+					'enum'     => [
890
+						EEM_Base::caps_read,
891
+						EEM_Base::caps_read_admin,
892
+						EEM_Base::caps_edit,
893
+						EEM_Base::caps_delete,
894
+					],
895
+				],
896
+			]
897
+		);
898
+	}
899
+
900
+
901
+	/**
902
+	 * Gets parameter information for a model regarding writing data
903
+	 *
904
+	 * @param string           $model_name
905
+	 * @param ModelVersionInfo $model_version_info
906
+	 * @param boolean          $create                                       whether this is for request to create (in
907
+	 *                                                                       which case we need all required params) or
908
+	 *                                                                       just to update (in which case we don't
909
+	 *                                                                       need those on every request)
910
+	 * @return array
911
+	 * @throws EE_Error
912
+	 * @throws ReflectionException
913
+	 */
914
+	protected function _get_write_params(
915
+		$model_name,
916
+		ModelVersionInfo $model_version_info,
917
+		$create = false
918
+	) {
919
+		$model = EE_Registry::instance()->load_model($model_name);
920
+		$fields = $model_version_info->fieldsOnModelInThisVersion($model);
921
+
922
+		// we do our own validation and sanitization within the controller
923
+		$sanitize_callback = function_exists('rest_validate_value_from_schema')
924
+			? ['EED_Core_Rest_Api', 'default_sanitize_callback']
925
+			: null;
926
+		$args_info = [];
927
+		foreach ($fields as $field_name => $field_obj) {
928
+			if ($field_obj->is_auto_increment()) {
929
+				// totally ignore auto increment IDs
930
+				continue;
931
+			}
932
+			$arg_info = $field_obj->getSchema();
933
+			$required = $create && ! $field_obj->is_nullable() && $field_obj->get_default_value() === null;
934
+			$arg_info['required'] = $required;
935
+			// remove the read-only flag. If it were read-only we wouldn't list it as an argument while writing, right?
936
+			unset($arg_info['readonly']);
937
+			$schema_properties = $field_obj->getSchemaProperties();
938
+			if (isset($schema_properties['raw'])
939
+				&& $field_obj->getSchemaType() === 'object'
940
+			) {
941
+				// if there's a "raw" form of this argument, use those properties instead
942
+				$arg_info = array_replace(
943
+					$arg_info,
944
+					$schema_properties['raw']
945
+				);
946
+			}
947
+			$arg_info['default'] = ModelDataTranslator::prepareFieldValueForJson(
948
+				$field_obj,
949
+				$field_obj->get_default_value(),
950
+				$model_version_info->requestedVersion()
951
+			);
952
+			$arg_info['sanitize_callback'] = $sanitize_callback;
953
+			$args_info[ $field_name ] = $arg_info;
954
+			if ($field_obj instanceof EE_Datetime_Field) {
955
+				$gmt_arg_info = $arg_info;
956
+				$gmt_arg_info['description'] = sprintf(
957
+					esc_html__(
958
+						'%1$s - the value for this field in UTC. Ignored if %2$s is provided.',
959
+						'event_espresso'
960
+					),
961
+					$field_obj->get_nicename(),
962
+					$field_name
963
+				);
964
+				$args_info[ $field_name . '_gmt' ] = $gmt_arg_info;
965
+			}
966
+		}
967
+		return $args_info;
968
+	}
969
+
970
+
971
+	/**
972
+	 * Replacement for WP API's 'rest_parse_request_arg'.
973
+	 * If the value is blank but not required, don't bother validating it.
974
+	 * Also, it uses our email validation instead of WP API's default.
975
+	 *
976
+	 * @param                 $value
977
+	 * @param WP_REST_Request $request
978
+	 * @param                 $param
979
+	 * @return bool|true|WP_Error
980
+	 * @throws InvalidArgumentException
981
+	 * @throws InvalidInterfaceException
982
+	 * @throws InvalidDataTypeException
983
+	 */
984
+	public static function default_sanitize_callback($value, WP_REST_Request $request, $param)
985
+	{
986
+		$attributes = $request->get_attributes();
987
+		if (! isset($attributes['args'][ $param ])
988
+			|| ! is_array($attributes['args'][ $param ])) {
989
+			$validation_result = true;
990
+		} else {
991
+			$args = $attributes['args'][ $param ];
992
+			if ((
993
+					$value === ''
994
+					|| $value === null
995
+				)
996
+				&& (! isset($args['required'])
997
+					|| $args['required'] === false
998
+				)
999
+			) {
1000
+				// not required and not provided? that's cool
1001
+				$validation_result = true;
1002
+			} elseif (isset($args['format'])
1003
+					  && $args['format'] === 'email'
1004
+			) {
1005
+				$validation_result = true;
1006
+				if (! EED_Core_Rest_Api::_validate_email($value)) {
1007
+					$validation_result = new WP_Error(
1008
+						'rest_invalid_param',
1009
+						esc_html__(
1010
+							'The email address is not valid or does not exist.',
1011
+							'event_espresso'
1012
+						)
1013
+					);
1014
+				}
1015
+			} else {
1016
+				$validation_result = rest_validate_value_from_schema($value, $args, $param);
1017
+			}
1018
+		}
1019
+		if (is_wp_error($validation_result)) {
1020
+			return $validation_result;
1021
+		}
1022
+		return rest_sanitize_request_arg($value, $request, $param);
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * Returns whether or not this email address is valid. Copied from EE_Email_Validation_Strategy::_validate_email()
1028
+	 *
1029
+	 * @param $email
1030
+	 * @return bool
1031
+	 * @throws InvalidArgumentException
1032
+	 * @throws InvalidInterfaceException
1033
+	 * @throws InvalidDataTypeException
1034
+	 */
1035
+	protected static function _validate_email($email)
1036
+	{
1037
+		try {
1038
+			EmailAddressFactory::create($email);
1039
+			return true;
1040
+		} catch (EmailValidationException $e) {
1041
+			return false;
1042
+		}
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 * Gets routes for the config
1048
+	 *
1049
+	 * @return array @see _register_model_routes
1050
+	 * @deprecated since version 4.9.1
1051
+	 */
1052
+	protected function _register_config_routes()
1053
+	{
1054
+		$config_routes = [];
1055
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1056
+			$config_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version(
1057
+				$version,
1058
+				$hidden_endpoint
1059
+			);
1060
+		}
1061
+		return $config_routes;
1062
+	}
1063
+
1064
+
1065
+	/**
1066
+	 * Gets routes for the config for the specified version
1067
+	 *
1068
+	 * @param string  $version
1069
+	 * @param boolean $hidden_endpoint
1070
+	 * @return array
1071
+	 */
1072
+	protected function _get_config_route_data_for_version($version, $hidden_endpoint)
1073
+	{
1074
+		return [
1075
+			'config'    => [
1076
+				[
1077
+					'callback'        => [
1078
+						'EventEspresso\core\libraries\rest_api\controllers\config\Read',
1079
+						'handleRequest',
1080
+					],
1081
+					'methods'         => WP_REST_Server::READABLE,
1082
+					'hidden_endpoint' => $hidden_endpoint,
1083
+					'callback_args'   => [$version],
1084
+				],
1085
+			],
1086
+			'site_info' => [
1087
+				[
1088
+					'callback'        => [
1089
+						'EventEspresso\core\libraries\rest_api\controllers\config\Read',
1090
+						'handleRequestSiteInfo',
1091
+					],
1092
+					'methods'         => WP_REST_Server::READABLE,
1093
+					'hidden_endpoint' => $hidden_endpoint,
1094
+					'callback_args'   => [$version],
1095
+				],
1096
+			],
1097
+		];
1098
+	}
1099
+
1100
+
1101
+	/**
1102
+	 * Gets the meta info routes
1103
+	 *
1104
+	 * @return array @see _register_model_routes
1105
+	 * @deprecated since version 4.9.1
1106
+	 */
1107
+	protected function _register_meta_routes()
1108
+	{
1109
+		$meta_routes = [];
1110
+		foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1111
+			$meta_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version(
1112
+				$version,
1113
+				$hidden_endpoint
1114
+			);
1115
+		}
1116
+		return $meta_routes;
1117
+	}
1118
+
1119
+
1120
+	/**
1121
+	 * @param string  $version
1122
+	 * @param boolean $hidden_endpoint
1123
+	 * @return array
1124
+	 */
1125
+	protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false)
1126
+	{
1127
+		return [
1128
+			'resources' => [
1129
+				[
1130
+					'callback'        => [
1131
+						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
1132
+						'handleRequestModelsMeta',
1133
+					],
1134
+					'methods'         => WP_REST_Server::READABLE,
1135
+					'hidden_endpoint' => $hidden_endpoint,
1136
+					'callback_args'   => [$version],
1137
+				],
1138
+			],
1139
+		];
1140
+	}
1141
+
1142
+
1143
+	/**
1144
+	 * Tries to hide old 4.6 endpoints from the
1145
+	 *
1146
+	 * @param array $route_data
1147
+	 * @return array
1148
+	 * @throws EE_Error
1149
+	 * @throws ReflectionException
1150
+	 */
1151
+	public static function hide_old_endpoints($route_data)
1152
+	{
1153
+		// allow API clients to override which endpoints get hidden, in case
1154
+		// they want to discover particular endpoints
1155
+		// also, we don't have access to the request so we have to just grab it from the superglobal
1156
+		$force_show_ee_namespace = ltrim(
1157
+			EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''),
1158
+			'/'
1159
+		);
1160
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
1161
+			foreach ($relative_urls as $resource_name => $endpoints) {
1162
+				foreach ($endpoints as $key => $endpoint) {
1163
+					// skip schema and other route options
1164
+					if (! is_numeric($key)) {
1165
+						continue;
1166
+					}
1167
+					// by default, hide "hidden_endpoint"s, unless the request indicates
1168
+					// to $force_show_ee_namespace, in which case only show that one
1169
+					// namespace's endpoints (and hide all others)
1170
+					if (($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace)
1171
+						|| ($endpoint['hidden_endpoint'] && $force_show_ee_namespace === '')
1172
+					) {
1173
+						$full_route = '/' . ltrim($namespace, '/');
1174
+						$full_route .= '/' . ltrim($resource_name, '/');
1175
+						unset($route_data[ $full_route ]);
1176
+					}
1177
+				}
1178
+			}
1179
+		}
1180
+		return $route_data;
1181
+	}
1182
+
1183
+
1184
+	/**
1185
+	 * Returns an array describing which versions of core support serving requests for.
1186
+	 * Keys are core versions' major and minor version, and values are the
1187
+	 * LOWEST requested version they can serve. Eg, 4.7 can serve requests for 4.6-like
1188
+	 * data by just removing a few models and fields from the responses. However, 4.15 might remove
1189
+	 * the answers table entirely, in which case it would be very difficult for
1190
+	 * it to serve 4.6-style responses.
1191
+	 * Versions of core that are missing from this array are unknowns.
1192
+	 * previous ver
1193
+	 *
1194
+	 * @return array
1195
+	 */
1196
+	public static function version_compatibilities()
1197
+	{
1198
+		return apply_filters(
1199
+			'FHEE__EED_Core_REST_API__version_compatibilities',
1200
+			[
1201
+				'4.8.29' => '4.8.29',
1202
+				'4.8.33' => '4.8.29',
1203
+				'4.8.34' => '4.8.29',
1204
+				'4.8.36' => '4.8.29',
1205
+			]
1206
+		);
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * Gets the latest API version served. Eg if there
1212
+	 * are two versions served of the API, 4.8.29 and 4.8.32, and
1213
+	 * we are on core version 4.8.34, it will return the string "4.8.32"
1214
+	 *
1215
+	 * @return string
1216
+	 */
1217
+	public static function latest_rest_api_version()
1218
+	{
1219
+		$versions_served = EED_Core_Rest_Api::versions_served();
1220
+		$versions_served_keys = array_keys($versions_served);
1221
+		return end($versions_served_keys);
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * Using EED_Core_Rest_Api::version_compatibilities(), determines what version of
1227
+	 * EE the API can serve requests for. Eg, if we are on 4.15 of core, and
1228
+	 * we can serve requests from 4.12 or later, this will return array( '4.12', '4.13', '4.14', '4.15' ).
1229
+	 * We also indicate whether or not this version should be put in the index or not
1230
+	 *
1231
+	 * @return array keys are API version numbers (just major and minor numbers), and values
1232
+	 * are whether or not they should be hidden
1233
+	 */
1234
+	public static function versions_served()
1235
+	{
1236
+		$versions_served = [];
1237
+		$possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
1238
+		$lowest_compatible_version = end($possibly_served_versions);
1239
+		reset($possibly_served_versions);
1240
+		$versions_served_historically = array_keys($possibly_served_versions);
1241
+		$latest_version = end($versions_served_historically);
1242
+		reset($versions_served_historically);
1243
+		// for each version of core we have ever served:
1244
+		foreach ($versions_served_historically as $key_versioned_endpoint) {
1245
+			// if it's not above the current core version, and it's compatible with the current version of core
1246
+
1247
+			if ($key_versioned_endpoint === $latest_version) {
1248
+				// don't hide the latest version in the index
1249
+				$versions_served[ $key_versioned_endpoint ] = false;
1250
+			} elseif (version_compare($key_versioned_endpoint, $lowest_compatible_version, '>=')
1251
+					  && version_compare($key_versioned_endpoint, EED_Core_Rest_Api::core_version(), '<')
1252
+			) {
1253
+				// include, but hide, previous versions which are still supported
1254
+				$versions_served[ $key_versioned_endpoint ] = true;
1255
+			} elseif (apply_filters(
1256
+				'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
1257
+				false,
1258
+				$possibly_served_versions
1259
+			)) {
1260
+				// if a version is no longer supported, don't include it in index or list of versions served
1261
+				$versions_served[ $key_versioned_endpoint ] = true;
1262
+			}
1263
+		}
1264
+		return $versions_served;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * Gets the major and minor version of EE core's version string
1270
+	 *
1271
+	 * @return string
1272
+	 */
1273
+	public static function core_version()
1274
+	{
1275
+		return apply_filters(
1276
+			'FHEE__EED_Core_REST_API__core_version',
1277
+			implode(
1278
+				'.',
1279
+				array_slice(
1280
+					explode(
1281
+						'.',
1282
+						espresso_version()
1283
+					),
1284
+					0,
1285
+					3
1286
+				)
1287
+			)
1288
+		);
1289
+	}
1290
+
1291
+
1292
+	/**
1293
+	 * Gets the default limit that should be used when querying for resources
1294
+	 *
1295
+	 * @return int
1296
+	 */
1297
+	public static function get_default_query_limit()
1298
+	{
1299
+		// we actually don't use a const because we want folks to always use
1300
+		// this method, not the const directly
1301
+		return apply_filters(
1302
+			'FHEE__EED_Core_Rest_Api__get_default_query_limit',
1303
+			50
1304
+		);
1305
+	}
1306
+
1307
+
1308
+	/**
1309
+	 * @param string $version api version string (i.e. '4.8.36')
1310
+	 * @return array
1311
+	 */
1312
+	public static function getCollectionRoutesIndexedByModelName($version = '')
1313
+	{
1314
+		$version = empty($version) ? EED_Core_Rest_Api::latest_rest_api_version() : $version;
1315
+		$model_names = EED_Core_Rest_Api::model_names_with_plural_routes($version);
1316
+		$collection_routes = [];
1317
+		foreach ($model_names as $model_name => $model_class_name) {
1318
+			$collection_routes[ strtolower($model_name) ] = '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/'
1319
+															. EEH_Inflector::pluralize_and_lower($model_name);
1320
+		}
1321
+		return $collection_routes;
1322
+	}
1323
+
1324
+
1325
+	/**
1326
+	 * Returns an array of primary key names indexed by model names.
1327
+	 *
1328
+	 * @param string $version
1329
+	 * @return array
1330
+	 */
1331
+	public static function getPrimaryKeyNamesIndexedByModelName($version = '')
1332
+	{
1333
+		$version = empty($version) ? EED_Core_Rest_Api::latest_rest_api_version() : $version;
1334
+		$model_names = EED_Core_Rest_Api::model_names_with_plural_routes($version);
1335
+		$primary_key_items = [];
1336
+		foreach ($model_names as $model_name => $model_class_name) {
1337
+			$primary_keys = $model_class_name::instance()->get_combined_primary_key_fields();
1338
+			foreach ($primary_keys as $primary_key_name => $primary_key_field) {
1339
+				if (count($primary_keys) > 1) {
1340
+					$primary_key_items[ strtolower($model_name) ][] = $primary_key_name;
1341
+				} else {
1342
+					$primary_key_items[ strtolower($model_name) ] = $primary_key_name;
1343
+				}
1344
+			}
1345
+		}
1346
+		return $primary_key_items;
1347
+	}
1348
+
1349
+
1350
+	/**
1351
+	 * Determines the EE REST API debug mode is activated, or not.
1352
+	 *
1353
+	 * @return bool
1354
+	 * @since 4.9.76.p
1355
+	 */
1356
+	public static function debugMode()
1357
+	{
1358
+		static $debug_mode = null; // could be class prop
1359
+		if ($debug_mode === null) {
1360
+			$debug_mode = defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE;
1361
+		}
1362
+		return $debug_mode;
1363
+	}
1364
+
1365
+
1366
+	/**
1367
+	 *    run - initial module setup
1368
+	 *
1369
+	 * @access    public
1370
+	 * @param WP $WP
1371
+	 * @return    void
1372
+	 */
1373
+	public function run($WP)
1374
+	{
1375
+	}
1376 1376
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         /** @var EventEspresso\core\services\request\Request $request */
80 80
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
81
-        if (! $request->isWordPressApi()) {
81
+        if ( ! $request->isWordPressApi()) {
82 82
             return;
83 83
         }
84 84
         add_action('rest_api_init', ['EED_Core_Rest_Api', 'register_routes'], 10);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected static function _set_hooks_for_changes()
131 131
     {
132
-        $folder_contents = EEH_File::get_contents_of_folders([EE_LIBRARIES . 'rest_api/changes'], false);
132
+        $folder_contents = EEH_File::get_contents_of_folders([EE_LIBRARIES.'rest_api/changes'], false);
133 133
         foreach ($folder_contents as $classname_in_namespace => $filepath) {
134 134
             // ignore the base parent class
135 135
             // and legacy named classes
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             ) {
139 139
                 continue;
140 140
             }
141
-            $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
141
+            $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace;
142 142
             if (class_exists($full_classname)) {
143 143
                 $instance_of_class = new $full_classname;
144 144
                 if ($instance_of_class instanceof ChangesInBase) {
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
                      * }
185 185
                      */
186 186
                     // skip route options
187
-                    if (! is_numeric($endpoint_key)) {
187
+                    if ( ! is_numeric($endpoint_key)) {
188 188
                         continue;
189 189
                     }
190
-                    if (! isset($data_for_single_endpoint['callback'], $data_for_single_endpoint['methods'])) {
190
+                    if ( ! isset($data_for_single_endpoint['callback'], $data_for_single_endpoint['methods'])) {
191 191
                         throw new EE_Error(
192 192
                             esc_html__(
193 193
                             // @codingStandardsIgnoreStart
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
                     }
209 209
                     if (isset($data_for_single_endpoint['callback_args'])) {
210 210
                         $callback_args = $data_for_single_endpoint['callback_args'];
211
-                        $single_endpoint_args['callback'] = static function (WP_REST_Request $request) use (
211
+                        $single_endpoint_args['callback'] = static function(WP_REST_Request $request) use (
212 212
                             $callback,
213 213
                             $callback_args
214 214
                         ) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                     $schema_route_data = $data_for_multiple_endpoints['schema'];
228 228
                     $schema_callback = $schema_route_data['schema_callback'];
229 229
                     $callback_args = $schema_route_data['callback_args'];
230
-                    $multiple_endpoint_args['schema'] = static function () use ($schema_callback, $callback_args) {
230
+                    $multiple_endpoint_args['schema'] = static function() use ($schema_callback, $callback_args) {
231 231
                         return call_user_func_array(
232 232
                             $schema_callback,
233 233
                             $callback_args
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     {
270 270
         // delete the saved EE REST API routes
271 271
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) {
272
-            delete_option(EED_Core_Rest_Api::saved_routes_option_names . $version);
272
+            delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version);
273 273
         }
274 274
     }
275 275
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $ee_routes = [];
291 291
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoints) {
292
-            $ee_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = EED_Core_Rest_Api::_get_ee_route_data_for_version(
292
+            $ee_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = EED_Core_Rest_Api::_get_ee_route_data_for_version(
293 293
                 $version,
294 294
                 $hidden_endpoints
295 295
             );
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
      */
311 311
     protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false)
312 312
     {
313
-        $ee_routes = get_option(EED_Core_Rest_Api::saved_routes_option_names . $version, null);
314
-        if (! $ee_routes || EED_Core_Rest_Api::debugMode()) {
313
+        $ee_routes = get_option(EED_Core_Rest_Api::saved_routes_option_names.$version, null);
314
+        if ( ! $ee_routes || EED_Core_Rest_Api::debugMode()) {
315 315
             $ee_routes = EED_Core_Rest_Api::_save_ee_route_data_for_version($version, $hidden_endpoints);
316 316
         }
317 317
         return $ee_routes;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
                 $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints)
340 340
             )
341 341
         );
342
-        $option_name = EED_Core_Rest_Api::saved_routes_option_names . $version;
342
+        $option_name = EED_Core_Rest_Api::saved_routes_option_names.$version;
343 343
         if (get_option($option_name)) {
344 344
             update_option($option_name, $routes, true);
345 345
         } else {
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
     {
385 385
         $model_routes = [];
386 386
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
387
-            $model_routes[ EED_Core_Rest_Api::ee_api_namespace
388
-                           . $version ] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
387
+            $model_routes[EED_Core_Rest_Api::ee_api_namespace
388
+                           . $version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint);
389 389
         }
390 390
         return $model_routes;
391 391
     }
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
         foreach (EED_Core_Rest_Api::model_names_with_plural_routes($version) as $model_name => $model_classname) {
455 455
             $model = EE_Registry::instance()->load_model($model_name);
456 456
             // if this isn't a valid model then let's skip iterate to the next item in the loop.
457
-            if (! $model instanceof EEM_Base) {
457
+            if ( ! $model instanceof EEM_Base) {
458 458
                 continue;
459 459
             }
460 460
             // yes we could just register one route for ALL models, but then they wouldn't show up in the index
461 461
             $plural_model_route = EED_Core_Rest_Api::get_collection_route($model);
462 462
             $singular_model_route = EED_Core_Rest_Api::get_entity_route($model, '(?P<id>[^\/]+)');
463
-            $model_routes[ $plural_model_route ] = [
463
+            $model_routes[$plural_model_route] = [
464 464
                 [
465 465
                     'callback'        => [
466 466
                         'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
                     'hidden_endpoint' => $hidden_endpoint,
472 472
                     'args'            => $this->_get_read_query_params($model, $version),
473 473
                     '_links'          => [
474
-                        'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route),
474
+                        'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route),
475 475
                     ],
476 476
                 ],
477 477
                 'schema' => [
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                     'callback_args'   => [$version, $model_name],
483 483
                 ],
484 484
             ];
485
-            $model_routes[ $singular_model_route ] = [
485
+            $model_routes[$singular_model_route] = [
486 486
                 [
487 487
                     'callback'        => [
488 488
                         'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
                 EED_Core_Rest_Api::should_have_write_endpoints($model),
500 500
                 $model
501 501
             )) {
502
-                $model_routes[ $plural_model_route ][] = [
502
+                $model_routes[$plural_model_route][] = [
503 503
                     'callback'        => [
504 504
                         'EventEspresso\core\libraries\rest_api\controllers\model\Write',
505 505
                         'handleRequestInsert',
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
                     'hidden_endpoint' => $hidden_endpoint,
510 510
                     'args'            => $this->_get_write_params($model_name, $model_version_info, true),
511 511
                 ];
512
-                $model_routes[ $singular_model_route ] = array_merge(
513
-                    $model_routes[ $singular_model_route ],
512
+                $model_routes[$singular_model_route] = array_merge(
513
+                    $model_routes[$singular_model_route],
514 514
                     [
515 515
                         [
516 516
                             'callback'        => [
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
                     '(?P<id>[^\/]+)',
542 542
                     $relation_obj
543 543
                 );
544
-                $model_routes[ $related_route ] = [
544
+                $model_routes[$related_route] = [
545 545
                     [
546 546
                         'callback'        => [
547 547
                             'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
                     ],
555 555
                 ];
556 556
 
557
-                $related_write_route = $related_route . '/' . '(?P<related_id>[^\/]+)';
558
-                $model_routes[ $related_write_route ] = [
557
+                $related_write_route = $related_route.'/'.'(?P<related_id>[^\/]+)';
558
+                $model_routes[$related_write_route] = [
559 559
                     [
560 560
                         'callback'        => [
561 561
                             'EventEspresso\core\libraries\rest_api\controllers\model\Write',
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
      */
610 610
     public static function get_entity_route($model, $id)
611 611
     {
612
-        return EED_Core_Rest_Api::get_collection_route($model) . '/' . $id;
612
+        return EED_Core_Rest_Api::get_collection_route($model).'/'.$id;
613 613
     }
614 614
 
615 615
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             $relation_obj->get_other_model()->get_this_model_name(),
630 630
             $relation_obj
631 631
         );
632
-        return EED_Core_Rest_Api::get_entity_route($model, $id) . '/' . $related_model_name_endpoint_part;
632
+        return EED_Core_Rest_Api::get_entity_route($model, $id).'/'.$related_model_name_endpoint_part;
633 633
     }
634 634
 
635 635
 
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
      */
644 644
     public static function get_versioned_route_to($relative_route, $version = '4.8.36')
645 645
     {
646
-        return '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/' . $relative_route;
646
+        return '/'.EED_Core_Rest_Api::ee_api_namespace.$version.'/'.$relative_route;
647 647
     }
648 648
 
649 649
 
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
     {
658 658
         $routes = [];
659 659
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
660
-            $routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version(
660
+            $routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version(
661 661
                 $version,
662 662
                 $hidden_endpoint
663 663
             );
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
     {
790 790
         // if they're related through a HABTM relation, check for any non-FKs
791 791
         $all_relation_settings = $source_model->relation_settings();
792
-        $relation_settings = $all_relation_settings[ $related_model->get_this_model_name() ];
792
+        $relation_settings = $all_relation_settings[$related_model->get_this_model_name()];
793 793
         $params = [];
794 794
         if ($relation_settings instanceof EE_HABTM_Relation && $relation_settings->hasNonKeyFields()) {
795 795
             foreach ($relation_settings->getNonKeyFields() as $field) {
796 796
                 /* @var $field EE_Model_Field_Base */
797
-                $params[ $field->get_name() ] = [
797
+                $params[$field->get_name()] = [
798 798
                     'required'          => ! $field->is_nullable(),
799 799
                     'default'           => ModelDataTranslator::prepareFieldValueForJson($field,
800 800
                         $field->get_default_value(), $version),
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
     {
821 821
         $default_orderby = [];
822 822
         foreach ($model->get_combined_primary_key_fields() as $key_field) {
823
-            $default_orderby[ $key_field->get_name() ] = 'ASC';
823
+            $default_orderby[$key_field->get_name()] = 'ASC';
824 824
         }
825 825
         return array_merge(
826 826
             $this->_get_response_selection_query_params($model, $version),
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
                     'type'              => [
855 855
                         'object',
856 856
                         'string',
857
-                    ],// because we accept a variety of types, WP core validation and sanitization
857
+                    ], // because we accept a variety of types, WP core validation and sanitization
858 858
                     // freaks out. We'll just validate this argument while handling the request
859 859
                     'validate_callback' => null,
860 860
                     'sanitize_callback' => null,
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
                 $model_version_info->requestedVersion()
951 951
             );
952 952
             $arg_info['sanitize_callback'] = $sanitize_callback;
953
-            $args_info[ $field_name ] = $arg_info;
953
+            $args_info[$field_name] = $arg_info;
954 954
             if ($field_obj instanceof EE_Datetime_Field) {
955 955
                 $gmt_arg_info = $arg_info;
956 956
                 $gmt_arg_info['description'] = sprintf(
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
                     $field_obj->get_nicename(),
962 962
                     $field_name
963 963
                 );
964
-                $args_info[ $field_name . '_gmt' ] = $gmt_arg_info;
964
+                $args_info[$field_name.'_gmt'] = $gmt_arg_info;
965 965
             }
966 966
         }
967 967
         return $args_info;
@@ -984,16 +984,16 @@  discard block
 block discarded – undo
984 984
     public static function default_sanitize_callback($value, WP_REST_Request $request, $param)
985 985
     {
986 986
         $attributes = $request->get_attributes();
987
-        if (! isset($attributes['args'][ $param ])
988
-            || ! is_array($attributes['args'][ $param ])) {
987
+        if ( ! isset($attributes['args'][$param])
988
+            || ! is_array($attributes['args'][$param])) {
989 989
             $validation_result = true;
990 990
         } else {
991
-            $args = $attributes['args'][ $param ];
991
+            $args = $attributes['args'][$param];
992 992
             if ((
993 993
                     $value === ''
994 994
                     || $value === null
995 995
                 )
996
-                && (! isset($args['required'])
996
+                && ( ! isset($args['required'])
997 997
                     || $args['required'] === false
998 998
                 )
999 999
             ) {
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                       && $args['format'] === 'email'
1004 1004
             ) {
1005 1005
                 $validation_result = true;
1006
-                if (! EED_Core_Rest_Api::_validate_email($value)) {
1006
+                if ( ! EED_Core_Rest_Api::_validate_email($value)) {
1007 1007
                     $validation_result = new WP_Error(
1008 1008
                         'rest_invalid_param',
1009 1009
                         esc_html__(
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
     {
1054 1054
         $config_routes = [];
1055 1055
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1056
-            $config_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version(
1056
+            $config_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version(
1057 1057
                 $version,
1058 1058
                 $hidden_endpoint
1059 1059
             );
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
     {
1109 1109
         $meta_routes = [];
1110 1110
         foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden_endpoint) {
1111
-            $meta_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version(
1111
+            $meta_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version(
1112 1112
                 $version,
1113 1113
                 $hidden_endpoint
1114 1114
             );
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
             foreach ($relative_urls as $resource_name => $endpoints) {
1162 1162
                 foreach ($endpoints as $key => $endpoint) {
1163 1163
                     // skip schema and other route options
1164
-                    if (! is_numeric($key)) {
1164
+                    if ( ! is_numeric($key)) {
1165 1165
                         continue;
1166 1166
                     }
1167 1167
                     // by default, hide "hidden_endpoint"s, unless the request indicates
@@ -1170,9 +1170,9 @@  discard block
 block discarded – undo
1170 1170
                     if (($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace)
1171 1171
                         || ($endpoint['hidden_endpoint'] && $force_show_ee_namespace === '')
1172 1172
                     ) {
1173
-                        $full_route = '/' . ltrim($namespace, '/');
1174
-                        $full_route .= '/' . ltrim($resource_name, '/');
1175
-                        unset($route_data[ $full_route ]);
1173
+                        $full_route = '/'.ltrim($namespace, '/');
1174
+                        $full_route .= '/'.ltrim($resource_name, '/');
1175
+                        unset($route_data[$full_route]);
1176 1176
                     }
1177 1177
                 }
1178 1178
             }
@@ -1246,19 +1246,19 @@  discard block
 block discarded – undo
1246 1246
 
1247 1247
             if ($key_versioned_endpoint === $latest_version) {
1248 1248
                 // don't hide the latest version in the index
1249
-                $versions_served[ $key_versioned_endpoint ] = false;
1249
+                $versions_served[$key_versioned_endpoint] = false;
1250 1250
             } elseif (version_compare($key_versioned_endpoint, $lowest_compatible_version, '>=')
1251 1251
                       && version_compare($key_versioned_endpoint, EED_Core_Rest_Api::core_version(), '<')
1252 1252
             ) {
1253 1253
                 // include, but hide, previous versions which are still supported
1254
-                $versions_served[ $key_versioned_endpoint ] = true;
1254
+                $versions_served[$key_versioned_endpoint] = true;
1255 1255
             } elseif (apply_filters(
1256 1256
                 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
1257 1257
                 false,
1258 1258
                 $possibly_served_versions
1259 1259
             )) {
1260 1260
                 // if a version is no longer supported, don't include it in index or list of versions served
1261
-                $versions_served[ $key_versioned_endpoint ] = true;
1261
+                $versions_served[$key_versioned_endpoint] = true;
1262 1262
             }
1263 1263
         }
1264 1264
         return $versions_served;
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
         $model_names = EED_Core_Rest_Api::model_names_with_plural_routes($version);
1316 1316
         $collection_routes = [];
1317 1317
         foreach ($model_names as $model_name => $model_class_name) {
1318
-            $collection_routes[ strtolower($model_name) ] = '/' . EED_Core_Rest_Api::ee_api_namespace . $version . '/'
1318
+            $collection_routes[strtolower($model_name)] = '/'.EED_Core_Rest_Api::ee_api_namespace.$version.'/'
1319 1319
                                                             . EEH_Inflector::pluralize_and_lower($model_name);
1320 1320
         }
1321 1321
         return $collection_routes;
@@ -1337,9 +1337,9 @@  discard block
 block discarded – undo
1337 1337
             $primary_keys = $model_class_name::instance()->get_combined_primary_key_fields();
1338 1338
             foreach ($primary_keys as $primary_key_name => $primary_key_field) {
1339 1339
                 if (count($primary_keys) > 1) {
1340
-                    $primary_key_items[ strtolower($model_name) ][] = $primary_key_name;
1340
+                    $primary_key_items[strtolower($model_name)][] = $primary_key_name;
1341 1341
                 } else {
1342
-                    $primary_key_items[ strtolower($model_name) ] = $primary_key_name;
1342
+                    $primary_key_items[strtolower($model_name)] = $primary_key_name;
1343 1343
                 }
1344 1344
             }
1345 1345
         }
Please login to merge, or discard this patch.
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -31,266 +31,266 @@
 block discarded – undo
31 31
 class CoreAssetManager extends AssetManager
32 32
 {
33 33
 
34
-    // WordPress core / Third party JS asset handles
35
-    const JS_HANDLE_JQUERY = 'jquery';
36
-
37
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
38
-
39
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
40
-
41
-    const JS_HANDLE_JS_CORE = 'eejs-core';
42
-
43
-    const JS_HANDLE_CORE = 'espresso_core';
44
-
45
-    const JS_HANDLE_I18N = 'eei18n';
46
-
47
-    const JS_HANDLE_VENDOR = 'eventespresso-vendor';
48
-
49
-    // EE CSS assets handles
50
-    const CSS_HANDLE_DEFAULT = 'espresso_default';
51
-
52
-    const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
53
-
54
-    /**
55
-     * @var EE_Currency_Config $currency_config
56
-     */
57
-    protected $currency_config;
58
-
59
-    /**
60
-     * @var EE_Template_Config $template_config
61
-     */
62
-    protected $template_config;
63
-
64
-
65
-    /**
66
-     * CoreAssetRegister constructor.
67
-     *
68
-     * @param AssetCollection    $assets
69
-     * @param EE_Currency_Config $currency_config
70
-     * @param EE_Template_Config $template_config
71
-     * @param DomainInterface    $domain
72
-     * @param Registry           $registry
73
-     */
74
-    public function __construct(
75
-        AssetCollection $assets,
76
-        EE_Currency_Config $currency_config,
77
-        EE_Template_Config $template_config,
78
-        DomainInterface $domain,
79
-        Registry $registry
80
-    ) {
81
-        $this->currency_config = $currency_config;
82
-        $this->template_config = $template_config;
83
-        parent::__construct($domain, $assets, $registry);
84
-    }
85
-
86
-
87
-    /**
88
-     * @since 4.9.62.p
89
-     * @throws DomainException
90
-     * @throws DuplicateCollectionIdentifierException
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidDataTypeException
93
-     * @throws InvalidEntityException
94
-     * @throws InvalidInterfaceException
95
-     */
96
-    public function addAssets()
97
-    {
98
-        $this->addJavascriptFiles();
99
-        $this->addStylesheetFiles();
100
-    }
101
-
102
-
103
-    /**
104
-     * @since 4.9.62.p
105
-     * @throws DomainException
106
-     * @throws DuplicateCollectionIdentifierException
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidEntityException
110
-     * @throws InvalidInterfaceException
111
-     */
112
-    public function addJavascriptFiles()
113
-    {
114
-        $this->loadCoreJs();
115
-        $this->loadJqueryValidate();
116
-    }
117
-
118
-
119
-    /**
120
-     * @throws DuplicateCollectionIdentifierException
121
-     * @throws InvalidDataTypeException
122
-     * @throws InvalidEntityException
123
-     * @throws DomainException
124
-     * @since 4.9.62.p
125
-     */
126
-    public function addStylesheetFiles()
127
-    {
128
-        $this->loadCoreCss();
129
-    }
130
-
131
-
132
-    /**
133
-     * core default javascript
134
-     *
135
-     * @since 4.9.62.p
136
-     * @throws DomainException
137
-     * @throws DuplicateCollectionIdentifierException
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidEntityException
141
-     * @throws InvalidInterfaceException
142
-     */
143
-    private function loadCoreJs()
144
-    {
145
-        $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR);
146
-        $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData();
147
-        $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
148
-        $this->registry->addData(
149
-            'paths',
150
-            array(
151
-                'base_rest_route' => rest_url(),
152
-                'rest_route' => rest_url('ee/v4.8.36/'),
153
-                'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
154
-                'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
155
-                'site_url' => site_url('/'),
156
-                'admin_url' => admin_url('/'),
157
-            )
158
-        );
159
-        // Event Espresso brand name
160
-        $this->registry->addData('brandName', Domain::brandName());
161
-        /** site formatting values **/
162
-        $this->registry->addData(
163
-            'site_formats',
164
-            array(
165
-                'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
166
-            )
167
-        );
168
-        /** currency data **/
169
-        $this->registry->addData(
170
-            'currency_config',
171
-            $this->getCurrencySettings()
172
-        );
173
-        /** site timezone */
174
-        $this->registry->addData(
175
-            'default_timezone',
176
-            array(
177
-                'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
178
-                'string' => get_option('timezone_string'),
179
-                'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
180
-            )
181
-        );
182
-        /** site locale (user locale if user logged in) */
183
-        $this->registry->addData(
184
-            'locale',
185
-            array(
186
-                'user' => get_user_locale(),
187
-                'site' => get_locale()
188
-            )
189
-        );
190
-
191
-        $this->addJavascript(
192
-            CoreAssetManager::JS_HANDLE_CORE,
193
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
194
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
195
-        )
196
-        ->setInlineDataCallback(
197
-            static function () {
198
-                wp_localize_script(
199
-                    CoreAssetManager::JS_HANDLE_CORE,
200
-                    CoreAssetManager::JS_HANDLE_I18N,
201
-                    EE_Registry::$i18n_js_strings
202
-                );
203
-            }
204
-        );
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * Returns configuration data for the js Currency VO.
211
-     * @since 4.9.71.p
212
-     * @return array
213
-     */
214
-    private function getCurrencySettings()
215
-    {
216
-        return array(
217
-            'code' => $this->currency_config->code,
218
-            'singularLabel' => $this->currency_config->name,
219
-            'pluralLabel' => $this->currency_config->plural,
220
-            'sign' => $this->currency_config->sign,
221
-            'signB4' => $this->currency_config->sign_b4,
222
-            'decimalPlaces' => $this->currency_config->dec_plc,
223
-            'decimalMark' => $this->currency_config->dec_mrk,
224
-            'thousandsSeparator' => $this->currency_config->thsnds,
225
-        );
226
-    }
227
-
228
-
229
-    /**
230
-     * @throws DuplicateCollectionIdentifierException
231
-     * @throws InvalidDataTypeException
232
-     * @throws InvalidEntityException
233
-     * @throws DomainException
234
-     * @since 4.9.62.p
235
-     */
236
-    private function loadCoreCss()
237
-    {
238
-        if ($this->template_config->enable_default_style && ! is_admin()) {
239
-            $this->addStylesheet(
240
-                CoreAssetManager::CSS_HANDLE_DEFAULT,
241
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
242
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
243
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
244
-                array('dashicons')
245
-            );
246
-            //Load custom style sheet if available
247
-            if ($this->template_config->custom_style_sheet !== null) {
248
-                $this->addStylesheet(
249
-                    CoreAssetManager::CSS_HANDLE_CUSTOM,
250
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
251
-                    array(CoreAssetManager::CSS_HANDLE_DEFAULT)
252
-                );
253
-            }
254
-        }
255
-    }
256
-
257
-
258
-    /**
259
-     * jQuery Validate for form validation
260
-     *
261
-     * @since 4.9.62.p
262
-     * @throws DomainException
263
-     * @throws DuplicateCollectionIdentifierException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidEntityException
266
-     */
267
-    private function loadJqueryValidate()
268
-    {
269
-        $this->addJavascript(
270
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
271
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
272
-            array(CoreAssetManager::JS_HANDLE_JQUERY),
273
-            true,
274
-            '1.15.0'
275
-        );
276
-
277
-        $this->addJavascript(
278
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
279
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
280
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE),
281
-            true,
282
-            '1.15.0'
283
-        );
284
-    }
285
-
286
-
287
-    /**
288
-     * @param JavascriptAsset $script
289
-     * @deprecated $VID:$
290
-     */
291
-    public function loadQtipJs(JavascriptAsset $script)
292
-    {
293
-        // replacement:
294
-        // \EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs
295
-    }
34
+	// WordPress core / Third party JS asset handles
35
+	const JS_HANDLE_JQUERY = 'jquery';
36
+
37
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
38
+
39
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
40
+
41
+	const JS_HANDLE_JS_CORE = 'eejs-core';
42
+
43
+	const JS_HANDLE_CORE = 'espresso_core';
44
+
45
+	const JS_HANDLE_I18N = 'eei18n';
46
+
47
+	const JS_HANDLE_VENDOR = 'eventespresso-vendor';
48
+
49
+	// EE CSS assets handles
50
+	const CSS_HANDLE_DEFAULT = 'espresso_default';
51
+
52
+	const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
53
+
54
+	/**
55
+	 * @var EE_Currency_Config $currency_config
56
+	 */
57
+	protected $currency_config;
58
+
59
+	/**
60
+	 * @var EE_Template_Config $template_config
61
+	 */
62
+	protected $template_config;
63
+
64
+
65
+	/**
66
+	 * CoreAssetRegister constructor.
67
+	 *
68
+	 * @param AssetCollection    $assets
69
+	 * @param EE_Currency_Config $currency_config
70
+	 * @param EE_Template_Config $template_config
71
+	 * @param DomainInterface    $domain
72
+	 * @param Registry           $registry
73
+	 */
74
+	public function __construct(
75
+		AssetCollection $assets,
76
+		EE_Currency_Config $currency_config,
77
+		EE_Template_Config $template_config,
78
+		DomainInterface $domain,
79
+		Registry $registry
80
+	) {
81
+		$this->currency_config = $currency_config;
82
+		$this->template_config = $template_config;
83
+		parent::__construct($domain, $assets, $registry);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @since 4.9.62.p
89
+	 * @throws DomainException
90
+	 * @throws DuplicateCollectionIdentifierException
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidDataTypeException
93
+	 * @throws InvalidEntityException
94
+	 * @throws InvalidInterfaceException
95
+	 */
96
+	public function addAssets()
97
+	{
98
+		$this->addJavascriptFiles();
99
+		$this->addStylesheetFiles();
100
+	}
101
+
102
+
103
+	/**
104
+	 * @since 4.9.62.p
105
+	 * @throws DomainException
106
+	 * @throws DuplicateCollectionIdentifierException
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidEntityException
110
+	 * @throws InvalidInterfaceException
111
+	 */
112
+	public function addJavascriptFiles()
113
+	{
114
+		$this->loadCoreJs();
115
+		$this->loadJqueryValidate();
116
+	}
117
+
118
+
119
+	/**
120
+	 * @throws DuplicateCollectionIdentifierException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws InvalidEntityException
123
+	 * @throws DomainException
124
+	 * @since 4.9.62.p
125
+	 */
126
+	public function addStylesheetFiles()
127
+	{
128
+		$this->loadCoreCss();
129
+	}
130
+
131
+
132
+	/**
133
+	 * core default javascript
134
+	 *
135
+	 * @since 4.9.62.p
136
+	 * @throws DomainException
137
+	 * @throws DuplicateCollectionIdentifierException
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidEntityException
141
+	 * @throws InvalidInterfaceException
142
+	 */
143
+	private function loadCoreJs()
144
+	{
145
+		$this->addJs(CoreAssetManager::JS_HANDLE_VENDOR);
146
+		$this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData();
147
+		$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
148
+		$this->registry->addData(
149
+			'paths',
150
+			array(
151
+				'base_rest_route' => rest_url(),
152
+				'rest_route' => rest_url('ee/v4.8.36/'),
153
+				'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
154
+				'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
155
+				'site_url' => site_url('/'),
156
+				'admin_url' => admin_url('/'),
157
+			)
158
+		);
159
+		// Event Espresso brand name
160
+		$this->registry->addData('brandName', Domain::brandName());
161
+		/** site formatting values **/
162
+		$this->registry->addData(
163
+			'site_formats',
164
+			array(
165
+				'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
166
+			)
167
+		);
168
+		/** currency data **/
169
+		$this->registry->addData(
170
+			'currency_config',
171
+			$this->getCurrencySettings()
172
+		);
173
+		/** site timezone */
174
+		$this->registry->addData(
175
+			'default_timezone',
176
+			array(
177
+				'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
178
+				'string' => get_option('timezone_string'),
179
+				'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
180
+			)
181
+		);
182
+		/** site locale (user locale if user logged in) */
183
+		$this->registry->addData(
184
+			'locale',
185
+			array(
186
+				'user' => get_user_locale(),
187
+				'site' => get_locale()
188
+			)
189
+		);
190
+
191
+		$this->addJavascript(
192
+			CoreAssetManager::JS_HANDLE_CORE,
193
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
194
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
195
+		)
196
+		->setInlineDataCallback(
197
+			static function () {
198
+				wp_localize_script(
199
+					CoreAssetManager::JS_HANDLE_CORE,
200
+					CoreAssetManager::JS_HANDLE_I18N,
201
+					EE_Registry::$i18n_js_strings
202
+				);
203
+			}
204
+		);
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * Returns configuration data for the js Currency VO.
211
+	 * @since 4.9.71.p
212
+	 * @return array
213
+	 */
214
+	private function getCurrencySettings()
215
+	{
216
+		return array(
217
+			'code' => $this->currency_config->code,
218
+			'singularLabel' => $this->currency_config->name,
219
+			'pluralLabel' => $this->currency_config->plural,
220
+			'sign' => $this->currency_config->sign,
221
+			'signB4' => $this->currency_config->sign_b4,
222
+			'decimalPlaces' => $this->currency_config->dec_plc,
223
+			'decimalMark' => $this->currency_config->dec_mrk,
224
+			'thousandsSeparator' => $this->currency_config->thsnds,
225
+		);
226
+	}
227
+
228
+
229
+	/**
230
+	 * @throws DuplicateCollectionIdentifierException
231
+	 * @throws InvalidDataTypeException
232
+	 * @throws InvalidEntityException
233
+	 * @throws DomainException
234
+	 * @since 4.9.62.p
235
+	 */
236
+	private function loadCoreCss()
237
+	{
238
+		if ($this->template_config->enable_default_style && ! is_admin()) {
239
+			$this->addStylesheet(
240
+				CoreAssetManager::CSS_HANDLE_DEFAULT,
241
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
242
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
243
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
244
+				array('dashicons')
245
+			);
246
+			//Load custom style sheet if available
247
+			if ($this->template_config->custom_style_sheet !== null) {
248
+				$this->addStylesheet(
249
+					CoreAssetManager::CSS_HANDLE_CUSTOM,
250
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
251
+					array(CoreAssetManager::CSS_HANDLE_DEFAULT)
252
+				);
253
+			}
254
+		}
255
+	}
256
+
257
+
258
+	/**
259
+	 * jQuery Validate for form validation
260
+	 *
261
+	 * @since 4.9.62.p
262
+	 * @throws DomainException
263
+	 * @throws DuplicateCollectionIdentifierException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidEntityException
266
+	 */
267
+	private function loadJqueryValidate()
268
+	{
269
+		$this->addJavascript(
270
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
271
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
272
+			array(CoreAssetManager::JS_HANDLE_JQUERY),
273
+			true,
274
+			'1.15.0'
275
+		);
276
+
277
+		$this->addJavascript(
278
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
279
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
280
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE),
281
+			true,
282
+			'1.15.0'
283
+		);
284
+	}
285
+
286
+
287
+	/**
288
+	 * @param JavascriptAsset $script
289
+	 * @deprecated $VID:$
290
+	 */
291
+	public function loadQtipJs(JavascriptAsset $script)
292
+	{
293
+		// replacement:
294
+		// \EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs
295
+	}
296 296
 }
Please login to merge, or discard this patch.
core/domain/services/assets/EspressoLegacyAdminAssetManager.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -15,121 +15,121 @@
 block discarded – undo
15 15
 class EspressoLegacyAdminAssetManager extends AssetManager
16 16
 {
17 17
 
18
-    const JS_HANDLE_INJECT_WP = 'ee-inject-wp';
19
-
20
-    const JS_HANDLE_JQUERY_COOKIE = 'jquery-cookie';
21
-
22
-    const JS_HANDLE_JOYRIDE_MODERNIZR = 'joyride-modernizr';
23
-
24
-    const JS_HANDLE_JQUERY_JOYRIDE = 'jquery-joyride';
25
-
26
-    const CSS_HANDLE_EE_JOYRIDE = 'ee-joyride-css';
27
-
28
-    const CSS_HANDLE_JOYRIDE = 'joyride-css';
29
-
30
-
31
-    /**
32
-     * @inheritDoc
33
-     */
34
-    public function addAssets()
35
-    {
36
-        $joyride = filter_var(apply_filters('FHEE_load_joyride', false), FILTER_VALIDATE_BOOLEAN);
37
-        $this->registerJavascript($joyride);
38
-        $this->registerStyleSheets($joyride);
39
-    }
40
-
41
-
42
-    /**
43
-     * Register javascript assets
44
-     *
45
-     * @param bool $joyride
46
-     */
47
-    private function registerJavascript($joyride = false)
48
-    {
49
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
50
-        // Note: the intention of this script is to only do TARGETED injections.
51
-        //ie: only injecting on certain script calls.
52
-        $this->addJavascript(
53
-            EspressoLegacyAdminAssetManager::JS_HANDLE_INJECT_WP,
54
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
55
-            ['jquery'],
56
-            true,
57
-            EVENT_ESPRESSO_VERSION
58
-        );
59
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
60
-        // can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
61
-        if (! $joyride) {
62
-            return;
63
-        }
64
-        // register cookie script for future dependencies
65
-        $this->addJavascript(
66
-            EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
67
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
68
-            ['jquery'],
69
-            true,
70
-            '2.1'
71
-        );
72
-        $this->addJavascript(
73
-            EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
74
-            EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
75
-            [],
76
-            true,
77
-            '2.1'
78
-        );
79
-        // wanna go for a joyride?
80
-        $this->addJavascript(
81
-            EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
82
-            EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
83
-            [
84
-                EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
85
-                EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR
86
-            ],
87
-            '2.1',
88
-            true
89
-        )->enqueueAsset();
90
-        $this->loadQtipJs();
91
-    }
92
-
93
-
94
-    /**
95
-     * Register CSS assets.
96
-     *
97
-     * @param bool $joyride
98
-     */
99
-    private function registerStyleSheets($joyride = false)
100
-    {
101
-        if (! $joyride) {
102
-            return;
103
-        }       // joyride style
104
-        $this->addStylesheet(
105
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
106
-            EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
107
-            [],
108
-            'all',
109
-            '2.1'
110
-        );
111
-        $this->addStylesheet(
112
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
113
-            EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
114
-            ['joyride-css'],
115
-            'all',
116
-            EVENT_ESPRESSO_VERSION
117
-        )->enqueueAsset();
118
-    }
119
-
120
-
121
-    /**
122
-     * registers assets for cleaning your ears
123
-     */
124
-    public function loadQtipJs()
125
-    {
126
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
127
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
128
-        if (apply_filters('FHEE_load_qtip', false)) {
129
-            $qtip_loader = EEH_Qtip_Loader::instance();
130
-            if ($qtip_loader instanceof EEH_Qtip_Loader) {
131
-                $qtip_loader->register_and_enqueue();
132
-            }
133
-        }
134
-    }
18
+	const JS_HANDLE_INJECT_WP = 'ee-inject-wp';
19
+
20
+	const JS_HANDLE_JQUERY_COOKIE = 'jquery-cookie';
21
+
22
+	const JS_HANDLE_JOYRIDE_MODERNIZR = 'joyride-modernizr';
23
+
24
+	const JS_HANDLE_JQUERY_JOYRIDE = 'jquery-joyride';
25
+
26
+	const CSS_HANDLE_EE_JOYRIDE = 'ee-joyride-css';
27
+
28
+	const CSS_HANDLE_JOYRIDE = 'joyride-css';
29
+
30
+
31
+	/**
32
+	 * @inheritDoc
33
+	 */
34
+	public function addAssets()
35
+	{
36
+		$joyride = filter_var(apply_filters('FHEE_load_joyride', false), FILTER_VALIDATE_BOOLEAN);
37
+		$this->registerJavascript($joyride);
38
+		$this->registerStyleSheets($joyride);
39
+	}
40
+
41
+
42
+	/**
43
+	 * Register javascript assets
44
+	 *
45
+	 * @param bool $joyride
46
+	 */
47
+	private function registerJavascript($joyride = false)
48
+	{
49
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
50
+		// Note: the intention of this script is to only do TARGETED injections.
51
+		//ie: only injecting on certain script calls.
52
+		$this->addJavascript(
53
+			EspressoLegacyAdminAssetManager::JS_HANDLE_INJECT_WP,
54
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
55
+			['jquery'],
56
+			true,
57
+			EVENT_ESPRESSO_VERSION
58
+		);
59
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
60
+		// can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
61
+		if (! $joyride) {
62
+			return;
63
+		}
64
+		// register cookie script for future dependencies
65
+		$this->addJavascript(
66
+			EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
67
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
68
+			['jquery'],
69
+			true,
70
+			'2.1'
71
+		);
72
+		$this->addJavascript(
73
+			EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
74
+			EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
75
+			[],
76
+			true,
77
+			'2.1'
78
+		);
79
+		// wanna go for a joyride?
80
+		$this->addJavascript(
81
+			EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
82
+			EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
83
+			[
84
+				EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
85
+				EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR
86
+			],
87
+			'2.1',
88
+			true
89
+		)->enqueueAsset();
90
+		$this->loadQtipJs();
91
+	}
92
+
93
+
94
+	/**
95
+	 * Register CSS assets.
96
+	 *
97
+	 * @param bool $joyride
98
+	 */
99
+	private function registerStyleSheets($joyride = false)
100
+	{
101
+		if (! $joyride) {
102
+			return;
103
+		}       // joyride style
104
+		$this->addStylesheet(
105
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
106
+			EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
107
+			[],
108
+			'all',
109
+			'2.1'
110
+		);
111
+		$this->addStylesheet(
112
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
113
+			EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
114
+			['joyride-css'],
115
+			'all',
116
+			EVENT_ESPRESSO_VERSION
117
+		)->enqueueAsset();
118
+	}
119
+
120
+
121
+	/**
122
+	 * registers assets for cleaning your ears
123
+	 */
124
+	public function loadQtipJs()
125
+	{
126
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
127
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
128
+		if (apply_filters('FHEE_load_qtip', false)) {
129
+			$qtip_loader = EEH_Qtip_Loader::instance();
130
+			if ($qtip_loader instanceof EEH_Qtip_Loader) {
131
+				$qtip_loader->register_and_enqueue();
132
+			}
133
+		}
134
+	}
135 135
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,27 +51,27 @@  discard block
 block discarded – undo
51 51
         //ie: only injecting on certain script calls.
52 52
         $this->addJavascript(
53 53
             EspressoLegacyAdminAssetManager::JS_HANDLE_INJECT_WP,
54
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
54
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
55 55
             ['jquery'],
56 56
             true,
57 57
             EVENT_ESPRESSO_VERSION
58 58
         );
59 59
         // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
60 60
         // can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
61
-        if (! $joyride) {
61
+        if ( ! $joyride) {
62 62
             return;
63 63
         }
64 64
         // register cookie script for future dependencies
65 65
         $this->addJavascript(
66 66
             EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
67
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
67
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
68 68
             ['jquery'],
69 69
             true,
70 70
             '2.1'
71 71
         );
72 72
         $this->addJavascript(
73 73
             EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
74
-            EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
74
+            EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js',
75 75
             [],
76 76
             true,
77 77
             '2.1'
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         // wanna go for a joyride?
80 80
         $this->addJavascript(
81 81
             EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
82
-            EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
82
+            EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
83 83
             [
84 84
                 EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_COOKIE,
85 85
                 EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function registerStyleSheets($joyride = false)
100 100
     {
101
-        if (! $joyride) {
101
+        if ( ! $joyride) {
102 102
             return;
103 103
         }       // joyride style
104 104
         $this->addStylesheet(
105 105
             EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
106
-            EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
106
+            EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css',
107 107
             [],
108 108
             'all',
109 109
             '2.1'
110 110
         );
111 111
         $this->addStylesheet(
112 112
             EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
113
-            EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
113
+            EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
114 114
             ['joyride-css'],
115 115
             'all',
116 116
             EVENT_ESPRESSO_VERSION
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/RouteInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,24 +14,24 @@
 block discarded – undo
14 14
 interface RouteInterface
15 15
 {
16 16
 
17
-    /**
18
-     * final method called by RouteHandler on Route which in turn calls requestHandler()
19
-     *
20
-     * @return bool
21
-     * @since   $VID:$
22
-     */
23
-    public function handleRequest();
17
+	/**
18
+	 * final method called by RouteHandler on Route which in turn calls requestHandler()
19
+	 *
20
+	 * @return bool
21
+	 * @since   $VID:$
22
+	 */
23
+	public function handleRequest();
24 24
 
25
-    /**
26
-     * @return bool
27
-     */
28
-    public function isHandled();
25
+	/**
26
+	 * @return bool
27
+	 */
28
+	public function isHandled();
29 29
 
30
-    /**
31
-     * returns true if the current request matches this route
32
-     *
33
-     * @return bool
34
-     * @since   $VID:$
35
-     */
36
-    public function matchesCurrentRequest();
30
+	/**
31
+	 * returns true if the current request matches this route
32
+	 *
33
+	 * @return bool
34
+	 * @since   $VID:$
35
+	 */
36
+	public function matchesCurrentRequest();
37 37
 }
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/admin/WordPressPluginsPage.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -17,55 +17,55 @@
 block discarded – undo
17 17
 class WordPressPluginsPage extends Route
18 18
 {
19 19
 
20
-    /**
21
-     * returns true if the current request matches this route
22
-     *
23
-     * @return bool
24
-     * @since   $VID:$
25
-     */
26
-    public function matchesCurrentRequest()
27
-    {
28
-        return $this->request->isAdmin()
29
-               && strpos($this->request->requestUri(), 'wp-admin/plugins.php') !== false;
30
-    }
20
+	/**
21
+	 * returns true if the current request matches this route
22
+	 *
23
+	 * @return bool
24
+	 * @since   $VID:$
25
+	 */
26
+	public function matchesCurrentRequest()
27
+	{
28
+		return $this->request->isAdmin()
29
+			   && strpos($this->request->requestUri(), 'wp-admin/plugins.php') !== false;
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * @since $VID:$
35
-     */
36
-    protected function registerDependencies() {
37
-        $this->dependency_map->registerDependencies(
38
-            'EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager',
39
-            [
40
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
41
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
42
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
43
-                'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache,
44
-            ]
45
-        );
46
-        $this->dependency_map->registerDependencies(
47
-            'EventEspresso\core\domain\services\admin\ExitModal',
48
-            [ 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache ]
49
-        );
50
-        $this->dependency_map->registerDependencies(
51
-            'EventEspresso\core\domain\services\admin\PluginUpsells',
52
-            [ 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache ]
53
-        );
54
-    }
33
+	/**
34
+	 * @since $VID:$
35
+	 */
36
+	protected function registerDependencies() {
37
+		$this->dependency_map->registerDependencies(
38
+			'EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager',
39
+			[
40
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
41
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
42
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
43
+				'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache,
44
+			]
45
+		);
46
+		$this->dependency_map->registerDependencies(
47
+			'EventEspresso\core\domain\services\admin\ExitModal',
48
+			[ 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache ]
49
+		);
50
+		$this->dependency_map->registerDependencies(
51
+			'EventEspresso\core\domain\services\admin\PluginUpsells',
52
+			[ 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache ]
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * implements logic required to run during request
59
-     *
60
-     * @return bool
61
-     * @since   $VID:$
62
-     */
63
-    protected function requestHandler()
64
-    {
65
-        $this->loader->getShared('EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager');
66
-        /** @var PluginUpsells $plugin_upsells */
67
-        $plugin_upsells = $this->loader->getShared('EventEspresso\core\domain\services\admin\PluginUpsells');
68
-        $plugin_upsells->decafUpsells();
69
-        return true;
70
-    }
57
+	/**
58
+	 * implements logic required to run during request
59
+	 *
60
+	 * @return bool
61
+	 * @since   $VID:$
62
+	 */
63
+	protected function requestHandler()
64
+	{
65
+		$this->loader->getShared('EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager');
66
+		/** @var PluginUpsells $plugin_upsells */
67
+		$plugin_upsells = $this->loader->getShared('EventEspresso\core\domain\services\admin\PluginUpsells');
68
+		$plugin_upsells->decafUpsells();
69
+		return true;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
45 45
         );
46 46
         $this->dependency_map->registerDependencies(
47 47
             'EventEspresso\core\domain\services\admin\ExitModal',
48
-            [ 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache ]
48
+            ['EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache]
49 49
         );
50 50
         $this->dependency_map->registerDependencies(
51 51
             'EventEspresso\core\domain\services\admin\PluginUpsells',
52
-            [ 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache ]
52
+            ['EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache]
53 53
         );
54 54
     }
55 55
 
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/admin/PersonalDataRequests.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -18,108 +18,108 @@
 block discarded – undo
18 18
 class PersonalDataRequests extends Route
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Maintenance_Mode $maintenance_mode
23
-     */
24
-    private $maintenance_mode;
21
+	/**
22
+	 * @var EE_Maintenance_Mode $maintenance_mode
23
+	 */
24
+	private $maintenance_mode;
25 25
 
26 26
 
27
-    /**
28
-     * Route constructor.
29
-     *
30
-     * @param EE_Dependency_Map   $dependency_map
31
-     * @param EE_Maintenance_Mode $maintenance_mode
32
-     * @param LoaderInterface     $loader
33
-     * @param RequestInterface    $request
34
-     */
35
-    public function __construct(
36
-        EE_Dependency_Map $dependency_map,
37
-        EE_Maintenance_Mode $maintenance_mode,
38
-        LoaderInterface $loader,
39
-        RequestInterface $request
40
-    ) {
41
-        $this->maintenance_mode = $maintenance_mode;
42
-        parent::__construct($dependency_map, $loader, $request);
43
-    }
27
+	/**
28
+	 * Route constructor.
29
+	 *
30
+	 * @param EE_Dependency_Map   $dependency_map
31
+	 * @param EE_Maintenance_Mode $maintenance_mode
32
+	 * @param LoaderInterface     $loader
33
+	 * @param RequestInterface    $request
34
+	 */
35
+	public function __construct(
36
+		EE_Dependency_Map $dependency_map,
37
+		EE_Maintenance_Mode $maintenance_mode,
38
+		LoaderInterface $loader,
39
+		RequestInterface $request
40
+	) {
41
+		$this->maintenance_mode = $maintenance_mode;
42
+		parent::__construct($dependency_map, $loader, $request);
43
+	}
44 44
 
45
-    /**
46
-     * returns true if the current request matches this route
47
-     *
48
-     * @return bool
49
-     * @since   $VID:$
50
-     */
51
-    public function matchesCurrentRequest()
52
-    {
53
-        return ($this->request->isAdmin() || $this->request->isAjax()) && $this->maintenance_mode->models_can_query();
54
-    }
45
+	/**
46
+	 * returns true if the current request matches this route
47
+	 *
48
+	 * @return bool
49
+	 * @since   $VID:$
50
+	 */
51
+	public function matchesCurrentRequest()
52
+	{
53
+		return ($this->request->isAdmin() || $this->request->isAjax()) && $this->maintenance_mode->models_can_query();
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @since $VID:$
59
-     */
60
-    protected function registerDependencies()
61
-    {
62
-        $this->dependency_map->registerDependencies(
63
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy',
64
-            [
65
-                'EEM_Payment_Method'                                       => EE_Dependency_Map::load_from_cache,
66
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
67
-            ]
68
-        );
69
-        $this->dependency_map->registerDependencies(
70
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee',
71
-            [ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
72
-        );
73
-        $this->dependency_map->registerDependencies(
74
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData',
75
-            [
76
-                'EEM_Attendee'       => EE_Dependency_Map::load_from_cache,
77
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
78
-            ]
79
-        );
80
-        $this->dependency_map->registerDependencies(
81
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins',
82
-            [ 'EEM_Checkin' => EE_Dependency_Map::load_from_cache ]
83
-        );
84
-        $this->dependency_map->registerDependencies(
85
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration',
86
-            [ 'EEM_Registration' => EE_Dependency_Map::load_from_cache ]
87
-        );
88
-        $this->dependency_map->registerDependencies(
89
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction',
90
-            [ 'EEM_Transaction' => EE_Dependency_Map::load_from_cache ]
91
-        );
92
-        $this->dependency_map->registerDependencies(
93
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData',
94
-            [ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
95
-        );
96
-        $this->dependency_map->registerDependencies(
97
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers',
98
-            [
99
-                'EEM_Answer'   => EE_Dependency_Map::load_from_cache,
100
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
101
-            ]
102
-        );
103
-        $this->dependency_map->registerDependencies(
104
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler',
105
-            [
106
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
107
-                'EE_Config'   => EE_Dependency_Map::load_from_cache
108
-            ]
109
-        );
110
-    }
57
+	/**
58
+	 * @since $VID:$
59
+	 */
60
+	protected function registerDependencies()
61
+	{
62
+		$this->dependency_map->registerDependencies(
63
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy',
64
+			[
65
+				'EEM_Payment_Method'                                       => EE_Dependency_Map::load_from_cache,
66
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
67
+			]
68
+		);
69
+		$this->dependency_map->registerDependencies(
70
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee',
71
+			[ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
72
+		);
73
+		$this->dependency_map->registerDependencies(
74
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData',
75
+			[
76
+				'EEM_Attendee'       => EE_Dependency_Map::load_from_cache,
77
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
78
+			]
79
+		);
80
+		$this->dependency_map->registerDependencies(
81
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins',
82
+			[ 'EEM_Checkin' => EE_Dependency_Map::load_from_cache ]
83
+		);
84
+		$this->dependency_map->registerDependencies(
85
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration',
86
+			[ 'EEM_Registration' => EE_Dependency_Map::load_from_cache ]
87
+		);
88
+		$this->dependency_map->registerDependencies(
89
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction',
90
+			[ 'EEM_Transaction' => EE_Dependency_Map::load_from_cache ]
91
+		);
92
+		$this->dependency_map->registerDependencies(
93
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData',
94
+			[ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
95
+		);
96
+		$this->dependency_map->registerDependencies(
97
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers',
98
+			[
99
+				'EEM_Answer'   => EE_Dependency_Map::load_from_cache,
100
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
101
+			]
102
+		);
103
+		$this->dependency_map->registerDependencies(
104
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler',
105
+			[
106
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
107
+				'EE_Config'   => EE_Dependency_Map::load_from_cache
108
+			]
109
+		);
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * implements logic required to run during request
115
-     *
116
-     * @return bool
117
-     * @since   $VID:$
118
-     */
119
-    protected function requestHandler()
120
-    {
121
-        $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
122
-        $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
123
-        return true;
124
-    }
113
+	/**
114
+	 * implements logic required to run during request
115
+	 *
116
+	 * @return bool
117
+	 * @since   $VID:$
118
+	 */
119
+	protected function requestHandler()
120
+	{
121
+		$this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
122
+		$this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
123
+		return true;
124
+	}
125 125
 }
126 126
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         );
69 69
         $this->dependency_map->registerDependencies(
70 70
             'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee',
71
-            [ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
71
+            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
72 72
         );
73 73
         $this->dependency_map->registerDependencies(
74 74
             'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData',
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
         );
80 80
         $this->dependency_map->registerDependencies(
81 81
             'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins',
82
-            [ 'EEM_Checkin' => EE_Dependency_Map::load_from_cache ]
82
+            ['EEM_Checkin' => EE_Dependency_Map::load_from_cache]
83 83
         );
84 84
         $this->dependency_map->registerDependencies(
85 85
             'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration',
86
-            [ 'EEM_Registration' => EE_Dependency_Map::load_from_cache ]
86
+            ['EEM_Registration' => EE_Dependency_Map::load_from_cache]
87 87
         );
88 88
         $this->dependency_map->registerDependencies(
89 89
             'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction',
90
-            [ 'EEM_Transaction' => EE_Dependency_Map::load_from_cache ]
90
+            ['EEM_Transaction' => EE_Dependency_Map::load_from_cache]
91 91
         );
92 92
         $this->dependency_map->registerDependencies(
93 93
             'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData',
94
-            [ 'EEM_Attendee' => EE_Dependency_Map::load_from_cache ]
94
+            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
95 95
         );
96 96
         $this->dependency_map->registerDependencies(
97 97
             'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers',
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/admin/EspressoLegacyAdmin.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -16,109 +16,109 @@
 block discarded – undo
16 16
 class EspressoLegacyAdmin extends Route
17 17
 {
18 18
 
19
-    /**
20
-     * returns true if the current request matches this route
21
-     *
22
-     * @return bool
23
-     * @since   $VID:$
24
-     */
25
-    public function matchesCurrentRequest()
26
-    {
27
-        return $this->request->isAdmin() || $this->request->isAdminAjax();
28
-    }
19
+	/**
20
+	 * returns true if the current request matches this route
21
+	 *
22
+	 * @return bool
23
+	 * @since   $VID:$
24
+	 */
25
+	public function matchesCurrentRequest()
26
+	{
27
+		return $this->request->isAdmin() || $this->request->isAdminAjax();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @since $VID:$
33
-     */
34
-    protected function registerDependencies()
35
-    {
36
-        $this->dependency_map->registerDependencies(
37
-        'EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager',
38
-                [
39
-                    'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
40
-                    'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
41
-                    'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
42
-                ]
43
-        );
44
-        $this->dependency_map->registerDependencies(
45
-            'EE_Admin_Transactions_List_Table',
46
-            [
47
-                null,
48
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
49
-            ]
50
-        );
51
-        $this->dependency_map->registerDependencies(
52
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings',
53
-            [ 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache ]
54
-        );
55
-        $this->dependency_map->registerDependencies(
56
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings',
57
-            [
58
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
59
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
60
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
61
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
62
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
63
-            ]
64
-        );
65
-        $this->dependency_map->registerDependencies(
66
-            'EventEspresso\core\services\address\CountrySubRegionDao',
67
-            [
68
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
69
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
70
-            ]
71
-        );
72
-        $this->dependency_map->registerDependencies(
73
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
74
-            [
75
-                null,
76
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
77
-                'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
78
-            ]
79
-        );
80
-        $this->dependency_map->registerDependencies(
81
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
82
-            [
83
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
84
-                'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
85
-            ]
86
-        );
87
-        $this->dependency_map->registerDependencies(
88
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
89
-            [
90
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
91
-                'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
92
-            ]
93
-        );
94
-        $this->dependency_map->registerDependencies(
95
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
96
-            [
97
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
98
-                'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
99
-            ]
100
-        );
101
-        $this->dependency_map->registerDependencies(
102
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
103
-            [
104
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
105
-                'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-    }
31
+	/**
32
+	 * @since $VID:$
33
+	 */
34
+	protected function registerDependencies()
35
+	{
36
+		$this->dependency_map->registerDependencies(
37
+		'EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager',
38
+				[
39
+					'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
40
+					'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
41
+					'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
42
+				]
43
+		);
44
+		$this->dependency_map->registerDependencies(
45
+			'EE_Admin_Transactions_List_Table',
46
+			[
47
+				null,
48
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
49
+			]
50
+		);
51
+		$this->dependency_map->registerDependencies(
52
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings',
53
+			[ 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache ]
54
+		);
55
+		$this->dependency_map->registerDependencies(
56
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings',
57
+			[
58
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
59
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
60
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
61
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
62
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
63
+			]
64
+		);
65
+		$this->dependency_map->registerDependencies(
66
+			'EventEspresso\core\services\address\CountrySubRegionDao',
67
+			[
68
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
69
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
70
+			]
71
+		);
72
+		$this->dependency_map->registerDependencies(
73
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
74
+			[
75
+				null,
76
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
77
+				'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
78
+			]
79
+		);
80
+		$this->dependency_map->registerDependencies(
81
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
82
+			[
83
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
84
+				'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
85
+			]
86
+		);
87
+		$this->dependency_map->registerDependencies(
88
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
89
+			[
90
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
91
+				'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
92
+			]
93
+		);
94
+		$this->dependency_map->registerDependencies(
95
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
96
+			[
97
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
98
+				'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
99
+			]
100
+		);
101
+		$this->dependency_map->registerDependencies(
102
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
103
+			[
104
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
105
+				'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * implements logic required to run during request
113
-     *
114
-     * @return bool
115
-     * @since   $VID:$
116
-     */
117
-    protected function requestHandler()
118
-    {
119
-        do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
120
-        $this->loader->getShared('EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager');
121
-        $this->loader->getShared('EE_Admin');
122
-        return true;
123
-    }
111
+	/**
112
+	 * implements logic required to run during request
113
+	 *
114
+	 * @return bool
115
+	 * @since   $VID:$
116
+	 */
117
+	protected function requestHandler()
118
+	{
119
+		do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
120
+		$this->loader->getShared('EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager');
121
+		$this->loader->getShared('EE_Admin');
122
+		return true;
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
         );
51 51
         $this->dependency_map->registerDependencies(
52 52
             'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings',
53
-            [ 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache ]
53
+            ['EE_Registration_Config' => EE_Dependency_Map::load_from_cache]
54 54
         );
55 55
         $this->dependency_map->registerDependencies(
56 56
             'EventEspresso\admin_pages\general_settings\OrganizationSettings',
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/admin/PueRequests.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -15,71 +15,71 @@
 block discarded – undo
15 15
 class PueRequests extends Route
16 16
 {
17 17
 
18
-    /**
19
-     * returns true if the current request matches this route
20
-     *
21
-     * @return bool
22
-     * @since   $VID:$
23
-     */
24
-    public function matchesCurrentRequest()
25
-    {
26
-        return $this->request->isAdmin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true);
27
-    }
18
+	/**
19
+	 * returns true if the current request matches this route
20
+	 *
21
+	 * @return bool
22
+	 * @since   $VID:$
23
+	 */
24
+	public function matchesCurrentRequest()
25
+	{
26
+		return $this->request->isAdmin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true);
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @since $VID:$
32
-     */
33
-    protected function registerDependencies()
34
-    {
35
-        $this->dependency_map->registerDependencies(
36
-            'EventEspresso\core\services\licensing\LicenseService',
37
-            [
38
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
39
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
40
-            ]
41
-        );
42
-        $this->dependency_map->registerDependencies(
43
-            'EventEspresso\core\domain\services\pue\Stats',
44
-            [
45
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
46
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
47
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
48
-            ]
49
-        );
50
-        $this->dependency_map->registerDependencies(
51
-            'EventEspresso\core\domain\services\pue\Config',
52
-            [
53
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
54
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
55
-            ]
56
-        );
57
-        $this->dependency_map->registerDependencies(
58
-            'EventEspresso\core\domain\services\pue\StatsGatherer',
59
-            [
60
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
61
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
62
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
63
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
64
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
65
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
66
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
67
-            ]
68
-        );
69
-    }
30
+	/**
31
+	 * @since $VID:$
32
+	 */
33
+	protected function registerDependencies()
34
+	{
35
+		$this->dependency_map->registerDependencies(
36
+			'EventEspresso\core\services\licensing\LicenseService',
37
+			[
38
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
39
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
40
+			]
41
+		);
42
+		$this->dependency_map->registerDependencies(
43
+			'EventEspresso\core\domain\services\pue\Stats',
44
+			[
45
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
46
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
47
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
48
+			]
49
+		);
50
+		$this->dependency_map->registerDependencies(
51
+			'EventEspresso\core\domain\services\pue\Config',
52
+			[
53
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
54
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
55
+			]
56
+		);
57
+		$this->dependency_map->registerDependencies(
58
+			'EventEspresso\core\domain\services\pue\StatsGatherer',
59
+			[
60
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
61
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
62
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
63
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
64
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
65
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
66
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
67
+			]
68
+		);
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * implements logic required to run during request
74
-     *
75
-     * @return bool
76
-     * @since   $VID:$
77
-     */
78
-    protected function requestHandler()
79
-    {
80
-        // pew pew pew
81
-        $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
82
-        do_action('AHEE__EE_System__brew_espresso__after_pue_init');
83
-        return true;
84
-    }
72
+	/**
73
+	 * implements logic required to run during request
74
+	 *
75
+	 * @return bool
76
+	 * @since   $VID:$
77
+	 */
78
+	protected function requestHandler()
79
+	{
80
+		// pew pew pew
81
+		$this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
82
+		do_action('AHEE__EE_System__brew_espresso__after_pue_init');
83
+		return true;
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/domain/entities/routes/handlers/admin/EspressoEventEditor.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -16,117 +16,117 @@
 block discarded – undo
16 16
 class EspressoEventEditor extends Route
17 17
 {
18 18
 
19
-    /**
20
-     * returns true if the current request matches this route
21
-     *
22
-     * @return bool
23
-     * @since   $VID:$
24
-     */
25
-    public function matchesCurrentRequest()
26
-    {
27
-        return $this->request->isAdmin()
28
-            && $this->request->getRequestParam('page') === 'espresso_events'
29
-               && (
30
-                   $this->request->getRequestParam('action') === 'create_new'
31
-                   || $this->request->getRequestParam('action') === 'edit'
32
-               );
33
-    }
19
+	/**
20
+	 * returns true if the current request matches this route
21
+	 *
22
+	 * @return bool
23
+	 * @since   $VID:$
24
+	 */
25
+	public function matchesCurrentRequest()
26
+	{
27
+		return $this->request->isAdmin()
28
+			&& $this->request->getRequestParam('page') === 'espresso_events'
29
+			   && (
30
+				   $this->request->getRequestParam('action') === 'create_new'
31
+				   || $this->request->getRequestParam('action') === 'edit'
32
+			   );
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * @since $VID:$
38
-     */
39
-    protected function registerDependencies()
40
-    {
41
-        $this->dependency_map->registerDependencies(
42
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
43
-            [
44
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
45
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
46
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
47
-            ]
48
-        );
49
-        $this->dependency_map->registerDependencies(
50
-            'EventEspresso\core\domain\services\admin\events\editor\EventEditor',
51
-            [
52
-                'EE_Admin_Config'                                                               => EE_Dependency_Map::load_from_cache,
53
-                'EE_Event'                                                                      => EE_Dependency_Map::not_registered,
54
-                'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser'              =>
55
-                    EE_Dependency_Map::not_registered,
56
-                'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' =>
57
-                    EE_Dependency_Map::load_from_cache,
58
-                'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings'          =>
59
-                    EE_Dependency_Map::load_from_cache,
60
-                'EventEspresso\core\services\assets\JedLocaleData'                              => EE_Dependency_Map::load_from_cache,
61
-            ]
62
-        );
63
-        $this->dependency_map->registerDependencies(
64
-            'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection',
65
-            ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache]
66
-        );
67
-        $this->dependency_map->registerDependencies(
68
-            'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
69
-            [
70
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
71
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
72
-                'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
73
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
74
-                'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
75
-                'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
76
-            ]
77
-        );
78
-        $this->dependency_map->registerDependencies(
79
-            'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
80
-            [
81
-                'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
82
-                'EEM_Event'      => EE_Dependency_Map::load_from_cache,
83
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
84
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
85
-                'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
86
-            ]
87
-        );
88
-        $this->dependency_map->registerDependencies(
89
-            'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
90
-            [
91
-                'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
92
-                'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
93
-                'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
94
-                'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
95
-                'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
96
-                'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
97
-            ]
98
-        );
99
-        $this->dependency_map->registerDependencies(
100
-            'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
101
-            [
102
-                'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
103
-                'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
104
-            ]
105
-        );
106
-        $this->dependency_map->registerDependencies(
107
-            'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
108
-            [
109
-                'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
110
-                'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
111
-            ]
112
-        );
113
-        $this->dependency_map->registerDependencies(
114
-            'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
115
-            [
116
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
117
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
118
-            ]
119
-        );
120
-    }
36
+	/**
37
+	 * @since $VID:$
38
+	 */
39
+	protected function registerDependencies()
40
+	{
41
+		$this->dependency_map->registerDependencies(
42
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
43
+			[
44
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
45
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
46
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
47
+			]
48
+		);
49
+		$this->dependency_map->registerDependencies(
50
+			'EventEspresso\core\domain\services\admin\events\editor\EventEditor',
51
+			[
52
+				'EE_Admin_Config'                                                               => EE_Dependency_Map::load_from_cache,
53
+				'EE_Event'                                                                      => EE_Dependency_Map::not_registered,
54
+				'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser'              =>
55
+					EE_Dependency_Map::not_registered,
56
+				'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' =>
57
+					EE_Dependency_Map::load_from_cache,
58
+				'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings'          =>
59
+					EE_Dependency_Map::load_from_cache,
60
+				'EventEspresso\core\services\assets\JedLocaleData'                              => EE_Dependency_Map::load_from_cache,
61
+			]
62
+		);
63
+		$this->dependency_map->registerDependencies(
64
+			'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection',
65
+			['EE_Admin_Config' => EE_Dependency_Map::load_from_cache]
66
+		);
67
+		$this->dependency_map->registerDependencies(
68
+			'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
69
+			[
70
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
71
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
72
+				'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
73
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
74
+				'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
75
+				'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
76
+			]
77
+		);
78
+		$this->dependency_map->registerDependencies(
79
+			'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
80
+			[
81
+				'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
82
+				'EEM_Event'      => EE_Dependency_Map::load_from_cache,
83
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
84
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
85
+				'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
86
+			]
87
+		);
88
+		$this->dependency_map->registerDependencies(
89
+			'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
90
+			[
91
+				'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
92
+				'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
93
+				'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
94
+				'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
95
+				'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
96
+				'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
97
+			]
98
+		);
99
+		$this->dependency_map->registerDependencies(
100
+			'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
101
+			[
102
+				'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
103
+				'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
104
+			]
105
+		);
106
+		$this->dependency_map->registerDependencies(
107
+			'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
108
+			[
109
+				'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
110
+				'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
111
+			]
112
+		);
113
+		$this->dependency_map->registerDependencies(
114
+			'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
115
+			[
116
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
117
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
118
+			]
119
+		);
120
+	}
121 121
 
122
-    /**
123
-     * implements logic required to run during request
124
-     *
125
-     * @return bool
126
-     * @since   $VID:$
127
-     */
128
-    protected function requestHandler()
129
-    {
130
-        return false;
131
-    }
122
+	/**
123
+	 * implements logic required to run during request
124
+	 *
125
+	 * @return bool
126
+	 * @since   $VID:$
127
+	 */
128
+	protected function requestHandler()
129
+	{
130
+		return false;
131
+	}
132 132
 }
Please login to merge, or discard this patch.