@@ -15,226 +15,226 @@ |
||
15 | 15 | */ |
16 | 16 | class I18nRegistry |
17 | 17 | { |
18 | - /** |
|
19 | - * @var DomainInterface |
|
20 | - */ |
|
21 | - private $domain; |
|
22 | - |
|
23 | - /** |
|
24 | - * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - private $registered_i18n = array(); |
|
29 | - |
|
30 | - /** |
|
31 | - * Used to hold queued translations for the chunks loading in a view. |
|
32 | - * |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - private $queued_handle_translations = array(); |
|
36 | - |
|
37 | - /** |
|
38 | - * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
39 | - * |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - private $queued_scripts = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
46 | - * translation strings. |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - private $i18n_map; |
|
51 | - |
|
52 | - /** |
|
53 | - * I18nRegistry constructor. |
|
54 | - * |
|
55 | - * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
56 | - * provided, the class will look for map in root of plugin with filename of |
|
57 | - * 'translation-map.json'. |
|
58 | - * @param DomainInterface $domain |
|
59 | - */ |
|
60 | - public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
61 | - { |
|
62 | - $this->domain = $domain; |
|
63 | - $this->setI18nMap($i18n_map); |
|
64 | - add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Used to register a script that has i18n strings for its $handle |
|
69 | - * |
|
70 | - * @param string $handle The script handle reference. |
|
71 | - * @param string $domain The i18n domain for the strings. |
|
72 | - */ |
|
73 | - public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
74 | - { |
|
75 | - if (!isset($this->registered_i18n[$handle])) { |
|
76 | - $this->registered_i18n[$handle] = 1; |
|
77 | - $this->queued_scripts[$handle] = $domain; |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
83 | - * |
|
84 | - * @param array $handles Array of registered script handles. |
|
85 | - * @return array |
|
86 | - */ |
|
87 | - public function queueI18n(array $handles) |
|
88 | - { |
|
89 | - if (empty($this->queued_scripts)) { |
|
90 | - return $handles; |
|
91 | - } |
|
92 | - foreach ($handles as $handle) { |
|
93 | - $this->queueI18nTranslationsForHandle($handle); |
|
94 | - } |
|
95 | - if ($this->queued_handle_translations) { |
|
96 | - foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
97 | - $this->registerInlineScript( |
|
98 | - $handle, |
|
99 | - $translations_for_domain['translations'], |
|
100 | - $translations_for_domain['domain'] |
|
101 | - ); |
|
102 | - unset($this->queued_handle_translations[$handle]); |
|
103 | - } |
|
104 | - } |
|
105 | - return $handles; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Registers inline script with translations for given handle and domain. |
|
110 | - * |
|
111 | - * @param string $handle Handle used to register javascript file containing translations. |
|
112 | - * @param array $translations Array of string translations. |
|
113 | - * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
114 | - * domain for the javascript. |
|
115 | - */ |
|
116 | - protected function registerInlineScript($handle, array $translations, $domain) |
|
117 | - { |
|
118 | - $script = $domain ? |
|
119 | - 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
120 | - 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
121 | - wp_add_inline_script($handle, $script, 'before'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Queues up the translation strings for the given handle. |
|
126 | - * |
|
127 | - * @param string $handle The script handle being queued up. |
|
128 | - */ |
|
129 | - private function queueI18nTranslationsForHandle($handle) |
|
130 | - { |
|
131 | - if (isset($this->queued_scripts[$handle])) { |
|
132 | - $domain = $this->queued_scripts[$handle]; |
|
133 | - $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
134 | - if (count($translations) > 0) { |
|
135 | - $this->queued_handle_translations[$handle] = array( |
|
136 | - 'domain' => $domain, |
|
137 | - 'translations' => $translations, |
|
138 | - ); |
|
139 | - } |
|
140 | - unset($this->queued_scripts[$handle]); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Sets the internal i18n_map property. |
|
146 | - * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
147 | - * |
|
148 | - * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
149 | - * correspond to. |
|
150 | - */ |
|
151 | - private function setI18nMap(array $i18n_map) |
|
152 | - { |
|
153 | - if (empty($i18n_map)) { |
|
154 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
155 | - ? json_decode( |
|
156 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
157 | - true |
|
158 | - ) |
|
159 | - : array(); |
|
160 | - } |
|
161 | - $this->i18n_map = $i18n_map; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Get the jed locale data for a given $handle and domain |
|
166 | - * |
|
167 | - * @param string $handle The name for the script handle we want strings returned for. |
|
168 | - * @param string $domain The i18n domain. |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
172 | - { |
|
173 | - $translations = $this->getJedLocaleData($domain); |
|
174 | - // get index for adding back after extracting strings for this $chunk. |
|
175 | - $index = $translations['']; |
|
176 | - $translations = $this->getLocaleDataMatchingMap( |
|
177 | - $this->getOriginalStringsForHandleFromMap($handle), |
|
178 | - $translations |
|
179 | - ); |
|
180 | - $translations[''] = $index; |
|
181 | - return $translations; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Get locale data for given strings from given translations |
|
186 | - * |
|
187 | - * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
188 | - * @param array $translations Translation data to extra strings from. |
|
189 | - * @return array |
|
190 | - */ |
|
191 | - protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
192 | - { |
|
193 | - if (empty($string_set)) { |
|
194 | - return array(); |
|
195 | - } |
|
196 | - // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
197 | - // slashed also filter falsey values. |
|
198 | - $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
199 | - return array_intersect_key($translations, array_flip($string_set)); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Get original strings to translate for the given chunk from the map |
|
204 | - * |
|
205 | - * @param string $handle The script handle name to get strings from the map for. |
|
206 | - * @return array |
|
207 | - */ |
|
208 | - protected function getOriginalStringsForHandleFromMap($handle) |
|
209 | - { |
|
210 | - return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Returns Jed-formatted localization data. |
|
215 | - * |
|
216 | - * @param string $domain Translation domain. |
|
217 | - * @return array |
|
218 | - */ |
|
219 | - private function getJedLocaleData($domain) |
|
220 | - { |
|
221 | - $translations = get_translations_for_domain($domain); |
|
222 | - |
|
223 | - $locale = array( |
|
224 | - '' => array( |
|
225 | - 'domain' => $domain, |
|
226 | - 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale(), |
|
227 | - ), |
|
228 | - ); |
|
229 | - |
|
230 | - if (!empty($translations->headers['Plural-Forms'])) { |
|
231 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
232 | - } |
|
233 | - |
|
234 | - foreach ($translations->entries as $msgid => $entry) { |
|
235 | - $locale[$msgid] = $entry->translations; |
|
236 | - } |
|
237 | - |
|
238 | - return $locale; |
|
239 | - } |
|
18 | + /** |
|
19 | + * @var DomainInterface |
|
20 | + */ |
|
21 | + private $domain; |
|
22 | + |
|
23 | + /** |
|
24 | + * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + private $registered_i18n = array(); |
|
29 | + |
|
30 | + /** |
|
31 | + * Used to hold queued translations for the chunks loading in a view. |
|
32 | + * |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + private $queued_handle_translations = array(); |
|
36 | + |
|
37 | + /** |
|
38 | + * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
39 | + * |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + private $queued_scripts = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
46 | + * translation strings. |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + private $i18n_map; |
|
51 | + |
|
52 | + /** |
|
53 | + * I18nRegistry constructor. |
|
54 | + * |
|
55 | + * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
56 | + * provided, the class will look for map in root of plugin with filename of |
|
57 | + * 'translation-map.json'. |
|
58 | + * @param DomainInterface $domain |
|
59 | + */ |
|
60 | + public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
61 | + { |
|
62 | + $this->domain = $domain; |
|
63 | + $this->setI18nMap($i18n_map); |
|
64 | + add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Used to register a script that has i18n strings for its $handle |
|
69 | + * |
|
70 | + * @param string $handle The script handle reference. |
|
71 | + * @param string $domain The i18n domain for the strings. |
|
72 | + */ |
|
73 | + public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
74 | + { |
|
75 | + if (!isset($this->registered_i18n[$handle])) { |
|
76 | + $this->registered_i18n[$handle] = 1; |
|
77 | + $this->queued_scripts[$handle] = $domain; |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
83 | + * |
|
84 | + * @param array $handles Array of registered script handles. |
|
85 | + * @return array |
|
86 | + */ |
|
87 | + public function queueI18n(array $handles) |
|
88 | + { |
|
89 | + if (empty($this->queued_scripts)) { |
|
90 | + return $handles; |
|
91 | + } |
|
92 | + foreach ($handles as $handle) { |
|
93 | + $this->queueI18nTranslationsForHandle($handle); |
|
94 | + } |
|
95 | + if ($this->queued_handle_translations) { |
|
96 | + foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
97 | + $this->registerInlineScript( |
|
98 | + $handle, |
|
99 | + $translations_for_domain['translations'], |
|
100 | + $translations_for_domain['domain'] |
|
101 | + ); |
|
102 | + unset($this->queued_handle_translations[$handle]); |
|
103 | + } |
|
104 | + } |
|
105 | + return $handles; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Registers inline script with translations for given handle and domain. |
|
110 | + * |
|
111 | + * @param string $handle Handle used to register javascript file containing translations. |
|
112 | + * @param array $translations Array of string translations. |
|
113 | + * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
114 | + * domain for the javascript. |
|
115 | + */ |
|
116 | + protected function registerInlineScript($handle, array $translations, $domain) |
|
117 | + { |
|
118 | + $script = $domain ? |
|
119 | + 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
120 | + 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
121 | + wp_add_inline_script($handle, $script, 'before'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Queues up the translation strings for the given handle. |
|
126 | + * |
|
127 | + * @param string $handle The script handle being queued up. |
|
128 | + */ |
|
129 | + private function queueI18nTranslationsForHandle($handle) |
|
130 | + { |
|
131 | + if (isset($this->queued_scripts[$handle])) { |
|
132 | + $domain = $this->queued_scripts[$handle]; |
|
133 | + $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
134 | + if (count($translations) > 0) { |
|
135 | + $this->queued_handle_translations[$handle] = array( |
|
136 | + 'domain' => $domain, |
|
137 | + 'translations' => $translations, |
|
138 | + ); |
|
139 | + } |
|
140 | + unset($this->queued_scripts[$handle]); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Sets the internal i18n_map property. |
|
146 | + * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
147 | + * |
|
148 | + * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
149 | + * correspond to. |
|
150 | + */ |
|
151 | + private function setI18nMap(array $i18n_map) |
|
152 | + { |
|
153 | + if (empty($i18n_map)) { |
|
154 | + $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
155 | + ? json_decode( |
|
156 | + file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
157 | + true |
|
158 | + ) |
|
159 | + : array(); |
|
160 | + } |
|
161 | + $this->i18n_map = $i18n_map; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Get the jed locale data for a given $handle and domain |
|
166 | + * |
|
167 | + * @param string $handle The name for the script handle we want strings returned for. |
|
168 | + * @param string $domain The i18n domain. |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
172 | + { |
|
173 | + $translations = $this->getJedLocaleData($domain); |
|
174 | + // get index for adding back after extracting strings for this $chunk. |
|
175 | + $index = $translations['']; |
|
176 | + $translations = $this->getLocaleDataMatchingMap( |
|
177 | + $this->getOriginalStringsForHandleFromMap($handle), |
|
178 | + $translations |
|
179 | + ); |
|
180 | + $translations[''] = $index; |
|
181 | + return $translations; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Get locale data for given strings from given translations |
|
186 | + * |
|
187 | + * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
188 | + * @param array $translations Translation data to extra strings from. |
|
189 | + * @return array |
|
190 | + */ |
|
191 | + protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
192 | + { |
|
193 | + if (empty($string_set)) { |
|
194 | + return array(); |
|
195 | + } |
|
196 | + // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
197 | + // slashed also filter falsey values. |
|
198 | + $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
199 | + return array_intersect_key($translations, array_flip($string_set)); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Get original strings to translate for the given chunk from the map |
|
204 | + * |
|
205 | + * @param string $handle The script handle name to get strings from the map for. |
|
206 | + * @return array |
|
207 | + */ |
|
208 | + protected function getOriginalStringsForHandleFromMap($handle) |
|
209 | + { |
|
210 | + return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Returns Jed-formatted localization data. |
|
215 | + * |
|
216 | + * @param string $domain Translation domain. |
|
217 | + * @return array |
|
218 | + */ |
|
219 | + private function getJedLocaleData($domain) |
|
220 | + { |
|
221 | + $translations = get_translations_for_domain($domain); |
|
222 | + |
|
223 | + $locale = array( |
|
224 | + '' => array( |
|
225 | + 'domain' => $domain, |
|
226 | + 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale(), |
|
227 | + ), |
|
228 | + ); |
|
229 | + |
|
230 | + if (!empty($translations->headers['Plural-Forms'])) { |
|
231 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
232 | + } |
|
233 | + |
|
234 | + foreach ($translations->entries as $msgid => $entry) { |
|
235 | + $locale[$msgid] = $entry->translations; |
|
236 | + } |
|
237 | + |
|
238 | + return $locale; |
|
239 | + } |
|
240 | 240 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function registerScriptI18n($handle, $domain = 'event_espresso') |
74 | 74 | { |
75 | - if (!isset($this->registered_i18n[$handle])) { |
|
75 | + if ( ! isset($this->registered_i18n[$handle])) { |
|
76 | 76 | $this->registered_i18n[$handle] = 1; |
77 | 77 | $this->queued_scripts[$handle] = $domain; |
78 | 78 | } |
@@ -116,8 +116,7 @@ discard block |
||
116 | 116 | protected function registerInlineScript($handle, array $translations, $domain) |
117 | 117 | { |
118 | 118 | $script = $domain ? |
119 | - 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
120 | - 'wp.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
119 | + 'wp.i18n.setLocaleData( '.wp_json_encode($translations).', "'.$domain.'" );' : 'wp.i18n.setLocaleData( '.wp_json_encode($translations).' );'; |
|
121 | 120 | wp_add_inline_script($handle, $script, 'before'); |
122 | 121 | } |
123 | 122 | |
@@ -151,9 +150,9 @@ discard block |
||
151 | 150 | private function setI18nMap(array $i18n_map) |
152 | 151 | { |
153 | 152 | if (empty($i18n_map)) { |
154 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
153 | + $i18n_map = file_exists($this->domain->pluginPath().'translation-map.json') |
|
155 | 154 | ? json_decode( |
156 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
155 | + file_get_contents($this->domain->pluginPath().'translation-map.json'), |
|
157 | 156 | true |
158 | 157 | ) |
159 | 158 | : array(); |
@@ -227,7 +226,7 @@ discard block |
||
227 | 226 | ), |
228 | 227 | ); |
229 | 228 | |
230 | - if (!empty($translations->headers['Plural-Forms'])) { |
|
229 | + if ( ! empty($translations->headers['Plural-Forms'])) { |
|
231 | 230 | $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
232 | 231 | } |
233 | 232 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | if ($this->admin_config->useAdvancedEditor()) { |
104 | 104 | $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
105 | - if (! $eventId) { |
|
105 | + if ( ! $eventId) { |
|
106 | 106 | global $post; |
107 | 107 | $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
108 | 108 | $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $data = wp_json_encode($data); |
115 | 115 | add_action( |
116 | 116 | 'admin_footer', |
117 | - static function () use ($data) { |
|
117 | + static function() use ($data) { |
|
118 | 118 | wp_add_inline_script( |
119 | 119 | EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
120 | 120 | " |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $event = $this->getEventGraphQLData($eventId); |
148 | 148 | $event['dbId'] = $eventId; |
149 | 149 | |
150 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
150 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : ''; |
|
151 | 151 | $graphqlEndpoint = esc_url($graphqlEndpoint); |
152 | 152 | |
153 | 153 | $currentUser = $this->getGraphQLCurrentUser(); |
@@ -172,18 +172,18 @@ discard block |
||
172 | 172 | $datetimes = $this->getGraphQLDatetimes($eventId); |
173 | 173 | } |
174 | 174 | |
175 | - if (! empty($datetimes['nodes'])) { |
|
175 | + if ( ! empty($datetimes['nodes'])) { |
|
176 | 176 | $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
177 | 177 | |
178 | - if (! empty($datetimeIn)) { |
|
178 | + if ( ! empty($datetimeIn)) { |
|
179 | 179 | $tickets = $this->getGraphQLTickets($datetimeIn); |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - if (! empty($tickets['nodes'])) { |
|
183 | + if ( ! empty($tickets['nodes'])) { |
|
184 | 184 | $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
185 | 185 | |
186 | - if (! empty($ticketIn)) { |
|
186 | + if ( ! empty($ticketIn)) { |
|
187 | 187 | $prices = $this->getGraphQLPrices($ticketIn); |
188 | 188 | } |
189 | 189 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | protected function getGraphQLDatetimes($eventId) |
237 | 237 | { |
238 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
238 | + $field_key = lcfirst($this->namespace).'Datetimes'; |
|
239 | 239 | $query = <<<QUERY |
240 | 240 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
241 | 241 | {$field_key}(where: \$where) { |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | ]; |
277 | 277 | |
278 | 278 | $responseData = $this->makeGraphQLRequest($data); |
279 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
279 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function getGraphQLTickets(array $datetimeIn) |
289 | 289 | { |
290 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
290 | + $field_key = lcfirst($this->namespace).'Tickets'; |
|
291 | 291 | $query = <<<QUERY |
292 | 292 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
293 | 293 | {$field_key}(where: \$where) { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | ]; |
330 | 330 | |
331 | 331 | $responseData = $this->makeGraphQLRequest($data); |
332 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
332 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | protected function getGraphQLPrices(array $ticketIn) |
342 | 342 | { |
343 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
343 | + $field_key = lcfirst($this->namespace).'Prices'; |
|
344 | 344 | $query = <<<QUERY |
345 | 345 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
346 | 346 | {$field_key}(where: \$where) { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | ]; |
377 | 377 | |
378 | 378 | $responseData = $this->makeGraphQLRequest($data); |
379 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
379 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function getGraphQLPriceTypes() |
388 | 388 | { |
389 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
389 | + $field_key = lcfirst($this->namespace).'PriceTypes'; |
|
390 | 390 | $query = <<<QUERY |
391 | 391 | query GET_PRICES { |
392 | 392 | {$field_key} { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | ]; |
414 | 414 | |
415 | 415 | $responseData = $this->makeGraphQLRequest($data); |
416 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
416 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | ]; |
449 | 449 | |
450 | 450 | $responseData = $this->makeGraphQLRequest($data); |
451 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
451 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | ]; |
476 | 476 | |
477 | 477 | $responseData = $this->makeGraphQLRequest($data); |
478 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
478 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | { |
489 | 489 | try { |
490 | 490 | $response = graphql($data); |
491 | - if (!empty($response['data'])) { |
|
491 | + if ( ! empty($response['data'])) { |
|
492 | 492 | return $response['data']; |
493 | 493 | } |
494 | 494 | return null; |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | foreach ($related_models as $key => $model) { |
541 | 541 | // Get the IDs of related entities for the datetime ID. |
542 | 542 | $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
543 | - if (! empty($Ids)) { |
|
544 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
543 | + if ( ! empty($Ids)) { |
|
544 | + $data['datetimes'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | } |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | foreach ($related_models as $key => $model) { |
560 | 560 | // Get the IDs of related entities for the ticket ID. |
561 | 561 | $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
562 | - if (! empty($Ids)) { |
|
563 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
562 | + if ( ! empty($Ids)) { |
|
563 | + $data['tickets'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | } |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | foreach ($related_models as $key => $model) { |
579 | 579 | // Get the IDs of related entities for the price ID. |
580 | 580 | $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
581 | - if (! empty($Ids)) { |
|
582 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
581 | + if ( ! empty($Ids)) { |
|
582 | + $data['prices'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | public static function convertToGlobalId($type, $ID) |
598 | 598 | { |
599 | 599 | if (is_array($ID)) { |
600 | - return array_map(function ($id) use ($type) { |
|
600 | + return array_map(function($id) use ($type) { |
|
601 | 601 | return self::convertToGlobalId($type, $id); |
602 | 602 | }, $ID); |
603 | 603 | } |
@@ -34,209 +34,209 @@ discard block |
||
34 | 34 | class AdvancedEditorData |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * @var string $namespace The graphql namespace/prefix. |
|
39 | - */ |
|
40 | - protected $namespace = 'Espresso'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Event |
|
44 | - */ |
|
45 | - protected $event; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Admin_Config |
|
49 | - */ |
|
50 | - protected $admin_config; |
|
51 | - /** |
|
52 | - * @var EEM_Datetime $datetime_model |
|
53 | - */ |
|
54 | - protected $datetime_model; |
|
55 | - /** |
|
56 | - * @var EEM_Price $price_model |
|
57 | - */ |
|
58 | - protected $price_model; |
|
59 | - /** |
|
60 | - * @var EEM_Ticket $ticket_model |
|
61 | - */ |
|
62 | - protected $ticket_model; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * AdvancedEditorAdminForm constructor. |
|
67 | - * |
|
68 | - * @param EE_Event $event |
|
69 | - * @param EE_Admin_Config $admin_config |
|
70 | - * @param EEM_Datetime $datetime_model |
|
71 | - * @param EEM_Price $price_model |
|
72 | - * @param EEM_Ticket $ticket_model |
|
73 | - */ |
|
74 | - public function __construct( |
|
75 | - EE_Event $event, |
|
76 | - EE_Admin_Config $admin_config, |
|
77 | - EEM_Datetime $datetime_model, |
|
78 | - EEM_Price $price_model, |
|
79 | - EEM_Ticket $ticket_model |
|
80 | - ) { |
|
81 | - $this->event = $event; |
|
82 | - $this->admin_config = $admin_config; |
|
83 | - $this->datetime_model = $datetime_model; |
|
84 | - $this->price_model = $price_model; |
|
85 | - $this->ticket_model = $ticket_model; |
|
86 | - add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @throws EE_Error |
|
92 | - * @throws InvalidArgumentException |
|
93 | - * @throws InvalidDataTypeException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws ModelConfigurationException |
|
96 | - * @throws ReflectionException |
|
97 | - * @throws UnexpectedEntityException |
|
98 | - * @throws DomainException |
|
99 | - * @since $VID:$ |
|
100 | - */ |
|
101 | - public function loadScriptsStyles() |
|
102 | - { |
|
103 | - if ($this->admin_config->useAdvancedEditor()) { |
|
104 | - $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
105 | - if (! $eventId) { |
|
106 | - global $post; |
|
107 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
108 | - $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
109 | - ? $post->ID |
|
110 | - : $eventId; |
|
111 | - } |
|
112 | - if ($eventId) { |
|
113 | - $data = $this->getEditorData($eventId); |
|
114 | - $data = wp_json_encode($data); |
|
115 | - add_action( |
|
116 | - 'admin_footer', |
|
117 | - static function () use ($data) { |
|
118 | - wp_add_inline_script( |
|
119 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
120 | - " |
|
37 | + /** |
|
38 | + * @var string $namespace The graphql namespace/prefix. |
|
39 | + */ |
|
40 | + protected $namespace = 'Espresso'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Event |
|
44 | + */ |
|
45 | + protected $event; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Admin_Config |
|
49 | + */ |
|
50 | + protected $admin_config; |
|
51 | + /** |
|
52 | + * @var EEM_Datetime $datetime_model |
|
53 | + */ |
|
54 | + protected $datetime_model; |
|
55 | + /** |
|
56 | + * @var EEM_Price $price_model |
|
57 | + */ |
|
58 | + protected $price_model; |
|
59 | + /** |
|
60 | + * @var EEM_Ticket $ticket_model |
|
61 | + */ |
|
62 | + protected $ticket_model; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * AdvancedEditorAdminForm constructor. |
|
67 | + * |
|
68 | + * @param EE_Event $event |
|
69 | + * @param EE_Admin_Config $admin_config |
|
70 | + * @param EEM_Datetime $datetime_model |
|
71 | + * @param EEM_Price $price_model |
|
72 | + * @param EEM_Ticket $ticket_model |
|
73 | + */ |
|
74 | + public function __construct( |
|
75 | + EE_Event $event, |
|
76 | + EE_Admin_Config $admin_config, |
|
77 | + EEM_Datetime $datetime_model, |
|
78 | + EEM_Price $price_model, |
|
79 | + EEM_Ticket $ticket_model |
|
80 | + ) { |
|
81 | + $this->event = $event; |
|
82 | + $this->admin_config = $admin_config; |
|
83 | + $this->datetime_model = $datetime_model; |
|
84 | + $this->price_model = $price_model; |
|
85 | + $this->ticket_model = $ticket_model; |
|
86 | + add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @throws EE_Error |
|
92 | + * @throws InvalidArgumentException |
|
93 | + * @throws InvalidDataTypeException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws ModelConfigurationException |
|
96 | + * @throws ReflectionException |
|
97 | + * @throws UnexpectedEntityException |
|
98 | + * @throws DomainException |
|
99 | + * @since $VID:$ |
|
100 | + */ |
|
101 | + public function loadScriptsStyles() |
|
102 | + { |
|
103 | + if ($this->admin_config->useAdvancedEditor()) { |
|
104 | + $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
105 | + if (! $eventId) { |
|
106 | + global $post; |
|
107 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
108 | + $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
109 | + ? $post->ID |
|
110 | + : $eventId; |
|
111 | + } |
|
112 | + if ($eventId) { |
|
113 | + $data = $this->getEditorData($eventId); |
|
114 | + $data = wp_json_encode($data); |
|
115 | + add_action( |
|
116 | + 'admin_footer', |
|
117 | + static function () use ($data) { |
|
118 | + wp_add_inline_script( |
|
119 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
120 | + " |
|
121 | 121 | var eeEditorData={$data}; |
122 | 122 | ", |
123 | - 'before' |
|
124 | - ); |
|
125 | - } |
|
126 | - ); |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @param int $eventId |
|
134 | - * @return array |
|
135 | - * @throws EE_Error |
|
136 | - * @throws InvalidDataTypeException |
|
137 | - * @throws InvalidInterfaceException |
|
138 | - * @throws ModelConfigurationException |
|
139 | - * @throws UnexpectedEntityException |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws ReflectionException |
|
142 | - * @throws DomainException |
|
143 | - * @since $VID:$ |
|
144 | - */ |
|
145 | - protected function getEditorData($eventId) |
|
146 | - { |
|
147 | - $event = $this->getEventGraphQLData($eventId); |
|
148 | - $event['dbId'] = $eventId; |
|
149 | - |
|
150 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
151 | - $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
152 | - |
|
153 | - $currentUser = $this->getGraphQLCurrentUser(); |
|
154 | - |
|
155 | - $generalSettings = $this->getGraphQLGeneralSettings(); |
|
156 | - |
|
157 | - return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings'); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param int $eventId |
|
163 | - * @return array |
|
164 | - * @since $VID:$ |
|
165 | - */ |
|
166 | - protected function getEventGraphQLData($eventId) |
|
167 | - { |
|
168 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
169 | - |
|
170 | - if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
171 | - $this->addDefaultEntities($eventId); |
|
172 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
173 | - } |
|
174 | - |
|
175 | - if (! empty($datetimes['nodes'])) { |
|
176 | - $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
177 | - |
|
178 | - if (! empty($datetimeIn)) { |
|
179 | - $tickets = $this->getGraphQLTickets($datetimeIn); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - if (! empty($tickets['nodes'])) { |
|
184 | - $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
185 | - |
|
186 | - if (! empty($ticketIn)) { |
|
187 | - $prices = $this->getGraphQLPrices($ticketIn); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - $priceTypes = $this->getGraphQLPriceTypes(); |
|
192 | - |
|
193 | - $relations = $this->getRelationalData($eventId); |
|
194 | - |
|
195 | - return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * @param int $eventId |
|
200 | - * @throws DomainException |
|
201 | - * @throws EE_Error |
|
202 | - * @throws InvalidArgumentException |
|
203 | - * @throws InvalidDataTypeException |
|
204 | - * @throws InvalidInterfaceException |
|
205 | - * @throws ModelConfigurationException |
|
206 | - * @throws ReflectionException |
|
207 | - * @throws UnexpectedEntityException |
|
208 | - * @since $VID:$ |
|
209 | - */ |
|
210 | - protected function addDefaultEntities($eventId) |
|
211 | - { |
|
212 | - $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
213 | - if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
214 | - $default_date = $default_dates[0]; |
|
215 | - $default_date->save(); |
|
216 | - $default_date->_add_relation_to($eventId, 'Event'); |
|
217 | - $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
218 | - $default_prices = $this->price_model->get_all_default_prices(); |
|
219 | - foreach ($default_tickets as $default_ticket) { |
|
220 | - $default_ticket->save(); |
|
221 | - $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
222 | - foreach ($default_prices as $default_price) { |
|
223 | - $default_price->save(); |
|
224 | - $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * @param int $eventId |
|
233 | - * @return array|null |
|
234 | - * @since $VID:$ |
|
235 | - */ |
|
236 | - protected function getGraphQLDatetimes($eventId) |
|
237 | - { |
|
238 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
239 | - $query = <<<QUERY |
|
123 | + 'before' |
|
124 | + ); |
|
125 | + } |
|
126 | + ); |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @param int $eventId |
|
134 | + * @return array |
|
135 | + * @throws EE_Error |
|
136 | + * @throws InvalidDataTypeException |
|
137 | + * @throws InvalidInterfaceException |
|
138 | + * @throws ModelConfigurationException |
|
139 | + * @throws UnexpectedEntityException |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws ReflectionException |
|
142 | + * @throws DomainException |
|
143 | + * @since $VID:$ |
|
144 | + */ |
|
145 | + protected function getEditorData($eventId) |
|
146 | + { |
|
147 | + $event = $this->getEventGraphQLData($eventId); |
|
148 | + $event['dbId'] = $eventId; |
|
149 | + |
|
150 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
151 | + $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
152 | + |
|
153 | + $currentUser = $this->getGraphQLCurrentUser(); |
|
154 | + |
|
155 | + $generalSettings = $this->getGraphQLGeneralSettings(); |
|
156 | + |
|
157 | + return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings'); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param int $eventId |
|
163 | + * @return array |
|
164 | + * @since $VID:$ |
|
165 | + */ |
|
166 | + protected function getEventGraphQLData($eventId) |
|
167 | + { |
|
168 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
169 | + |
|
170 | + if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
171 | + $this->addDefaultEntities($eventId); |
|
172 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
173 | + } |
|
174 | + |
|
175 | + if (! empty($datetimes['nodes'])) { |
|
176 | + $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
177 | + |
|
178 | + if (! empty($datetimeIn)) { |
|
179 | + $tickets = $this->getGraphQLTickets($datetimeIn); |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + if (! empty($tickets['nodes'])) { |
|
184 | + $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
185 | + |
|
186 | + if (! empty($ticketIn)) { |
|
187 | + $prices = $this->getGraphQLPrices($ticketIn); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + $priceTypes = $this->getGraphQLPriceTypes(); |
|
192 | + |
|
193 | + $relations = $this->getRelationalData($eventId); |
|
194 | + |
|
195 | + return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * @param int $eventId |
|
200 | + * @throws DomainException |
|
201 | + * @throws EE_Error |
|
202 | + * @throws InvalidArgumentException |
|
203 | + * @throws InvalidDataTypeException |
|
204 | + * @throws InvalidInterfaceException |
|
205 | + * @throws ModelConfigurationException |
|
206 | + * @throws ReflectionException |
|
207 | + * @throws UnexpectedEntityException |
|
208 | + * @since $VID:$ |
|
209 | + */ |
|
210 | + protected function addDefaultEntities($eventId) |
|
211 | + { |
|
212 | + $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
213 | + if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
214 | + $default_date = $default_dates[0]; |
|
215 | + $default_date->save(); |
|
216 | + $default_date->_add_relation_to($eventId, 'Event'); |
|
217 | + $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
218 | + $default_prices = $this->price_model->get_all_default_prices(); |
|
219 | + foreach ($default_tickets as $default_ticket) { |
|
220 | + $default_ticket->save(); |
|
221 | + $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
222 | + foreach ($default_prices as $default_price) { |
|
223 | + $default_price->save(); |
|
224 | + $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * @param int $eventId |
|
233 | + * @return array|null |
|
234 | + * @since $VID:$ |
|
235 | + */ |
|
236 | + protected function getGraphQLDatetimes($eventId) |
|
237 | + { |
|
238 | + $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
239 | + $query = <<<QUERY |
|
240 | 240 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
241 | 241 | {$field_key}(where: \$where) { |
242 | 242 | nodes { |
@@ -264,31 +264,31 @@ discard block |
||
264 | 264 | } |
265 | 265 | } |
266 | 266 | QUERY; |
267 | - $data = [ |
|
268 | - 'operation_name' => 'GET_DATETIMES', |
|
269 | - 'variables' => [ |
|
270 | - 'first' => 50, |
|
271 | - 'where' => [ |
|
272 | - 'eventId' => $eventId, |
|
273 | - ], |
|
274 | - ], |
|
275 | - 'query' => $query, |
|
276 | - ]; |
|
277 | - |
|
278 | - $responseData = $this->makeGraphQLRequest($data); |
|
279 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * @param array $datetimeIn |
|
285 | - * @return array|null |
|
286 | - * @since $VID:$ |
|
287 | - */ |
|
288 | - protected function getGraphQLTickets(array $datetimeIn) |
|
289 | - { |
|
290 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
291 | - $query = <<<QUERY |
|
267 | + $data = [ |
|
268 | + 'operation_name' => 'GET_DATETIMES', |
|
269 | + 'variables' => [ |
|
270 | + 'first' => 50, |
|
271 | + 'where' => [ |
|
272 | + 'eventId' => $eventId, |
|
273 | + ], |
|
274 | + ], |
|
275 | + 'query' => $query, |
|
276 | + ]; |
|
277 | + |
|
278 | + $responseData = $this->makeGraphQLRequest($data); |
|
279 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * @param array $datetimeIn |
|
285 | + * @return array|null |
|
286 | + * @since $VID:$ |
|
287 | + */ |
|
288 | + protected function getGraphQLTickets(array $datetimeIn) |
|
289 | + { |
|
290 | + $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
291 | + $query = <<<QUERY |
|
292 | 292 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
293 | 293 | {$field_key}(where: \$where) { |
294 | 294 | nodes { |
@@ -318,30 +318,30 @@ discard block |
||
318 | 318 | } |
319 | 319 | } |
320 | 320 | QUERY; |
321 | - $data = [ |
|
322 | - 'operation_name' => 'GET_TICKETS', |
|
323 | - 'variables' => [ |
|
324 | - 'where' => [ |
|
325 | - 'datetimeIn' => $datetimeIn, |
|
326 | - ], |
|
327 | - ], |
|
328 | - 'query' => $query, |
|
329 | - ]; |
|
330 | - |
|
331 | - $responseData = $this->makeGraphQLRequest($data); |
|
332 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @param array $ticketIn |
|
338 | - * @return array|null |
|
339 | - * @since $VID:$ |
|
340 | - */ |
|
341 | - protected function getGraphQLPrices(array $ticketIn) |
|
342 | - { |
|
343 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
344 | - $query = <<<QUERY |
|
321 | + $data = [ |
|
322 | + 'operation_name' => 'GET_TICKETS', |
|
323 | + 'variables' => [ |
|
324 | + 'where' => [ |
|
325 | + 'datetimeIn' => $datetimeIn, |
|
326 | + ], |
|
327 | + ], |
|
328 | + 'query' => $query, |
|
329 | + ]; |
|
330 | + |
|
331 | + $responseData = $this->makeGraphQLRequest($data); |
|
332 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @param array $ticketIn |
|
338 | + * @return array|null |
|
339 | + * @since $VID:$ |
|
340 | + */ |
|
341 | + protected function getGraphQLPrices(array $ticketIn) |
|
342 | + { |
|
343 | + $field_key = lcfirst($this->namespace) . 'Prices'; |
|
344 | + $query = <<<QUERY |
|
345 | 345 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
346 | 346 | {$field_key}(where: \$where) { |
347 | 347 | nodes { |
@@ -365,29 +365,29 @@ discard block |
||
365 | 365 | } |
366 | 366 | } |
367 | 367 | QUERY; |
368 | - $data = [ |
|
369 | - 'operation_name' => 'GET_PRICES', |
|
370 | - 'variables' => [ |
|
371 | - 'where' => [ |
|
372 | - 'ticketIn' => $ticketIn, |
|
373 | - ], |
|
374 | - ], |
|
375 | - 'query' => $query, |
|
376 | - ]; |
|
377 | - |
|
378 | - $responseData = $this->makeGraphQLRequest($data); |
|
379 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * @return array|null |
|
385 | - * @since $VID:$ |
|
386 | - */ |
|
387 | - protected function getGraphQLPriceTypes() |
|
388 | - { |
|
389 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
390 | - $query = <<<QUERY |
|
368 | + $data = [ |
|
369 | + 'operation_name' => 'GET_PRICES', |
|
370 | + 'variables' => [ |
|
371 | + 'where' => [ |
|
372 | + 'ticketIn' => $ticketIn, |
|
373 | + ], |
|
374 | + ], |
|
375 | + 'query' => $query, |
|
376 | + ]; |
|
377 | + |
|
378 | + $responseData = $this->makeGraphQLRequest($data); |
|
379 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * @return array|null |
|
385 | + * @since $VID:$ |
|
386 | + */ |
|
387 | + protected function getGraphQLPriceTypes() |
|
388 | + { |
|
389 | + $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
390 | + $query = <<<QUERY |
|
391 | 391 | query GET_PRICES { |
392 | 392 | {$field_key} { |
393 | 393 | nodes { |
@@ -407,24 +407,24 @@ discard block |
||
407 | 407 | } |
408 | 408 | } |
409 | 409 | QUERY; |
410 | - $data = [ |
|
411 | - 'operation_name' => 'GET_PRICES', |
|
412 | - 'query' => $query, |
|
413 | - ]; |
|
414 | - |
|
415 | - $responseData = $this->makeGraphQLRequest($data); |
|
416 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * @return array|null |
|
422 | - * @since $VID:$ |
|
423 | - */ |
|
424 | - protected function getGraphQLCurrentUser() |
|
425 | - { |
|
426 | - $field_key = 'viewer'; |
|
427 | - $query = <<<QUERY |
|
410 | + $data = [ |
|
411 | + 'operation_name' => 'GET_PRICES', |
|
412 | + 'query' => $query, |
|
413 | + ]; |
|
414 | + |
|
415 | + $responseData = $this->makeGraphQLRequest($data); |
|
416 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * @return array|null |
|
422 | + * @since $VID:$ |
|
423 | + */ |
|
424 | + protected function getGraphQLCurrentUser() |
|
425 | + { |
|
426 | + $field_key = 'viewer'; |
|
427 | + $query = <<<QUERY |
|
428 | 428 | query GET_CURRENT_USER { |
429 | 429 | {$field_key} { |
430 | 430 | description |
@@ -442,24 +442,24 @@ discard block |
||
442 | 442 | } |
443 | 443 | } |
444 | 444 | QUERY; |
445 | - $data = [ |
|
446 | - 'operation_name' => 'GET_CURRENT_USER', |
|
447 | - 'query' => $query, |
|
448 | - ]; |
|
449 | - |
|
450 | - $responseData = $this->makeGraphQLRequest($data); |
|
451 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * @return array|null |
|
457 | - * @since $VID:$ |
|
458 | - */ |
|
459 | - protected function getGraphQLGeneralSettings() |
|
460 | - { |
|
461 | - $field_key = 'generalSettings'; |
|
462 | - $query = <<<QUERY |
|
445 | + $data = [ |
|
446 | + 'operation_name' => 'GET_CURRENT_USER', |
|
447 | + 'query' => $query, |
|
448 | + ]; |
|
449 | + |
|
450 | + $responseData = $this->makeGraphQLRequest($data); |
|
451 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * @return array|null |
|
457 | + * @since $VID:$ |
|
458 | + */ |
|
459 | + protected function getGraphQLGeneralSettings() |
|
460 | + { |
|
461 | + $field_key = 'generalSettings'; |
|
462 | + $query = <<<QUERY |
|
463 | 463 | query GET_GENERAL_SETTINGS { |
464 | 464 | {$field_key} { |
465 | 465 | dateFormat |
@@ -469,144 +469,144 @@ discard block |
||
469 | 469 | } |
470 | 470 | } |
471 | 471 | QUERY; |
472 | - $data = [ |
|
473 | - 'operation_name' => 'GET_CURRENT_USER', |
|
474 | - 'query' => $query, |
|
475 | - ]; |
|
476 | - |
|
477 | - $responseData = $this->makeGraphQLRequest($data); |
|
478 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
479 | - } |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * @param array $data |
|
484 | - * @return array |
|
485 | - * @since $VID:$ |
|
486 | - */ |
|
487 | - protected function makeGraphQLRequest($data) |
|
488 | - { |
|
489 | - try { |
|
490 | - $response = graphql($data); |
|
491 | - if (!empty($response['data'])) { |
|
492 | - return $response['data']; |
|
493 | - } |
|
494 | - return null; |
|
495 | - } catch (\Exception $e) { |
|
496 | - // do something with the errors thrown |
|
497 | - return null; |
|
498 | - } |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
504 | - * @param array $args The inputArgs on the field |
|
505 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
506 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
507 | - * @return string |
|
508 | - * @throws EE_Error |
|
509 | - * @throws Exception |
|
510 | - * @throws InvalidArgumentException |
|
511 | - * @throws InvalidDataTypeException |
|
512 | - * @throws InvalidInterfaceException |
|
513 | - * @throws ReflectionException |
|
514 | - * @throws UserError |
|
515 | - * @throws UnexpectedEntityException |
|
516 | - * @since $VID:$ |
|
517 | - */ |
|
518 | - public static function getRelationalData($eventId) |
|
519 | - { |
|
520 | - |
|
521 | - $data = [ |
|
522 | - 'datetimes' => [], |
|
523 | - 'tickets' => [], |
|
524 | - 'prices' => [], |
|
525 | - ]; |
|
526 | - |
|
527 | - $eem_datetime = EEM_Datetime::instance(); |
|
528 | - $eem_ticket = EEM_Ticket::instance(); |
|
529 | - $eem_price = EEM_Price::instance(); |
|
530 | - $eem_price_type = EEM_Price_Type::instance(); |
|
531 | - |
|
532 | - // PROCESS DATETIMES |
|
533 | - $related_models = [ |
|
534 | - 'tickets' => $eem_ticket, |
|
535 | - ]; |
|
536 | - // Get the IDs of event datetimes. |
|
537 | - $datetimeIds = $eem_datetime->get_col([[ |
|
538 | - 'EVT_ID' => $eventId, |
|
539 | - 'DTT_deleted' => ['IN', [true, false]], |
|
540 | - ]]); |
|
541 | - foreach ($datetimeIds as $datetimeId) { |
|
542 | - $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
543 | - foreach ($related_models as $key => $model) { |
|
544 | - // Get the IDs of related entities for the datetime ID. |
|
545 | - $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
546 | - if (! empty($Ids)) { |
|
547 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
548 | - } |
|
549 | - } |
|
550 | - } |
|
551 | - |
|
552 | - // PROCESS TICKETS |
|
553 | - $related_models = [ |
|
554 | - 'datetimes' => $eem_datetime, |
|
555 | - 'prices' => $eem_price, |
|
556 | - ]; |
|
557 | - // Get the IDs of all datetime tickets. |
|
558 | - $ticketIds = $eem_ticket->get_col([[ |
|
559 | - 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
560 | - 'TKT_deleted' => ['IN', [true, false]], |
|
561 | - ]]); |
|
562 | - foreach ($ticketIds as $ticketId) { |
|
563 | - $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
564 | - |
|
565 | - foreach ($related_models as $key => $model) { |
|
566 | - // Get the IDs of related entities for the ticket ID. |
|
567 | - $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
568 | - if (! empty($Ids)) { |
|
569 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
570 | - } |
|
571 | - } |
|
572 | - } |
|
573 | - |
|
574 | - // PROCESS PRICES |
|
575 | - $related_models = [ |
|
576 | - 'tickets' => $eem_ticket, |
|
577 | - 'priceTypes' => $eem_price_type, |
|
578 | - ]; |
|
579 | - // Get the IDs of all ticket prices. |
|
580 | - $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
581 | - foreach ($priceIds as $priceId) { |
|
582 | - $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
583 | - |
|
584 | - foreach ($related_models as $key => $model) { |
|
585 | - // Get the IDs of related entities for the price ID. |
|
586 | - $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
587 | - if (! empty($Ids)) { |
|
588 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - |
|
593 | - return $data; |
|
594 | - } |
|
595 | - |
|
596 | - /** |
|
597 | - * Convert the DB ID into GID |
|
598 | - * |
|
599 | - * @param string $type |
|
600 | - * @param int|int[] $ID |
|
601 | - * @return mixed |
|
602 | - */ |
|
603 | - public static function convertToGlobalId($type, $ID) |
|
604 | - { |
|
605 | - if (is_array($ID)) { |
|
606 | - return array_map(function ($id) use ($type) { |
|
607 | - return self::convertToGlobalId($type, $id); |
|
608 | - }, $ID); |
|
609 | - } |
|
610 | - return Relay::toGlobalId($type, $ID); |
|
611 | - } |
|
472 | + $data = [ |
|
473 | + 'operation_name' => 'GET_CURRENT_USER', |
|
474 | + 'query' => $query, |
|
475 | + ]; |
|
476 | + |
|
477 | + $responseData = $this->makeGraphQLRequest($data); |
|
478 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
479 | + } |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * @param array $data |
|
484 | + * @return array |
|
485 | + * @since $VID:$ |
|
486 | + */ |
|
487 | + protected function makeGraphQLRequest($data) |
|
488 | + { |
|
489 | + try { |
|
490 | + $response = graphql($data); |
|
491 | + if (!empty($response['data'])) { |
|
492 | + return $response['data']; |
|
493 | + } |
|
494 | + return null; |
|
495 | + } catch (\Exception $e) { |
|
496 | + // do something with the errors thrown |
|
497 | + return null; |
|
498 | + } |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
504 | + * @param array $args The inputArgs on the field |
|
505 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
506 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
507 | + * @return string |
|
508 | + * @throws EE_Error |
|
509 | + * @throws Exception |
|
510 | + * @throws InvalidArgumentException |
|
511 | + * @throws InvalidDataTypeException |
|
512 | + * @throws InvalidInterfaceException |
|
513 | + * @throws ReflectionException |
|
514 | + * @throws UserError |
|
515 | + * @throws UnexpectedEntityException |
|
516 | + * @since $VID:$ |
|
517 | + */ |
|
518 | + public static function getRelationalData($eventId) |
|
519 | + { |
|
520 | + |
|
521 | + $data = [ |
|
522 | + 'datetimes' => [], |
|
523 | + 'tickets' => [], |
|
524 | + 'prices' => [], |
|
525 | + ]; |
|
526 | + |
|
527 | + $eem_datetime = EEM_Datetime::instance(); |
|
528 | + $eem_ticket = EEM_Ticket::instance(); |
|
529 | + $eem_price = EEM_Price::instance(); |
|
530 | + $eem_price_type = EEM_Price_Type::instance(); |
|
531 | + |
|
532 | + // PROCESS DATETIMES |
|
533 | + $related_models = [ |
|
534 | + 'tickets' => $eem_ticket, |
|
535 | + ]; |
|
536 | + // Get the IDs of event datetimes. |
|
537 | + $datetimeIds = $eem_datetime->get_col([[ |
|
538 | + 'EVT_ID' => $eventId, |
|
539 | + 'DTT_deleted' => ['IN', [true, false]], |
|
540 | + ]]); |
|
541 | + foreach ($datetimeIds as $datetimeId) { |
|
542 | + $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
543 | + foreach ($related_models as $key => $model) { |
|
544 | + // Get the IDs of related entities for the datetime ID. |
|
545 | + $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
546 | + if (! empty($Ids)) { |
|
547 | + $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
548 | + } |
|
549 | + } |
|
550 | + } |
|
551 | + |
|
552 | + // PROCESS TICKETS |
|
553 | + $related_models = [ |
|
554 | + 'datetimes' => $eem_datetime, |
|
555 | + 'prices' => $eem_price, |
|
556 | + ]; |
|
557 | + // Get the IDs of all datetime tickets. |
|
558 | + $ticketIds = $eem_ticket->get_col([[ |
|
559 | + 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
560 | + 'TKT_deleted' => ['IN', [true, false]], |
|
561 | + ]]); |
|
562 | + foreach ($ticketIds as $ticketId) { |
|
563 | + $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
564 | + |
|
565 | + foreach ($related_models as $key => $model) { |
|
566 | + // Get the IDs of related entities for the ticket ID. |
|
567 | + $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
568 | + if (! empty($Ids)) { |
|
569 | + $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
570 | + } |
|
571 | + } |
|
572 | + } |
|
573 | + |
|
574 | + // PROCESS PRICES |
|
575 | + $related_models = [ |
|
576 | + 'tickets' => $eem_ticket, |
|
577 | + 'priceTypes' => $eem_price_type, |
|
578 | + ]; |
|
579 | + // Get the IDs of all ticket prices. |
|
580 | + $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
581 | + foreach ($priceIds as $priceId) { |
|
582 | + $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
583 | + |
|
584 | + foreach ($related_models as $key => $model) { |
|
585 | + // Get the IDs of related entities for the price ID. |
|
586 | + $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
587 | + if (! empty($Ids)) { |
|
588 | + $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + |
|
593 | + return $data; |
|
594 | + } |
|
595 | + |
|
596 | + /** |
|
597 | + * Convert the DB ID into GID |
|
598 | + * |
|
599 | + * @param string $type |
|
600 | + * @param int|int[] $ID |
|
601 | + * @return mixed |
|
602 | + */ |
|
603 | + public static function convertToGlobalId($type, $ID) |
|
604 | + { |
|
605 | + if (is_array($ID)) { |
|
606 | + return array_map(function ($id) use ($type) { |
|
607 | + return self::convertToGlobalId($type, $id); |
|
608 | + }, $ID); |
|
609 | + } |
|
610 | + return Relay::toGlobalId($type, $ID); |
|
611 | + } |
|
612 | 612 | } |
@@ -19,51 +19,51 @@ |
||
19 | 19 | */ |
20 | 20 | class EspressoEditorAssetManager extends AssetManager |
21 | 21 | { |
22 | - const JS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
23 | - const JS_HANDLE_EDITOR_PROTOTYPE = 'eventespresso-editor-prototype'; |
|
24 | - const CSS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
25 | - const CSS_HANDLE_EDITOR_PROTOTYPE = 'eventespresso-editor-prototype'; |
|
22 | + const JS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
23 | + const JS_HANDLE_EDITOR_PROTOTYPE = 'eventespresso-editor-prototype'; |
|
24 | + const CSS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
25 | + const CSS_HANDLE_EDITOR_PROTOTYPE = 'eventespresso-editor-prototype'; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidEntityException |
|
31 | - * @throws DuplicateCollectionIdentifierException |
|
32 | - * @throws DomainException |
|
33 | - */ |
|
34 | - public function addAssets() |
|
35 | - { |
|
36 | - $this->registerJavascript(); |
|
37 | - $this->registerStyleSheets(); |
|
38 | - } |
|
28 | + /** |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidEntityException |
|
31 | + * @throws DuplicateCollectionIdentifierException |
|
32 | + * @throws DomainException |
|
33 | + */ |
|
34 | + public function addAssets() |
|
35 | + { |
|
36 | + $this->registerJavascript(); |
|
37 | + $this->registerStyleSheets(); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Register javascript assets |
|
43 | - * |
|
44 | - * @throws InvalidDataTypeException |
|
45 | - * @throws InvalidEntityException |
|
46 | - * @throws DuplicateCollectionIdentifierException |
|
47 | - * @throws DomainException |
|
48 | - */ |
|
49 | - private function registerJavascript() |
|
50 | - { |
|
51 | - $this->addJs(self::JS_HANDLE_EDITOR, [CoreAssetManager::JS_HANDLE_JS_CORE])->setRequiresTranslation(); |
|
52 | - $this->addJs(self::JS_HANDLE_EDITOR_PROTOTYPE, [self::JS_HANDLE_EDITOR])->setRequiresTranslation(); |
|
53 | - } |
|
41 | + /** |
|
42 | + * Register javascript assets |
|
43 | + * |
|
44 | + * @throws InvalidDataTypeException |
|
45 | + * @throws InvalidEntityException |
|
46 | + * @throws DuplicateCollectionIdentifierException |
|
47 | + * @throws DomainException |
|
48 | + */ |
|
49 | + private function registerJavascript() |
|
50 | + { |
|
51 | + $this->addJs(self::JS_HANDLE_EDITOR, [CoreAssetManager::JS_HANDLE_JS_CORE])->setRequiresTranslation(); |
|
52 | + $this->addJs(self::JS_HANDLE_EDITOR_PROTOTYPE, [self::JS_HANDLE_EDITOR])->setRequiresTranslation(); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Register CSS assets. |
|
58 | - * |
|
59 | - * @throws DuplicateCollectionIdentifierException |
|
60 | - * @throws InvalidDataTypeException |
|
61 | - * @throws InvalidEntityException |
|
62 | - * @throws DomainException |
|
63 | - */ |
|
64 | - private function registerStyleSheets() |
|
65 | - { |
|
66 | - $this->addCss(self::CSS_HANDLE_EDITOR); |
|
67 | - $this->addCss(self::CSS_HANDLE_EDITOR_PROTOTYPE, [self::CSS_HANDLE_EDITOR]); |
|
68 | - } |
|
56 | + /** |
|
57 | + * Register CSS assets. |
|
58 | + * |
|
59 | + * @throws DuplicateCollectionIdentifierException |
|
60 | + * @throws InvalidDataTypeException |
|
61 | + * @throws InvalidEntityException |
|
62 | + * @throws DomainException |
|
63 | + */ |
|
64 | + private function registerStyleSheets() |
|
65 | + { |
|
66 | + $this->addCss(self::CSS_HANDLE_EDITOR); |
|
67 | + $this->addCss(self::CSS_HANDLE_EDITOR_PROTOTYPE, [self::CSS_HANDLE_EDITOR]); |
|
68 | + } |
|
69 | 69 | } |