@@ -15,103 +15,103 @@ |
||
15 | 15 | class EE_Register_Data_Migration_Scripts implements EEI_Plugin_API |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Holds values for registered DMSs |
|
20 | - * |
|
21 | - * @var array[][] |
|
22 | - */ |
|
23 | - protected static $_settings = array(); |
|
18 | + /** |
|
19 | + * Holds values for registered DMSs |
|
20 | + * |
|
21 | + * @var array[][] |
|
22 | + */ |
|
23 | + protected static $_settings = array(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Method for registering new Data Migration Scripts |
|
28 | - * |
|
29 | - * @since 4.3.0 |
|
30 | - * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
31 | - * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
32 | - * @param array $setup_args { |
|
33 | - * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
34 | - * } |
|
35 | - * @throws EE_Error |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public static function register($addon_name = '', $setup_args = array()) |
|
39 | - { |
|
40 | - // required fields MUST be present, so let's make sure they are. |
|
41 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) { |
|
42 | - throw new EE_Error( |
|
43 | - esc_html__( |
|
44 | - 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', |
|
45 | - 'event_espresso' |
|
46 | - ) |
|
47 | - ); |
|
48 | - } |
|
49 | - // make sure we don't register twice |
|
50 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | - return; |
|
52 | - } |
|
53 | - // make sure this was called in the right place! |
|
54 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
55 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
56 | - ) { |
|
57 | - EE_Error::doing_it_wrong( |
|
58 | - __METHOD__, |
|
59 | - esc_html__( |
|
60 | - 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', |
|
61 | - 'event_espresso' |
|
62 | - ), |
|
63 | - '4.3.0' |
|
64 | - ); |
|
65 | - } |
|
66 | - // setup $_settings array from incoming values. |
|
67 | - self::$_settings[ $addon_name ] = array( |
|
68 | - 'dms_paths' => (array) $setup_args['dms_paths'], |
|
69 | - ); |
|
70 | - // setup DMS |
|
71 | - $filters_set = has_filter( |
|
72 | - 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
73 | - ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
74 | - ); |
|
75 | - if (! $filters_set) { |
|
76 | - add_filter( |
|
77 | - 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
78 | - ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
79 | - ); |
|
80 | - } |
|
81 | - } |
|
26 | + /** |
|
27 | + * Method for registering new Data Migration Scripts |
|
28 | + * |
|
29 | + * @since 4.3.0 |
|
30 | + * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
31 | + * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
32 | + * @param array $setup_args { |
|
33 | + * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
34 | + * } |
|
35 | + * @throws EE_Error |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public static function register($addon_name = '', $setup_args = array()) |
|
39 | + { |
|
40 | + // required fields MUST be present, so let's make sure they are. |
|
41 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) { |
|
42 | + throw new EE_Error( |
|
43 | + esc_html__( |
|
44 | + 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', |
|
45 | + 'event_espresso' |
|
46 | + ) |
|
47 | + ); |
|
48 | + } |
|
49 | + // make sure we don't register twice |
|
50 | + if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + return; |
|
52 | + } |
|
53 | + // make sure this was called in the right place! |
|
54 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
55 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
56 | + ) { |
|
57 | + EE_Error::doing_it_wrong( |
|
58 | + __METHOD__, |
|
59 | + esc_html__( |
|
60 | + 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', |
|
61 | + 'event_espresso' |
|
62 | + ), |
|
63 | + '4.3.0' |
|
64 | + ); |
|
65 | + } |
|
66 | + // setup $_settings array from incoming values. |
|
67 | + self::$_settings[ $addon_name ] = array( |
|
68 | + 'dms_paths' => (array) $setup_args['dms_paths'], |
|
69 | + ); |
|
70 | + // setup DMS |
|
71 | + $filters_set = has_filter( |
|
72 | + 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
73 | + ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
74 | + ); |
|
75 | + if (! $filters_set) { |
|
76 | + add_filter( |
|
77 | + 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
78 | + ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
79 | + ); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param array $dms_paths |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - public static function add_data_migration_script_folders($dms_paths = array()) |
|
89 | - { |
|
90 | - foreach (self::$_settings as $addon_name => $settings) { |
|
91 | - $wildcards = 0; |
|
92 | - foreach ($settings['dms_paths'] as $dms_path) { |
|
93 | - // since we are using the addon name for the array key |
|
94 | - // we need to ensure that the key is unique, |
|
95 | - // so if for some reason an addon has multiple dms paths, |
|
96 | - // we append one or more * to the classname |
|
97 | - // which will get stripped out later on |
|
98 | - $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
99 | - $wildcards++; |
|
100 | - } |
|
101 | - } |
|
102 | - return $dms_paths; |
|
103 | - } |
|
84 | + /** |
|
85 | + * @param array $dms_paths |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + public static function add_data_migration_script_folders($dms_paths = array()) |
|
89 | + { |
|
90 | + foreach (self::$_settings as $addon_name => $settings) { |
|
91 | + $wildcards = 0; |
|
92 | + foreach ($settings['dms_paths'] as $dms_path) { |
|
93 | + // since we are using the addon name for the array key |
|
94 | + // we need to ensure that the key is unique, |
|
95 | + // so if for some reason an addon has multiple dms paths, |
|
96 | + // we append one or more * to the classname |
|
97 | + // which will get stripped out later on |
|
98 | + $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
99 | + $wildcards++; |
|
100 | + } |
|
101 | + } |
|
102 | + return $dms_paths; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
108 | - * |
|
109 | - * @since 4.3.0 |
|
110 | - * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
111 | - * @return void |
|
112 | - */ |
|
113 | - public static function deregister($addon_name = '') |
|
114 | - { |
|
115 | - unset(self::$_settings[ $addon_name ]); |
|
116 | - } |
|
106 | + /** |
|
107 | + * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
108 | + * |
|
109 | + * @since 4.3.0 |
|
110 | + * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
111 | + * @return void |
|
112 | + */ |
|
113 | + public static function deregister($addon_name = '') |
|
114 | + { |
|
115 | + unset(self::$_settings[ $addon_name ]); |
|
116 | + } |
|
117 | 117 | } |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | ); |
48 | 48 | } |
49 | 49 | // make sure we don't register twice |
50 | - if (isset(self::$_settings[ $addon_name ])) { |
|
50 | + if (isset(self::$_settings[$addon_name])) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | // make sure this was called in the right place! |
54 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
54 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
55 | 55 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
56 | 56 | ) { |
57 | 57 | EE_Error::doing_it_wrong( |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ); |
65 | 65 | } |
66 | 66 | // setup $_settings array from incoming values. |
67 | - self::$_settings[ $addon_name ] = array( |
|
67 | + self::$_settings[$addon_name] = array( |
|
68 | 68 | 'dms_paths' => (array) $setup_args['dms_paths'], |
69 | 69 | ); |
70 | 70 | // setup DMS |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
73 | 73 | ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
74 | 74 | ); |
75 | - if (! $filters_set) { |
|
75 | + if ( ! $filters_set) { |
|
76 | 76 | add_filter( |
77 | 77 | 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
78 | 78 | ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // so if for some reason an addon has multiple dms paths, |
96 | 96 | // we append one or more * to the classname |
97 | 97 | // which will get stripped out later on |
98 | - $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
98 | + $dms_paths[$addon_name.str_repeat('*', $wildcards)] = $dms_path; |
|
99 | 99 | $wildcards++; |
100 | 100 | } |
101 | 101 | } |
@@ -112,6 +112,6 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function deregister($addon_name = '') |
114 | 114 | { |
115 | - unset(self::$_settings[ $addon_name ]); |
|
115 | + unset(self::$_settings[$addon_name]); |
|
116 | 116 | } |
117 | 117 | } |
@@ -37,122 +37,122 @@ |
||
37 | 37 | * @since 4.0 |
38 | 38 | */ |
39 | 39 | if (function_exists('espresso_version')) { |
40 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
41 | - /** |
|
42 | - * espresso_duplicate_plugin_error |
|
43 | - * displays if more than one version of EE is activated at the same time |
|
44 | - */ |
|
45 | - function espresso_duplicate_plugin_error() |
|
46 | - { |
|
47 | - ?> |
|
40 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
41 | + /** |
|
42 | + * espresso_duplicate_plugin_error |
|
43 | + * displays if more than one version of EE is activated at the same time |
|
44 | + */ |
|
45 | + function espresso_duplicate_plugin_error() |
|
46 | + { |
|
47 | + ?> |
|
48 | 48 | <div class="error"> |
49 | 49 | <p> |
50 | 50 | <?php |
51 | - echo esc_html__( |
|
52 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
53 | - 'event_espresso' |
|
54 | - ); ?> |
|
51 | + echo esc_html__( |
|
52 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
53 | + 'event_espresso' |
|
54 | + ); ?> |
|
55 | 55 | </p> |
56 | 56 | </div> |
57 | 57 | <?php |
58 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
59 | - } |
|
60 | - } |
|
61 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
58 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
59 | + } |
|
60 | + } |
|
61 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | 62 | } else { |
63 | - define('EE_MIN_PHP_VER_REQUIRED', '7.1.0'); |
|
64 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
65 | - /** |
|
66 | - * espresso_minimum_php_version_error |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - function espresso_minimum_php_version_error() |
|
71 | - { |
|
72 | - ?> |
|
63 | + define('EE_MIN_PHP_VER_REQUIRED', '7.1.0'); |
|
64 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
65 | + /** |
|
66 | + * espresso_minimum_php_version_error |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + function espresso_minimum_php_version_error() |
|
71 | + { |
|
72 | + ?> |
|
73 | 73 | <div class="error"> |
74 | 74 | <p> |
75 | 75 | <?php |
76 | - printf( |
|
77 | - esc_html__( |
|
78 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
79 | - 'event_espresso' |
|
80 | - ), |
|
81 | - EE_MIN_PHP_VER_REQUIRED, |
|
82 | - PHP_VERSION, |
|
83 | - '<br/>', |
|
84 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
85 | - ); |
|
86 | - ?> |
|
76 | + printf( |
|
77 | + esc_html__( |
|
78 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
79 | + 'event_espresso' |
|
80 | + ), |
|
81 | + EE_MIN_PHP_VER_REQUIRED, |
|
82 | + PHP_VERSION, |
|
83 | + '<br/>', |
|
84 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
85 | + ); |
|
86 | + ?> |
|
87 | 87 | </p> |
88 | 88 | </div> |
89 | 89 | <?php |
90 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
91 | - } |
|
90 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
91 | + } |
|
92 | 92 | |
93 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
94 | - } else { |
|
95 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.059'); |
|
105 | - } |
|
93 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
94 | + } else { |
|
95 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.059'); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * espresso_plugin_activation |
|
109 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
110 | - */ |
|
111 | - function espresso_plugin_activation() |
|
112 | - { |
|
113 | - update_option('ee_espresso_activation', true); |
|
107 | + /** |
|
108 | + * espresso_plugin_activation |
|
109 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
110 | + */ |
|
111 | + function espresso_plugin_activation() |
|
112 | + { |
|
113 | + update_option('ee_espresso_activation', true); |
|
114 | 114 | |
115 | - // Run WP GraphQL activation callback |
|
116 | - if (! class_exists('WPGraphQL')) { |
|
117 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
118 | - } |
|
119 | - graphql_init()->activate(); |
|
120 | - } |
|
115 | + // Run WP GraphQL activation callback |
|
116 | + if (! class_exists('WPGraphQL')) { |
|
117 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
118 | + } |
|
119 | + graphql_init()->activate(); |
|
120 | + } |
|
121 | 121 | |
122 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
122 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
123 | 123 | |
124 | - /** |
|
125 | - * espresso_plugin_deactivation |
|
126 | - */ |
|
127 | - function espresso_plugin_deactivation() |
|
128 | - { |
|
129 | - // Run WP GraphQL deactivation callback |
|
130 | - if (! class_exists('WPGraphQL')) { |
|
131 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
132 | - } |
|
133 | - graphql_init()->deactivate(); |
|
134 | - } |
|
135 | - register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
124 | + /** |
|
125 | + * espresso_plugin_deactivation |
|
126 | + */ |
|
127 | + function espresso_plugin_deactivation() |
|
128 | + { |
|
129 | + // Run WP GraphQL deactivation callback |
|
130 | + if (! class_exists('WPGraphQL')) { |
|
131 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
132 | + } |
|
133 | + graphql_init()->deactivate(); |
|
134 | + } |
|
135 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
136 | 136 | |
137 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
138 | - bootstrap_espresso(); |
|
139 | - } |
|
137 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
138 | + bootstrap_espresso(); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | if (! function_exists('espresso_deactivate_plugin')) { |
142 | - /** |
|
143 | - * deactivate_plugin |
|
144 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
145 | - * |
|
146 | - * @access public |
|
147 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
151 | - { |
|
152 | - if (! function_exists('deactivate_plugins')) { |
|
153 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
154 | - } |
|
155 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
156 | - deactivate_plugins($plugin_basename); |
|
157 | - } |
|
142 | + /** |
|
143 | + * deactivate_plugin |
|
144 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
145 | + * |
|
146 | + * @access public |
|
147 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
151 | + { |
|
152 | + if (! function_exists('deactivate_plugins')) { |
|
153 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
154 | + } |
|
155 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
156 | + deactivate_plugins($plugin_basename); |
|
157 | + } |
|
158 | 158 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @since 4.0 |
38 | 38 | */ |
39 | 39 | if (function_exists('espresso_version')) { |
40 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
40 | + if ( ! function_exists('espresso_duplicate_plugin_error')) { |
|
41 | 41 | /** |
42 | 42 | * espresso_duplicate_plugin_error |
43 | 43 | * displays if more than one version of EE is activated at the same time |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
62 | 62 | } else { |
63 | 63 | define('EE_MIN_PHP_VER_REQUIRED', '7.1.0'); |
64 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
64 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
65 | 65 | /** |
66 | 66 | * espresso_minimum_php_version_error |
67 | 67 | * |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | update_option('ee_espresso_activation', true); |
114 | 114 | |
115 | 115 | // Run WP GraphQL activation callback |
116 | - if (! class_exists('WPGraphQL')) { |
|
117 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
116 | + if ( ! class_exists('WPGraphQL')) { |
|
117 | + require_once EE_THIRD_PARTY.'wp-graphql/wp-graphql.php'; |
|
118 | 118 | } |
119 | 119 | graphql_init()->activate(); |
120 | 120 | } |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | function espresso_plugin_deactivation() |
128 | 128 | { |
129 | 129 | // Run WP GraphQL deactivation callback |
130 | - if (! class_exists('WPGraphQL')) { |
|
131 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
130 | + if ( ! class_exists('WPGraphQL')) { |
|
131 | + require_once EE_THIRD_PARTY.'wp-graphql/wp-graphql.php'; |
|
132 | 132 | } |
133 | 133 | graphql_init()->deactivate(); |
134 | 134 | } |
135 | 135 | register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
136 | 136 | |
137 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
137 | + require_once __DIR__.'/core/bootstrap_espresso.php'; |
|
138 | 138 | bootstrap_espresso(); |
139 | 139 | } |
140 | 140 | } |
141 | -if (! function_exists('espresso_deactivate_plugin')) { |
|
141 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
142 | 142 | /** |
143 | 143 | * deactivate_plugin |
144 | 144 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function espresso_deactivate_plugin($plugin_basename = '') |
151 | 151 | { |
152 | - if (! function_exists('deactivate_plugins')) { |
|
153 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
152 | + if ( ! function_exists('deactivate_plugins')) { |
|
153 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
154 | 154 | } |
155 | 155 | unset($_GET['activate'], $_REQUEST['activate']); |
156 | 156 | deactivate_plugins($plugin_basename); |
@@ -16,45 +16,45 @@ |
||
16 | 16 | */ |
17 | 17 | class CurrentUser extends JsonDataNode |
18 | 18 | { |
19 | - const NODE_NAME = 'currentUser'; |
|
19 | + const NODE_NAME = 'currentUser'; |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @param JsonDataNodeValidator $validator |
|
24 | - */ |
|
25 | - public function __construct(JsonDataNodeValidator $validator) |
|
26 | - { |
|
27 | - if (! class_exists('WPGraphQL')) { |
|
28 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
29 | - } |
|
30 | - parent::__construct($validator); |
|
31 | - $this->setNodeName(CurrentUser::NODE_NAME); |
|
32 | - } |
|
22 | + /** |
|
23 | + * @param JsonDataNodeValidator $validator |
|
24 | + */ |
|
25 | + public function __construct(JsonDataNodeValidator $validator) |
|
26 | + { |
|
27 | + if (! class_exists('WPGraphQL')) { |
|
28 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
29 | + } |
|
30 | + parent::__construct($validator); |
|
31 | + $this->setNodeName(CurrentUser::NODE_NAME); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @inheritDoc |
|
36 | - */ |
|
37 | - public function initialize() |
|
38 | - { |
|
39 | - $current_user = wp_get_current_user(); |
|
40 | - if (! $current_user instanceof WP_User) { |
|
41 | - $current_user = new WP_User(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * @inheritDoc |
|
36 | + */ |
|
37 | + public function initialize() |
|
38 | + { |
|
39 | + $current_user = wp_get_current_user(); |
|
40 | + if (! $current_user instanceof WP_User) { |
|
41 | + $current_user = new WP_User(); |
|
42 | + } |
|
43 | 43 | |
44 | - if (class_exists(Relay::class)) { |
|
45 | - $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
46 | - } |
|
47 | - $this->addData('databaseId', $current_user->ID); |
|
48 | - $this->addData('description', $current_user->description); |
|
49 | - $this->addData('email', $current_user->user_email); |
|
50 | - $this->addData('firstName', $current_user->first_name); |
|
51 | - $this->addData('lastName', $current_user->last_name); |
|
52 | - $this->addData('locale', get_user_locale($current_user->ID)); |
|
53 | - $this->addData('name', $current_user->display_name); |
|
54 | - $this->addData('nicename', $current_user->user_nicename); |
|
55 | - $this->addData('nickname', $current_user->nickname); |
|
56 | - $this->addData('username', $current_user->user_login); |
|
57 | - $this->addData('__typename', 'User'); |
|
58 | - $this->setInitialized(true); |
|
59 | - } |
|
44 | + if (class_exists(Relay::class)) { |
|
45 | + $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
46 | + } |
|
47 | + $this->addData('databaseId', $current_user->ID); |
|
48 | + $this->addData('description', $current_user->description); |
|
49 | + $this->addData('email', $current_user->user_email); |
|
50 | + $this->addData('firstName', $current_user->first_name); |
|
51 | + $this->addData('lastName', $current_user->last_name); |
|
52 | + $this->addData('locale', get_user_locale($current_user->ID)); |
|
53 | + $this->addData('name', $current_user->display_name); |
|
54 | + $this->addData('nicename', $current_user->user_nicename); |
|
55 | + $this->addData('nickname', $current_user->nickname); |
|
56 | + $this->addData('username', $current_user->user_login); |
|
57 | + $this->addData('__typename', 'User'); |
|
58 | + $this->setInitialized(true); |
|
59 | + } |
|
60 | 60 | } |
@@ -19,207 +19,207 @@ |
||
19 | 19 | */ |
20 | 20 | class GQLRequests extends Route |
21 | 21 | { |
22 | - /** |
|
23 | - * @var AssetManifestFactory |
|
24 | - */ |
|
25 | - private $manifest_factory; |
|
22 | + /** |
|
23 | + * @var AssetManifestFactory |
|
24 | + */ |
|
25 | + private $manifest_factory; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * AssetRequests constructor. |
|
30 | - * |
|
31 | - * @param EE_Dependency_Map $dependency_map |
|
32 | - * @param LoaderInterface $loader |
|
33 | - * @param RequestInterface $request |
|
34 | - * @param AssetManifestFactory $manifest_factory |
|
35 | - */ |
|
36 | - public function __construct( |
|
37 | - EE_Dependency_Map $dependency_map, |
|
38 | - LoaderInterface $loader, |
|
39 | - RequestInterface $request, |
|
40 | - AssetManifestFactory $manifest_factory |
|
41 | - ) { |
|
42 | - $this->manifest_factory = $manifest_factory; |
|
43 | - parent::__construct($dependency_map, $loader, $request); |
|
44 | - } |
|
28 | + /** |
|
29 | + * AssetRequests constructor. |
|
30 | + * |
|
31 | + * @param EE_Dependency_Map $dependency_map |
|
32 | + * @param LoaderInterface $loader |
|
33 | + * @param RequestInterface $request |
|
34 | + * @param AssetManifestFactory $manifest_factory |
|
35 | + */ |
|
36 | + public function __construct( |
|
37 | + EE_Dependency_Map $dependency_map, |
|
38 | + LoaderInterface $loader, |
|
39 | + RequestInterface $request, |
|
40 | + AssetManifestFactory $manifest_factory |
|
41 | + ) { |
|
42 | + $this->manifest_factory = $manifest_factory; |
|
43 | + parent::__construct($dependency_map, $loader, $request); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * returns true if the current request matches this route |
|
49 | - * |
|
50 | - * @return bool |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function matchesCurrentRequest() |
|
54 | - { |
|
55 | - global $pagenow; |
|
56 | - return ( |
|
57 | - $this->request->isGQL() |
|
58 | - || $this->request->isUnitTesting() |
|
59 | - || ( |
|
60 | - $this->request->isAdmin() |
|
61 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
62 | - && ( |
|
63 | - $this->request->getRequestParam('action') === 'create_new' |
|
64 | - || $this->request->getRequestParam('action') === 'edit' |
|
65 | - ) |
|
66 | - ) |
|
67 | - || ( |
|
68 | - $pagenow |
|
69 | - && ( |
|
70 | - $pagenow === 'post-new.php' |
|
71 | - || ( |
|
72 | - $pagenow === 'post.php' |
|
73 | - && $this->request->getRequestParam('action') === 'edit' |
|
74 | - ) |
|
75 | - ) |
|
76 | - ) |
|
77 | - ); |
|
78 | - } |
|
47 | + /** |
|
48 | + * returns true if the current request matches this route |
|
49 | + * |
|
50 | + * @return bool |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function matchesCurrentRequest() |
|
54 | + { |
|
55 | + global $pagenow; |
|
56 | + return ( |
|
57 | + $this->request->isGQL() |
|
58 | + || $this->request->isUnitTesting() |
|
59 | + || ( |
|
60 | + $this->request->isAdmin() |
|
61 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
62 | + && ( |
|
63 | + $this->request->getRequestParam('action') === 'create_new' |
|
64 | + || $this->request->getRequestParam('action') === 'edit' |
|
65 | + ) |
|
66 | + ) |
|
67 | + || ( |
|
68 | + $pagenow |
|
69 | + && ( |
|
70 | + $pagenow === 'post-new.php' |
|
71 | + || ( |
|
72 | + $pagenow === 'post.php' |
|
73 | + && $this->request->getRequestParam('action') === 'edit' |
|
74 | + ) |
|
75 | + ) |
|
76 | + ) |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @since $VID:$ |
|
83 | - */ |
|
84 | - protected function registerDependencies() |
|
85 | - { |
|
86 | - $this->dependency_map->registerDependencies( |
|
87 | - 'EventEspresso\core\services\graphql\GraphQLManager', |
|
88 | - [ |
|
89 | - 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
90 | - 'EventEspresso\core\services\graphql\DataLoaderManager' => EE_Dependency_Map::load_from_cache, |
|
91 | - 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
92 | - 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
93 | - 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
94 | - ] |
|
95 | - ); |
|
96 | - $this->dependency_map->registerDependencies( |
|
97 | - 'EventEspresso\core\services\graphql\TypesManager', |
|
98 | - [ |
|
99 | - 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
100 | - ] |
|
101 | - ); |
|
102 | - $this->dependency_map->registerDependencies( |
|
103 | - 'EventEspresso\core\services\graphql\InputsManager', |
|
104 | - [ |
|
105 | - 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
106 | - ] |
|
107 | - ); |
|
108 | - $this->dependency_map->registerDependencies( |
|
109 | - 'EventEspresso\core\services\graphql\EnumsManager', |
|
110 | - [ |
|
111 | - 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
112 | - ] |
|
113 | - ); |
|
114 | - $this->dependency_map->registerDependencies( |
|
115 | - 'EventEspresso\core\services\graphql\ConnectionsManager', |
|
116 | - [ |
|
117 | - 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
118 | - ] |
|
119 | - ); |
|
120 | - $this->dependency_map->registerDependencies( |
|
121 | - 'EventEspresso\core\services\graphql\DataLoaderManager', |
|
122 | - [ |
|
123 | - 'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache, |
|
124 | - ] |
|
125 | - ); |
|
126 | - $this->dependency_map->registerDependencies( |
|
127 | - 'EventEspresso\core\domain\services\graphql\types\Datetime', |
|
128 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
129 | - ); |
|
130 | - $this->dependency_map->registerDependencies( |
|
131 | - 'EventEspresso\core\domain\services\graphql\types\Attendee', |
|
132 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
133 | - ); |
|
134 | - $this->dependency_map->registerDependencies( |
|
135 | - 'EventEspresso\core\domain\services\graphql\types\Event', |
|
136 | - ['EEM_Event' => EE_Dependency_Map::load_from_cache] |
|
137 | - ); |
|
138 | - $this->dependency_map->registerDependencies( |
|
139 | - 'EventEspresso\core\domain\services\graphql\types\Ticket', |
|
140 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
141 | - ); |
|
142 | - $this->dependency_map->registerDependencies( |
|
143 | - 'EventEspresso\core\domain\services\graphql\types\Price', |
|
144 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
145 | - ); |
|
146 | - $this->dependency_map->registerDependencies( |
|
147 | - 'EventEspresso\core\domain\services\graphql\types\PriceType', |
|
148 | - ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
149 | - ); |
|
150 | - $this->dependency_map->registerDependencies( |
|
151 | - 'EventEspresso\core\domain\services\graphql\types\Venue', |
|
152 | - ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
153 | - ); |
|
154 | - $this->dependency_map->registerDependencies( |
|
155 | - 'EventEspresso\core\domain\services\graphql\types\State', |
|
156 | - ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
157 | - ); |
|
158 | - $this->dependency_map->registerDependencies( |
|
159 | - 'EventEspresso\core\domain\services\graphql\types\Country', |
|
160 | - ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
161 | - ); |
|
162 | - $this->dependency_map->registerDependencies( |
|
163 | - 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection', |
|
164 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
165 | - ); |
|
166 | - $this->dependency_map->registerDependencies( |
|
167 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection', |
|
168 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
169 | - ); |
|
170 | - $this->dependency_map->registerDependencies( |
|
171 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection', |
|
172 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
173 | - ); |
|
174 | - $this->dependency_map->registerDependencies( |
|
175 | - 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection', |
|
176 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
177 | - ); |
|
178 | - $this->dependency_map->registerDependencies( |
|
179 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection', |
|
180 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
181 | - ); |
|
182 | - $this->dependency_map->registerDependencies( |
|
183 | - 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection', |
|
184 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
185 | - ); |
|
186 | - $this->dependency_map->registerDependencies( |
|
187 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection', |
|
188 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
189 | - ); |
|
190 | - $this->dependency_map->registerDependencies( |
|
191 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection', |
|
192 | - ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
193 | - ); |
|
194 | - $this->dependency_map->registerDependencies( |
|
195 | - 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection', |
|
196 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
197 | - ); |
|
198 | - $this->dependency_map->registerDependencies( |
|
199 | - 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection', |
|
200 | - ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
201 | - ); |
|
202 | - } |
|
81 | + /** |
|
82 | + * @since $VID:$ |
|
83 | + */ |
|
84 | + protected function registerDependencies() |
|
85 | + { |
|
86 | + $this->dependency_map->registerDependencies( |
|
87 | + 'EventEspresso\core\services\graphql\GraphQLManager', |
|
88 | + [ |
|
89 | + 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
90 | + 'EventEspresso\core\services\graphql\DataLoaderManager' => EE_Dependency_Map::load_from_cache, |
|
91 | + 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
92 | + 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
93 | + 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
94 | + ] |
|
95 | + ); |
|
96 | + $this->dependency_map->registerDependencies( |
|
97 | + 'EventEspresso\core\services\graphql\TypesManager', |
|
98 | + [ |
|
99 | + 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
100 | + ] |
|
101 | + ); |
|
102 | + $this->dependency_map->registerDependencies( |
|
103 | + 'EventEspresso\core\services\graphql\InputsManager', |
|
104 | + [ |
|
105 | + 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
106 | + ] |
|
107 | + ); |
|
108 | + $this->dependency_map->registerDependencies( |
|
109 | + 'EventEspresso\core\services\graphql\EnumsManager', |
|
110 | + [ |
|
111 | + 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
112 | + ] |
|
113 | + ); |
|
114 | + $this->dependency_map->registerDependencies( |
|
115 | + 'EventEspresso\core\services\graphql\ConnectionsManager', |
|
116 | + [ |
|
117 | + 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
118 | + ] |
|
119 | + ); |
|
120 | + $this->dependency_map->registerDependencies( |
|
121 | + 'EventEspresso\core\services\graphql\DataLoaderManager', |
|
122 | + [ |
|
123 | + 'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache, |
|
124 | + ] |
|
125 | + ); |
|
126 | + $this->dependency_map->registerDependencies( |
|
127 | + 'EventEspresso\core\domain\services\graphql\types\Datetime', |
|
128 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
129 | + ); |
|
130 | + $this->dependency_map->registerDependencies( |
|
131 | + 'EventEspresso\core\domain\services\graphql\types\Attendee', |
|
132 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
133 | + ); |
|
134 | + $this->dependency_map->registerDependencies( |
|
135 | + 'EventEspresso\core\domain\services\graphql\types\Event', |
|
136 | + ['EEM_Event' => EE_Dependency_Map::load_from_cache] |
|
137 | + ); |
|
138 | + $this->dependency_map->registerDependencies( |
|
139 | + 'EventEspresso\core\domain\services\graphql\types\Ticket', |
|
140 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
141 | + ); |
|
142 | + $this->dependency_map->registerDependencies( |
|
143 | + 'EventEspresso\core\domain\services\graphql\types\Price', |
|
144 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
145 | + ); |
|
146 | + $this->dependency_map->registerDependencies( |
|
147 | + 'EventEspresso\core\domain\services\graphql\types\PriceType', |
|
148 | + ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
149 | + ); |
|
150 | + $this->dependency_map->registerDependencies( |
|
151 | + 'EventEspresso\core\domain\services\graphql\types\Venue', |
|
152 | + ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
153 | + ); |
|
154 | + $this->dependency_map->registerDependencies( |
|
155 | + 'EventEspresso\core\domain\services\graphql\types\State', |
|
156 | + ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
157 | + ); |
|
158 | + $this->dependency_map->registerDependencies( |
|
159 | + 'EventEspresso\core\domain\services\graphql\types\Country', |
|
160 | + ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
161 | + ); |
|
162 | + $this->dependency_map->registerDependencies( |
|
163 | + 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection', |
|
164 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
165 | + ); |
|
166 | + $this->dependency_map->registerDependencies( |
|
167 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection', |
|
168 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
169 | + ); |
|
170 | + $this->dependency_map->registerDependencies( |
|
171 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection', |
|
172 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
173 | + ); |
|
174 | + $this->dependency_map->registerDependencies( |
|
175 | + 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection', |
|
176 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
177 | + ); |
|
178 | + $this->dependency_map->registerDependencies( |
|
179 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection', |
|
180 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
181 | + ); |
|
182 | + $this->dependency_map->registerDependencies( |
|
183 | + 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection', |
|
184 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
185 | + ); |
|
186 | + $this->dependency_map->registerDependencies( |
|
187 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection', |
|
188 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
189 | + ); |
|
190 | + $this->dependency_map->registerDependencies( |
|
191 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection', |
|
192 | + ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
193 | + ); |
|
194 | + $this->dependency_map->registerDependencies( |
|
195 | + 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection', |
|
196 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
197 | + ); |
|
198 | + $this->dependency_map->registerDependencies( |
|
199 | + 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection', |
|
200 | + ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
201 | + ); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | |
205 | - /** |
|
206 | - * implements logic required to run during request |
|
207 | - * |
|
208 | - * @return bool |
|
209 | - * @since $VID:$ |
|
210 | - */ |
|
211 | - protected function requestHandler() |
|
212 | - { |
|
213 | - if (! class_exists('WPGraphQL')) { |
|
214 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
215 | - } |
|
216 | - // load handler for EE GraphQL requests |
|
217 | - $graphQL_manager = $this->loader->getShared( |
|
218 | - 'EventEspresso\core\services\graphql\GraphQLManager' |
|
219 | - ); |
|
220 | - $graphQL_manager->init(); |
|
221 | - $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain()); |
|
222 | - $manifest->initialize(); |
|
223 | - return true; |
|
224 | - } |
|
205 | + /** |
|
206 | + * implements logic required to run during request |
|
207 | + * |
|
208 | + * @return bool |
|
209 | + * @since $VID:$ |
|
210 | + */ |
|
211 | + protected function requestHandler() |
|
212 | + { |
|
213 | + if (! class_exists('WPGraphQL')) { |
|
214 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
215 | + } |
|
216 | + // load handler for EE GraphQL requests |
|
217 | + $graphQL_manager = $this->loader->getShared( |
|
218 | + 'EventEspresso\core\services\graphql\GraphQLManager' |
|
219 | + ); |
|
220 | + $graphQL_manager->init(); |
|
221 | + $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain()); |
|
222 | + $manifest->initialize(); |
|
223 | + return true; |
|
224 | + } |
|
225 | 225 | } |
@@ -19,127 +19,127 @@ |
||
19 | 19 | class EspressoEventEditor extends EspressoEventsAdmin |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * returns true if the current request matches this route |
|
24 | - * |
|
25 | - * @return bool |
|
26 | - * @since $VID:$ |
|
27 | - */ |
|
28 | - public function matchesCurrentRequest() |
|
29 | - { |
|
30 | - return parent::matchesCurrentRequest() |
|
31 | - && $this->admin_config->useAdvancedEditor() |
|
32 | - && ( |
|
33 | - $this->request->getRequestParam('action') === 'create_new' |
|
34 | - || $this->request->getRequestParam('action') === 'edit' |
|
35 | - ); |
|
36 | - } |
|
22 | + /** |
|
23 | + * returns true if the current request matches this route |
|
24 | + * |
|
25 | + * @return bool |
|
26 | + * @since $VID:$ |
|
27 | + */ |
|
28 | + public function matchesCurrentRequest() |
|
29 | + { |
|
30 | + return parent::matchesCurrentRequest() |
|
31 | + && $this->admin_config->useAdvancedEditor() |
|
32 | + && ( |
|
33 | + $this->request->getRequestParam('action') === 'create_new' |
|
34 | + || $this->request->getRequestParam('action') === 'edit' |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - protected function registerDependencies() |
|
43 | - { |
|
44 | - $this->dependency_map->registerDependencies( |
|
45 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData', |
|
46 | - [ |
|
47 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
48 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
49 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
50 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
51 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
52 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | - ] |
|
54 | - ); |
|
55 | - $this->dependency_map->registerDependencies( |
|
56 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations', |
|
57 | - [ |
|
58 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | - ] |
|
64 | - ); |
|
65 | - $this->dependency_map->registerDependencies( |
|
66 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities', |
|
67 | - [ |
|
68 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
74 | - ] |
|
75 | - ); |
|
76 | - $this->dependency_map->registerDependencies( |
|
77 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes', |
|
78 | - [ |
|
79 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | - ] |
|
82 | - ); |
|
83 | - $this->dependency_map->registerDependencies( |
|
84 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets', |
|
85 | - [ |
|
86 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
87 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
88 | - ] |
|
89 | - ); |
|
90 | - $this->dependency_map->registerDependencies( |
|
91 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices', |
|
92 | - [ |
|
93 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
94 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
95 | - ] |
|
96 | - ); |
|
97 | - $this->dependency_map->registerDependencies( |
|
98 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor', |
|
99 | - [ |
|
100 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
101 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
102 | - ] |
|
103 | - ); |
|
104 | - $this->dependency_map->registerDependencies( |
|
105 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager', |
|
106 | - [ |
|
107 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
108 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
109 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
110 | - ] |
|
111 | - ); |
|
112 | - $this->loader->getShared( |
|
113 | - 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' |
|
114 | - ); |
|
115 | - /** @var EventEditor $data_node */ |
|
116 | - $data_node = $this->loader->getShared( |
|
117 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' |
|
118 | - ); |
|
119 | - $this->setDataNode($data_node); |
|
120 | - } |
|
39 | + /** |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + protected function registerDependencies() |
|
43 | + { |
|
44 | + $this->dependency_map->registerDependencies( |
|
45 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData', |
|
46 | + [ |
|
47 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
48 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
49 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
50 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
51 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
52 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | + ] |
|
54 | + ); |
|
55 | + $this->dependency_map->registerDependencies( |
|
56 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations', |
|
57 | + [ |
|
58 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | + ] |
|
64 | + ); |
|
65 | + $this->dependency_map->registerDependencies( |
|
66 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities', |
|
67 | + [ |
|
68 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
74 | + ] |
|
75 | + ); |
|
76 | + $this->dependency_map->registerDependencies( |
|
77 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes', |
|
78 | + [ |
|
79 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | + ] |
|
82 | + ); |
|
83 | + $this->dependency_map->registerDependencies( |
|
84 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets', |
|
85 | + [ |
|
86 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
87 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
88 | + ] |
|
89 | + ); |
|
90 | + $this->dependency_map->registerDependencies( |
|
91 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices', |
|
92 | + [ |
|
93 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
94 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
95 | + ] |
|
96 | + ); |
|
97 | + $this->dependency_map->registerDependencies( |
|
98 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor', |
|
99 | + [ |
|
100 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
101 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
102 | + ] |
|
103 | + ); |
|
104 | + $this->dependency_map->registerDependencies( |
|
105 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager', |
|
106 | + [ |
|
107 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
108 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
109 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
110 | + ] |
|
111 | + ); |
|
112 | + $this->loader->getShared( |
|
113 | + 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' |
|
114 | + ); |
|
115 | + /** @var EventEditor $data_node */ |
|
116 | + $data_node = $this->loader->getShared( |
|
117 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' |
|
118 | + ); |
|
119 | + $this->setDataNode($data_node); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * implements logic required to run during request |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - * @since $VID:$ |
|
128 | - */ |
|
129 | - protected function requestHandler() |
|
130 | - { |
|
131 | - if (! class_exists('WPGraphQL')) { |
|
132 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | - } |
|
134 | - /** @var GraphQLManager $graphQL_manager */ |
|
135 | - $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | - $graphQL_manager->init(); |
|
123 | + /** |
|
124 | + * implements logic required to run during request |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + * @since $VID:$ |
|
128 | + */ |
|
129 | + protected function requestHandler() |
|
130 | + { |
|
131 | + if (! class_exists('WPGraphQL')) { |
|
132 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | + } |
|
134 | + /** @var GraphQLManager $graphQL_manager */ |
|
135 | + $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | + $graphQL_manager->init(); |
|
137 | 137 | |
138 | - /** @var EventEditorAssetManager $asset_manager */ |
|
139 | - $asset_manager = $this->loader->getShared( |
|
140 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | - ); |
|
142 | - add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | - return true; |
|
144 | - } |
|
138 | + /** @var EventEditorAssetManager $asset_manager */ |
|
139 | + $asset_manager = $this->loader->getShared( |
|
140 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | + ); |
|
142 | + add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | + return true; |
|
144 | + } |
|
145 | 145 | } |
@@ -128,8 +128,8 @@ |
||
128 | 128 | */ |
129 | 129 | protected function requestHandler() |
130 | 130 | { |
131 | - if (! class_exists('WPGraphQL')) { |
|
132 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
131 | + if ( ! class_exists('WPGraphQL')) { |
|
132 | + require_once EE_THIRD_PARTY.'wp-graphql/wp-graphql.php'; |
|
133 | 133 | } |
134 | 134 | /** @var GraphQLManager $graphQL_manager */ |
135 | 135 | $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
@@ -21,174 +21,174 @@ |
||
21 | 21 | class RouteHandler |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var JsonDataNodeHandler $data_node_handler |
|
26 | - */ |
|
27 | - private $data_node_handler; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var LoaderInterface $loader |
|
31 | - */ |
|
32 | - private $loader; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var RequestInterface $request |
|
36 | - */ |
|
37 | - protected $request; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var RouteCollection $routes |
|
41 | - */ |
|
42 | - private $routes; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var boolean $print_data_nodes |
|
46 | - */ |
|
47 | - private $print_data_nodes = true; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string $route_request_type |
|
51 | - */ |
|
52 | - protected $route_request_type; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * RouteHandler constructor. |
|
57 | - * |
|
58 | - * @param JsonDataNodeHandler $data_node_handler |
|
59 | - * @param LoaderInterface $loader |
|
60 | - * @param RequestInterface $request |
|
61 | - * @param RouteCollection $routes |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - JsonDataNodeHandler $data_node_handler, |
|
65 | - LoaderInterface $loader, |
|
66 | - RequestInterface $request, |
|
67 | - RouteCollection $routes |
|
68 | - ) { |
|
69 | - $this->data_node_handler = $data_node_handler; |
|
70 | - $this->loader = $loader; |
|
71 | - $this->request = $request; |
|
72 | - $this->routes = $routes; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $fqcn Fully Qualified Class Name for Route |
|
78 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
79 | - * @throws Exception |
|
80 | - * @since $VID:$ |
|
81 | - */ |
|
82 | - public function addRoute($fqcn, $handle = true) |
|
83 | - { |
|
84 | - try { |
|
85 | - $route = $this->loader->getShared($fqcn); |
|
86 | - $this->validateRoute($route, $fqcn); |
|
87 | - $this->routes->add($route); |
|
88 | - $this->handle($route, $handle); |
|
89 | - } catch (Exception $exception) { |
|
90 | - new ExceptionStackTraceDisplay( |
|
91 | - new DomainException( |
|
92 | - sprintf( |
|
93 | - esc_html__( |
|
94 | - 'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - $fqcn, |
|
98 | - '<br />', |
|
99 | - $exception->getMessage() |
|
100 | - ) |
|
101 | - ) |
|
102 | - ); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function getRouteRequestType() |
|
111 | - { |
|
112 | - return $this->route_request_type; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $route_request_type |
|
118 | - */ |
|
119 | - public function setRouteRequestType($route_request_type) |
|
120 | - { |
|
121 | - $this->route_request_type = $route_request_type !== null ? $route_request_type : $this->route_request_type; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @param RouteInterface $route |
|
127 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
128 | - */ |
|
129 | - public function handle(RouteInterface $route, $handle = true) |
|
130 | - { |
|
131 | - if ($handle && $route->isNotHandled()) { |
|
132 | - $route->handleRequest(); |
|
133 | - if ($route instanceof PrimaryRoute) { |
|
134 | - $this->setRouteRequestType($route->getRouteRequestType()); |
|
135 | - } |
|
136 | - $data_node = $route->dataNode(); |
|
137 | - if ($data_node instanceof JsonDataNode) { |
|
138 | - $this->data_node_handler->addDataNode($data_node); |
|
139 | - $this->printDataNodes(); |
|
140 | - } |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * calls RouteInterface::handleRequest() on all Routes that |
|
147 | - * - match current request |
|
148 | - * - have yet to be handled |
|
149 | - * |
|
150 | - * @return void |
|
151 | - */ |
|
152 | - public function handleRoutesForCurrentRequest() |
|
153 | - { |
|
154 | - $this->routes->handleRoutesForCurrentRequest(); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @since $VID:$ |
|
160 | - */ |
|
161 | - private function printDataNodes() |
|
162 | - { |
|
163 | - if ($this->print_data_nodes) { |
|
164 | - add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
165 | - add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
166 | - $this->print_data_nodes = false; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param RouteInterface $route |
|
173 | - * @param string $fqcn |
|
174 | - * @since $VID:$ |
|
175 | - */ |
|
176 | - private function validateRoute($route, $fqcn) |
|
177 | - { |
|
178 | - if (! $route instanceof RouteInterface) { |
|
179 | - throw new InvalidClassException( |
|
180 | - sprintf( |
|
181 | - /* |
|
24 | + /** |
|
25 | + * @var JsonDataNodeHandler $data_node_handler |
|
26 | + */ |
|
27 | + private $data_node_handler; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var LoaderInterface $loader |
|
31 | + */ |
|
32 | + private $loader; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var RequestInterface $request |
|
36 | + */ |
|
37 | + protected $request; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var RouteCollection $routes |
|
41 | + */ |
|
42 | + private $routes; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var boolean $print_data_nodes |
|
46 | + */ |
|
47 | + private $print_data_nodes = true; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string $route_request_type |
|
51 | + */ |
|
52 | + protected $route_request_type; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * RouteHandler constructor. |
|
57 | + * |
|
58 | + * @param JsonDataNodeHandler $data_node_handler |
|
59 | + * @param LoaderInterface $loader |
|
60 | + * @param RequestInterface $request |
|
61 | + * @param RouteCollection $routes |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + JsonDataNodeHandler $data_node_handler, |
|
65 | + LoaderInterface $loader, |
|
66 | + RequestInterface $request, |
|
67 | + RouteCollection $routes |
|
68 | + ) { |
|
69 | + $this->data_node_handler = $data_node_handler; |
|
70 | + $this->loader = $loader; |
|
71 | + $this->request = $request; |
|
72 | + $this->routes = $routes; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $fqcn Fully Qualified Class Name for Route |
|
78 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
79 | + * @throws Exception |
|
80 | + * @since $VID:$ |
|
81 | + */ |
|
82 | + public function addRoute($fqcn, $handle = true) |
|
83 | + { |
|
84 | + try { |
|
85 | + $route = $this->loader->getShared($fqcn); |
|
86 | + $this->validateRoute($route, $fqcn); |
|
87 | + $this->routes->add($route); |
|
88 | + $this->handle($route, $handle); |
|
89 | + } catch (Exception $exception) { |
|
90 | + new ExceptionStackTraceDisplay( |
|
91 | + new DomainException( |
|
92 | + sprintf( |
|
93 | + esc_html__( |
|
94 | + 'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + $fqcn, |
|
98 | + '<br />', |
|
99 | + $exception->getMessage() |
|
100 | + ) |
|
101 | + ) |
|
102 | + ); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function getRouteRequestType() |
|
111 | + { |
|
112 | + return $this->route_request_type; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $route_request_type |
|
118 | + */ |
|
119 | + public function setRouteRequestType($route_request_type) |
|
120 | + { |
|
121 | + $this->route_request_type = $route_request_type !== null ? $route_request_type : $this->route_request_type; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @param RouteInterface $route |
|
127 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
128 | + */ |
|
129 | + public function handle(RouteInterface $route, $handle = true) |
|
130 | + { |
|
131 | + if ($handle && $route->isNotHandled()) { |
|
132 | + $route->handleRequest(); |
|
133 | + if ($route instanceof PrimaryRoute) { |
|
134 | + $this->setRouteRequestType($route->getRouteRequestType()); |
|
135 | + } |
|
136 | + $data_node = $route->dataNode(); |
|
137 | + if ($data_node instanceof JsonDataNode) { |
|
138 | + $this->data_node_handler->addDataNode($data_node); |
|
139 | + $this->printDataNodes(); |
|
140 | + } |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * calls RouteInterface::handleRequest() on all Routes that |
|
147 | + * - match current request |
|
148 | + * - have yet to be handled |
|
149 | + * |
|
150 | + * @return void |
|
151 | + */ |
|
152 | + public function handleRoutesForCurrentRequest() |
|
153 | + { |
|
154 | + $this->routes->handleRoutesForCurrentRequest(); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @since $VID:$ |
|
160 | + */ |
|
161 | + private function printDataNodes() |
|
162 | + { |
|
163 | + if ($this->print_data_nodes) { |
|
164 | + add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
165 | + add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
166 | + $this->print_data_nodes = false; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param RouteInterface $route |
|
173 | + * @param string $fqcn |
|
174 | + * @since $VID:$ |
|
175 | + */ |
|
176 | + private function validateRoute($route, $fqcn) |
|
177 | + { |
|
178 | + if (! $route instanceof RouteInterface) { |
|
179 | + throw new InvalidClassException( |
|
180 | + sprintf( |
|
181 | + /* |
|
182 | 182 | * translators: |
183 | 183 | * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface. |
184 | 184 | */ |
185 | - esc_html__( |
|
186 | - 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
187 | - 'event_espresso' |
|
188 | - ), |
|
189 | - $fqcn |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - } |
|
185 | + esc_html__( |
|
186 | + 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
187 | + 'event_espresso' |
|
188 | + ), |
|
189 | + $fqcn |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + } |
|
194 | 194 | } |