Completed
Branch EDTR/master (d3ead4)
by
unknown
26:37 queued 17:42
created
core/services/assets/I18nRegistry.php 2 patches
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -15,226 +15,226 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/domain/services/assets/EspressoEditorAssetManager.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,51 +19,51 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/AbstractConnectionResolver.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -16,112 +16,112 @@
 block discarded – undo
16 16
 abstract class AbstractConnectionResolver extends WPGraphQLConnectionResolver
17 17
 {
18 18
 
19
-    /**
20
-     * Set limit the highest value of first and last, with a (filterable) max of 100
21
-     *
22
-     * @return array
23
-     */
24
-    protected function getLimit()
25
-    {
26
-        $first = ! empty($this->args['first']) ? absint($this->args['first']) : null;
27
-        $last  = ! empty($this->args['last']) ? absint($this->args['last']) : null;
19
+	/**
20
+	 * Set limit the highest value of first and last, with a (filterable) max of 100
21
+	 *
22
+	 * @return array
23
+	 */
24
+	protected function getLimit()
25
+	{
26
+		$first = ! empty($this->args['first']) ? absint($this->args['first']) : null;
27
+		$last  = ! empty($this->args['last']) ? absint($this->args['last']) : null;
28 28
 
29
-        $limit = min(
30
-            max($first, $last, 100),
31
-            $this->query_amount
32
-        );
33
-        $limit++;
34
-        return $limit;
35
-    }
29
+		$limit = min(
30
+			max($first, $last, 100),
31
+			$this->query_amount
32
+		);
33
+		$limit++;
34
+		return $limit;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
40
-     * friendly keys.
41
-     *
42
-     * @param array  $query_args
43
-     * @param array  $where_params
44
-     * @param string $primary_key
45
-     * @return array
46
-     */
47
-    protected function mapOrderbyInputArgs(array $query_args, array $where_params, $primary_key)
48
-    {
49
-        // ID of the current offset
50
-        $offset = $this->get_offset();
51
-        /**
52
-         * Map the orderby inputArgs to the WP_Query
53
-         */
54
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
55
-            $query_args['order_by'] = [];
56
-            foreach ($this->args['where']['orderby'] as $orderby_input) {
57
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
58
-            }
59
-        } elseif ($offset) {
60
-            $compare                      = $this->args['last'] ? '<' : '>';
61
-            $where_params[ $primary_key ] = [ $compare, $offset ];
62
-        }
63
-        return [ $query_args, $where_params ];
64
-    }
38
+	/**
39
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
40
+	 * friendly keys.
41
+	 *
42
+	 * @param array  $query_args
43
+	 * @param array  $where_params
44
+	 * @param string $primary_key
45
+	 * @return array
46
+	 */
47
+	protected function mapOrderbyInputArgs(array $query_args, array $where_params, $primary_key)
48
+	{
49
+		// ID of the current offset
50
+		$offset = $this->get_offset();
51
+		/**
52
+		 * Map the orderby inputArgs to the WP_Query
53
+		 */
54
+		if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
55
+			$query_args['order_by'] = [];
56
+			foreach ($this->args['where']['orderby'] as $orderby_input) {
57
+				$query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
58
+			}
59
+		} elseif ($offset) {
60
+			$compare                      = $this->args['last'] ? '<' : '>';
61
+			$where_params[ $primary_key ] = [ $compare, $offset ];
62
+		}
63
+		return [ $query_args, $where_params ];
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
69
-     * friendly keys.
70
-     *
71
-     * @param array $where_args
72
-     * @param array $arg_mapping
73
-     * @param array $id_fields   The fields to convert from global IDs to DB IDs.
74
-     * @return array
75
-     */
76
-    protected function sanitizeWhereArgsForInputFields(
77
-        array $where_args,
78
-        array $arg_mapping,
79
-        array $id_fields
80
-    ) {
81
-        $query_args = [];
67
+	/**
68
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
69
+	 * friendly keys.
70
+	 *
71
+	 * @param array $where_args
72
+	 * @param array $arg_mapping
73
+	 * @param array $id_fields   The fields to convert from global IDs to DB IDs.
74
+	 * @return array
75
+	 */
76
+	protected function sanitizeWhereArgsForInputFields(
77
+		array $where_args,
78
+		array $arg_mapping,
79
+		array $id_fields
80
+	) {
81
+		$query_args = [];
82 82
 
83
-        foreach ($where_args as $arg => $value) {
84
-            if (! array_key_exists($arg, $arg_mapping)) {
85
-                continue;
86
-            }
83
+		foreach ($where_args as $arg => $value) {
84
+			if (! array_key_exists($arg, $arg_mapping)) {
85
+				continue;
86
+			}
87 87
 
88
-            if (is_array($value) && ! empty($value)) {
89
-                $value = array_map(
90
-                    static function ($value) {
91
-                        if (is_string($value)) {
92
-                            $value = sanitize_text_field($value);
93
-                        }
94
-                        return $value;
95
-                    },
96
-                    $value
97
-                );
98
-            } elseif (is_string($value)) {
99
-                $value = sanitize_text_field($value);
100
-            }
101
-            $query_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true)
102
-                ? $this->convertGlobalId($value)
103
-                : $value;
104
-        }
88
+			if (is_array($value) && ! empty($value)) {
89
+				$value = array_map(
90
+					static function ($value) {
91
+						if (is_string($value)) {
92
+							$value = sanitize_text_field($value);
93
+						}
94
+						return $value;
95
+					},
96
+					$value
97
+				);
98
+			} elseif (is_string($value)) {
99
+				$value = sanitize_text_field($value);
100
+			}
101
+			$query_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true)
102
+				? $this->convertGlobalId($value)
103
+				: $value;
104
+		}
105 105
 
106
-        /**
107
-         * Return the Query Args
108
-         */
109
-        return ! empty($query_args) && is_array($query_args) ? $query_args : [];
110
-    }
106
+		/**
107
+		 * Return the Query Args
108
+		 */
109
+		return ! empty($query_args) && is_array($query_args) ? $query_args : [];
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * Converts global ID to DB ID.
115
-     *
116
-     * @param string|string[] $ID
117
-     * @return mixed
118
-     */
119
-    protected function convertGlobalId($ID)
120
-    {
121
-        if (is_array($ID)) {
122
-            return array_map([ $this, 'convertGlobalId' ], $ID);
123
-        }
124
-        $parts = Relay::fromGlobalId($ID);
125
-        return ! empty($parts['id']) ? $parts['id'] : null;
126
-    }
113
+	/**
114
+	 * Converts global ID to DB ID.
115
+	 *
116
+	 * @param string|string[] $ID
117
+	 * @return mixed
118
+	 */
119
+	protected function convertGlobalId($ID)
120
+	{
121
+		if (is_array($ID)) {
122
+			return array_map([ $this, 'convertGlobalId' ], $ID);
123
+		}
124
+		$parts = Relay::fromGlobalId($ID);
125
+		return ! empty($parts['id']) ? $parts['id'] : null;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
         /**
52 52
          * Map the orderby inputArgs to the WP_Query
53 53
          */
54
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
54
+        if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
55 55
             $query_args['order_by'] = [];
56 56
             foreach ($this->args['where']['orderby'] as $orderby_input) {
57
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
57
+                $query_args['order_by'][$orderby_input['field']] = $orderby_input['order'];
58 58
             }
59 59
         } elseif ($offset) {
60 60
             $compare                      = $this->args['last'] ? '<' : '>';
61
-            $where_params[ $primary_key ] = [ $compare, $offset ];
61
+            $where_params[$primary_key] = [$compare, $offset];
62 62
         }
63
-        return [ $query_args, $where_params ];
63
+        return [$query_args, $where_params];
64 64
     }
65 65
 
66 66
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
         $query_args = [];
82 82
 
83 83
         foreach ($where_args as $arg => $value) {
84
-            if (! array_key_exists($arg, $arg_mapping)) {
84
+            if ( ! array_key_exists($arg, $arg_mapping)) {
85 85
                 continue;
86 86
             }
87 87
 
88 88
             if (is_array($value) && ! empty($value)) {
89 89
                 $value = array_map(
90
-                    static function ($value) {
90
+                    static function($value) {
91 91
                         if (is_string($value)) {
92 92
                             $value = sanitize_text_field($value);
93 93
                         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             } elseif (is_string($value)) {
99 99
                 $value = sanitize_text_field($value);
100 100
             }
101
-            $query_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true)
101
+            $query_args[$arg_mapping[$arg]] = in_array($arg, $id_fields, true)
102 102
                 ? $this->convertGlobalId($value)
103 103
                 : $value;
104 104
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     protected function convertGlobalId($ID)
120 120
     {
121 121
         if (is_array($ID)) {
122
-            return array_map([ $this, 'convertGlobalId' ], $ID);
122
+            return array_map([$this, 'convertGlobalId'], $ID);
123 123
         }
124 124
         $parts = Relay::fromGlobalId($ID);
125 125
         return ! empty($parts['id']) ? $parts['id'] : null;
Please login to merge, or discard this patch.
core/domain/services/admin/events/editor/AdvancedEditorData.php 2 patches
Indentation   +494 added lines, -494 removed lines patch added patch discarded remove patch
@@ -35,223 +35,223 @@  discard block
 block discarded – undo
35 35
 class AdvancedEditorData
36 36
 {
37 37
 
38
-    /**
39
-     * @var string $namespace The graphql namespace/prefix.
40
-     */
41
-    protected $namespace = 'Espresso';
42
-
43
-    /**
44
-     * @var EE_Event
45
-     */
46
-    protected $event;
47
-
48
-    /**
49
-     * @var EE_Admin_Config
50
-     */
51
-    protected $admin_config;
52
-    /**
53
-     * @var EEM_Datetime $datetime_model
54
-     */
55
-    protected $datetime_model;
56
-    /**
57
-     * @var EEM_Price $price_model
58
-     */
59
-    protected $price_model;
60
-    /**
61
-     * @var EEM_Ticket $ticket_model
62
-     */
63
-    protected $ticket_model;
64
-
65
-
66
-    /**
67
-     * AdvancedEditorAdminForm constructor.
68
-     *
69
-     * @param EE_Event        $event
70
-     * @param EE_Admin_Config $admin_config
71
-     * @param EEM_Datetime    $datetime_model
72
-     * @param EEM_Price       $price_model
73
-     * @param EEM_Ticket      $ticket_model
74
-     */
75
-    public function __construct(
76
-        EE_Event $event,
77
-        EE_Admin_Config $admin_config,
78
-        EEM_Datetime $datetime_model,
79
-        EEM_Price $price_model,
80
-        EEM_Ticket $ticket_model
81
-    ) {
82
-        $this->event = $event;
83
-        $this->admin_config = $admin_config;
84
-        $this->datetime_model = $datetime_model;
85
-        $this->price_model = $price_model;
86
-        $this->ticket_model = $ticket_model;
87
-        add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
88
-    }
89
-
90
-
91
-    /**
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     * @throws ModelConfigurationException
97
-     * @throws ReflectionException
98
-     * @throws UnexpectedEntityException
99
-     * @throws DomainException
100
-     * @since $VID:$
101
-     */
102
-    public function loadScriptsStyles()
103
-    {
104
-        if ($this->admin_config->useAdvancedEditor()) {
105
-            $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
106
-            if (! $eventId) {
107
-                global $post;
108
-                $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
109
-                $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
110
-                    ? $post->ID
111
-                    : $eventId;
112
-            }
113
-            if ($eventId) {
114
-                $data = $this->getEditorData($eventId);
115
-                $data = wp_json_encode($data);
116
-                add_action(
117
-                    'admin_footer',
118
-                    static function () use ($data) {
119
-                        wp_add_inline_script(
120
-                            EspressoEditorAssetManager::JS_HANDLE_EDITOR,
121
-                            "
38
+	/**
39
+	 * @var string $namespace The graphql namespace/prefix.
40
+	 */
41
+	protected $namespace = 'Espresso';
42
+
43
+	/**
44
+	 * @var EE_Event
45
+	 */
46
+	protected $event;
47
+
48
+	/**
49
+	 * @var EE_Admin_Config
50
+	 */
51
+	protected $admin_config;
52
+	/**
53
+	 * @var EEM_Datetime $datetime_model
54
+	 */
55
+	protected $datetime_model;
56
+	/**
57
+	 * @var EEM_Price $price_model
58
+	 */
59
+	protected $price_model;
60
+	/**
61
+	 * @var EEM_Ticket $ticket_model
62
+	 */
63
+	protected $ticket_model;
64
+
65
+
66
+	/**
67
+	 * AdvancedEditorAdminForm constructor.
68
+	 *
69
+	 * @param EE_Event        $event
70
+	 * @param EE_Admin_Config $admin_config
71
+	 * @param EEM_Datetime    $datetime_model
72
+	 * @param EEM_Price       $price_model
73
+	 * @param EEM_Ticket      $ticket_model
74
+	 */
75
+	public function __construct(
76
+		EE_Event $event,
77
+		EE_Admin_Config $admin_config,
78
+		EEM_Datetime $datetime_model,
79
+		EEM_Price $price_model,
80
+		EEM_Ticket $ticket_model
81
+	) {
82
+		$this->event = $event;
83
+		$this->admin_config = $admin_config;
84
+		$this->datetime_model = $datetime_model;
85
+		$this->price_model = $price_model;
86
+		$this->ticket_model = $ticket_model;
87
+		add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
88
+	}
89
+
90
+
91
+	/**
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws ModelConfigurationException
97
+	 * @throws ReflectionException
98
+	 * @throws UnexpectedEntityException
99
+	 * @throws DomainException
100
+	 * @since $VID:$
101
+	 */
102
+	public function loadScriptsStyles()
103
+	{
104
+		if ($this->admin_config->useAdvancedEditor()) {
105
+			$eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
106
+			if (! $eventId) {
107
+				global $post;
108
+				$eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
109
+				$eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
110
+					? $post->ID
111
+					: $eventId;
112
+			}
113
+			if ($eventId) {
114
+				$data = $this->getEditorData($eventId);
115
+				$data = wp_json_encode($data);
116
+				add_action(
117
+					'admin_footer',
118
+					static function () use ($data) {
119
+						wp_add_inline_script(
120
+							EspressoEditorAssetManager::JS_HANDLE_EDITOR,
121
+							"
122 122
 var eeEditorData={$data};
123 123
 ",
124
-                            'before'
125
-                        );
126
-                    }
127
-                );
128
-                add_action(
129
-                    'admin_footer',
130
-                    static function () use ($data) {
131
-                        wp_add_inline_script(
132
-                            EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE,
133
-                            "
124
+							'before'
125
+						);
126
+					}
127
+				);
128
+				add_action(
129
+					'admin_footer',
130
+					static function () use ($data) {
131
+						wp_add_inline_script(
132
+							EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE,
133
+							"
134 134
 var eeEditorData={$data};
135 135
 ",
136
-                            'before'
137
-                        );
138
-                    }
139
-                );
140
-            }
141
-        }
142
-    }
143
-
144
-
145
-    /**
146
-     * @param int $eventId
147
-     * @return array
148
-     * @throws EE_Error
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidInterfaceException
151
-     * @throws ModelConfigurationException
152
-     * @throws UnexpectedEntityException
153
-     * @throws InvalidArgumentException
154
-     * @throws ReflectionException
155
-     * @throws DomainException
156
-     * @since $VID:$
157
-     */
158
-    protected function getEditorData($eventId)
159
-    {
160
-        $event = $this->getEventGraphQLData($eventId);
161
-        $event['dbId'] = $eventId;
162
-
163
-        $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : '';
164
-        $graphqlEndpoint = esc_url($graphqlEndpoint);
165
-
166
-        $currentUser = $this->getGraphQLCurrentUser();
167
-
168
-        $generalSettings = $this->getGraphQLGeneralSettings();
169
-
170
-        $i18n = self::getJedLocaleData('event_espresso');
171
-
172
-        return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n');
173
-    }
174
-
175
-
176
-    /**
177
-     * @param int $eventId
178
-     * @return array
179
-     * @since $VID:$
180
-     */
181
-    protected function getEventGraphQLData($eventId)
182
-    {
183
-        $datetimes = $this->getGraphQLDatetimes($eventId);
184
-
185
-        if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) {
186
-            $this->addDefaultEntities($eventId);
187
-            $datetimes = $this->getGraphQLDatetimes($eventId);
188
-        }
189
-
190
-        if (! empty($datetimes['nodes'])) {
191
-            $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id');
192
-
193
-            if (! empty($datetimeIn)) {
194
-                $tickets = $this->getGraphQLTickets($datetimeIn);
195
-            }
196
-        }
197
-
198
-        if (! empty($tickets['nodes'])) {
199
-            $ticketIn = wp_list_pluck($tickets['nodes'], 'id');
200
-
201
-            if (! empty($ticketIn)) {
202
-                $prices = $this->getGraphQLPrices($ticketIn);
203
-            }
204
-        }
205
-
206
-        $priceTypes = $this->getGraphQLPriceTypes();
207
-
208
-        $relations = $this->getRelationalData($eventId);
209
-
210
-        return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations');
211
-    }
212
-
213
-    /**
214
-     * @param int $eventId
215
-     * @throws DomainException
216
-     * @throws EE_Error
217
-     * @throws InvalidArgumentException
218
-     * @throws InvalidDataTypeException
219
-     * @throws InvalidInterfaceException
220
-     * @throws ModelConfigurationException
221
-     * @throws ReflectionException
222
-     * @throws UnexpectedEntityException
223
-     * @since $VID:$
224
-     */
225
-    protected function addDefaultEntities($eventId)
226
-    {
227
-        $default_dates = $this->datetime_model->create_new_blank_datetime();
228
-        if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
229
-            $default_date = $default_dates[0];
230
-            $default_date->save();
231
-            $default_date->_add_relation_to($eventId, 'Event');
232
-            $default_tickets = $this->ticket_model->get_all_default_tickets();
233
-            $default_prices = $this->price_model->get_all_default_prices();
234
-            foreach ($default_tickets as $default_ticket) {
235
-                $default_ticket->save();
236
-                $default_ticket->_add_relation_to($default_date, 'Datetime');
237
-                foreach ($default_prices as $default_price) {
238
-                    $default_price->save();
239
-                    $default_price->_add_relation_to($default_ticket, 'Ticket');
240
-                }
241
-            }
242
-        }
243
-    }
244
-
245
-
246
-    /**
247
-     * @param int $eventId
248
-     * @return array|null
249
-     * @since $VID:$
250
-     */
251
-    protected function getGraphQLDatetimes($eventId)
252
-    {
253
-        $field_key = lcfirst($this->namespace) . 'Datetimes';
254
-        $query = <<<QUERY
136
+							'before'
137
+						);
138
+					}
139
+				);
140
+			}
141
+		}
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param int $eventId
147
+	 * @return array
148
+	 * @throws EE_Error
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidInterfaceException
151
+	 * @throws ModelConfigurationException
152
+	 * @throws UnexpectedEntityException
153
+	 * @throws InvalidArgumentException
154
+	 * @throws ReflectionException
155
+	 * @throws DomainException
156
+	 * @since $VID:$
157
+	 */
158
+	protected function getEditorData($eventId)
159
+	{
160
+		$event = $this->getEventGraphQLData($eventId);
161
+		$event['dbId'] = $eventId;
162
+
163
+		$graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : '';
164
+		$graphqlEndpoint = esc_url($graphqlEndpoint);
165
+
166
+		$currentUser = $this->getGraphQLCurrentUser();
167
+
168
+		$generalSettings = $this->getGraphQLGeneralSettings();
169
+
170
+		$i18n = self::getJedLocaleData('event_espresso');
171
+
172
+		return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n');
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param int $eventId
178
+	 * @return array
179
+	 * @since $VID:$
180
+	 */
181
+	protected function getEventGraphQLData($eventId)
182
+	{
183
+		$datetimes = $this->getGraphQLDatetimes($eventId);
184
+
185
+		if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) {
186
+			$this->addDefaultEntities($eventId);
187
+			$datetimes = $this->getGraphQLDatetimes($eventId);
188
+		}
189
+
190
+		if (! empty($datetimes['nodes'])) {
191
+			$datetimeIn = wp_list_pluck($datetimes['nodes'], 'id');
192
+
193
+			if (! empty($datetimeIn)) {
194
+				$tickets = $this->getGraphQLTickets($datetimeIn);
195
+			}
196
+		}
197
+
198
+		if (! empty($tickets['nodes'])) {
199
+			$ticketIn = wp_list_pluck($tickets['nodes'], 'id');
200
+
201
+			if (! empty($ticketIn)) {
202
+				$prices = $this->getGraphQLPrices($ticketIn);
203
+			}
204
+		}
205
+
206
+		$priceTypes = $this->getGraphQLPriceTypes();
207
+
208
+		$relations = $this->getRelationalData($eventId);
209
+
210
+		return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations');
211
+	}
212
+
213
+	/**
214
+	 * @param int $eventId
215
+	 * @throws DomainException
216
+	 * @throws EE_Error
217
+	 * @throws InvalidArgumentException
218
+	 * @throws InvalidDataTypeException
219
+	 * @throws InvalidInterfaceException
220
+	 * @throws ModelConfigurationException
221
+	 * @throws ReflectionException
222
+	 * @throws UnexpectedEntityException
223
+	 * @since $VID:$
224
+	 */
225
+	protected function addDefaultEntities($eventId)
226
+	{
227
+		$default_dates = $this->datetime_model->create_new_blank_datetime();
228
+		if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) {
229
+			$default_date = $default_dates[0];
230
+			$default_date->save();
231
+			$default_date->_add_relation_to($eventId, 'Event');
232
+			$default_tickets = $this->ticket_model->get_all_default_tickets();
233
+			$default_prices = $this->price_model->get_all_default_prices();
234
+			foreach ($default_tickets as $default_ticket) {
235
+				$default_ticket->save();
236
+				$default_ticket->_add_relation_to($default_date, 'Datetime');
237
+				foreach ($default_prices as $default_price) {
238
+					$default_price->save();
239
+					$default_price->_add_relation_to($default_ticket, 'Ticket');
240
+				}
241
+			}
242
+		}
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param int $eventId
248
+	 * @return array|null
249
+	 * @since $VID:$
250
+	 */
251
+	protected function getGraphQLDatetimes($eventId)
252
+	{
253
+		$field_key = lcfirst($this->namespace) . 'Datetimes';
254
+		$query = <<<QUERY
255 255
         query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs, \$first: Int, \$last: Int ) {
256 256
             {$field_key}(where: \$where, first: \$first, last: \$last) {
257 257
                 nodes {
@@ -279,31 +279,31 @@  discard block
 block discarded – undo
279 279
             }
280 280
         }
281 281
 QUERY;
282
-        $data = [
283
-            'operation_name' => 'GET_DATETIMES',
284
-            'variables' => [
285
-                'first' => 100,
286
-                'where' => [
287
-                    'eventId' => $eventId,
288
-                ],
289
-            ],
290
-            'query' => $query,
291
-        ];
292
-
293
-        $responseData = $this->makeGraphQLRequest($data);
294
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
295
-    }
296
-
297
-
298
-    /**
299
-     * @param array $datetimeIn
300
-     * @return array|null
301
-     * @since $VID:$
302
-     */
303
-    protected function getGraphQLTickets(array $datetimeIn)
304
-    {
305
-        $field_key = lcfirst($this->namespace) . 'Tickets';
306
-        $query = <<<QUERY
282
+		$data = [
283
+			'operation_name' => 'GET_DATETIMES',
284
+			'variables' => [
285
+				'first' => 100,
286
+				'where' => [
287
+					'eventId' => $eventId,
288
+				],
289
+			],
290
+			'query' => $query,
291
+		];
292
+
293
+		$responseData = $this->makeGraphQLRequest($data);
294
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
295
+	}
296
+
297
+
298
+	/**
299
+	 * @param array $datetimeIn
300
+	 * @return array|null
301
+	 * @since $VID:$
302
+	 */
303
+	protected function getGraphQLTickets(array $datetimeIn)
304
+	{
305
+		$field_key = lcfirst($this->namespace) . 'Tickets';
306
+		$query = <<<QUERY
307 307
         query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) {
308 308
             {$field_key}(where: \$where, first: \$first, last: \$last) {
309 309
                 nodes {
@@ -334,31 +334,31 @@  discard block
 block discarded – undo
334 334
             }
335 335
         }
336 336
 QUERY;
337
-        $data = [
338
-            'operation_name' => 'GET_TICKETS',
339
-            'variables' => [
340
-                'first' => 100,
341
-                'where' => [
342
-                    'datetimeIn' => $datetimeIn,
343
-                ],
344
-            ],
345
-            'query' => $query,
346
-        ];
347
-
348
-        $responseData = $this->makeGraphQLRequest($data);
349
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
350
-    }
351
-
352
-
353
-    /**
354
-     * @param array $ticketIn
355
-     * @return array|null
356
-     * @since $VID:$
357
-     */
358
-    protected function getGraphQLPrices(array $ticketIn)
359
-    {
360
-        $field_key = lcfirst($this->namespace) . 'Prices';
361
-        $query = <<<QUERY
337
+		$data = [
338
+			'operation_name' => 'GET_TICKETS',
339
+			'variables' => [
340
+				'first' => 100,
341
+				'where' => [
342
+					'datetimeIn' => $datetimeIn,
343
+				],
344
+			],
345
+			'query' => $query,
346
+		];
347
+
348
+		$responseData = $this->makeGraphQLRequest($data);
349
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
350
+	}
351
+
352
+
353
+	/**
354
+	 * @param array $ticketIn
355
+	 * @return array|null
356
+	 * @since $VID:$
357
+	 */
358
+	protected function getGraphQLPrices(array $ticketIn)
359
+	{
360
+		$field_key = lcfirst($this->namespace) . 'Prices';
361
+		$query = <<<QUERY
362 362
         query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) {
363 363
             {$field_key}(where: \$where, first: \$first, last: \$last) {
364 364
                 nodes {
@@ -381,30 +381,30 @@  discard block
 block discarded – undo
381 381
             }
382 382
         }
383 383
 QUERY;
384
-        $data = [
385
-            'operation_name' => 'GET_PRICES',
386
-            'variables' => [
387
-                'first' => 100,
388
-                'where' => [
389
-                    'ticketIn' => $ticketIn,
390
-                ],
391
-            ],
392
-            'query' => $query,
393
-        ];
394
-
395
-        $responseData = $this->makeGraphQLRequest($data);
396
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
397
-    }
398
-
399
-
400
-    /**
401
-     * @return array|null
402
-     * @since $VID:$
403
-     */
404
-    protected function getGraphQLPriceTypes()
405
-    {
406
-        $field_key = lcfirst($this->namespace) . 'PriceTypes';
407
-        $query = <<<QUERY
384
+		$data = [
385
+			'operation_name' => 'GET_PRICES',
386
+			'variables' => [
387
+				'first' => 100,
388
+				'where' => [
389
+					'ticketIn' => $ticketIn,
390
+				],
391
+			],
392
+			'query' => $query,
393
+		];
394
+
395
+		$responseData = $this->makeGraphQLRequest($data);
396
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return array|null
402
+	 * @since $VID:$
403
+	 */
404
+	protected function getGraphQLPriceTypes()
405
+	{
406
+		$field_key = lcfirst($this->namespace) . 'PriceTypes';
407
+		$query = <<<QUERY
408 408
         query GET_PRICE_TYPES(\$first: Int, \$last: Int ) {
409 409
             {$field_key}(first: \$first, last: \$last) {
410 410
                 nodes {
@@ -424,27 +424,27 @@  discard block
 block discarded – undo
424 424
             }
425 425
         }
426 426
 QUERY;
427
-        $data = [
428
-            'operation_name' => 'GET_PRICE_TYPES',
429
-            'variables' => [
430
-                'first' => 100,
431
-            ],
432
-            'query' => $query,
433
-        ];
434
-
435
-        $responseData = $this->makeGraphQLRequest($data);
436
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
437
-    }
438
-
439
-
440
-    /**
441
-     * @return array|null
442
-     * @since $VID:$
443
-     */
444
-    protected function getGraphQLCurrentUser()
445
-    {
446
-        $field_key = 'viewer';
447
-        $query = <<<QUERY
427
+		$data = [
428
+			'operation_name' => 'GET_PRICE_TYPES',
429
+			'variables' => [
430
+				'first' => 100,
431
+			],
432
+			'query' => $query,
433
+		];
434
+
435
+		$responseData = $this->makeGraphQLRequest($data);
436
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
437
+	}
438
+
439
+
440
+	/**
441
+	 * @return array|null
442
+	 * @since $VID:$
443
+	 */
444
+	protected function getGraphQLCurrentUser()
445
+	{
446
+		$field_key = 'viewer';
447
+		$query = <<<QUERY
448 448
         query GET_CURRENT_USER {
449 449
             {$field_key} {
450 450
                 description
@@ -462,24 +462,24 @@  discard block
 block discarded – undo
462 462
             }
463 463
         }
464 464
 QUERY;
465
-        $data = [
466
-            'operation_name' => 'GET_CURRENT_USER',
467
-            'query' => $query,
468
-        ];
469
-
470
-        $responseData = $this->makeGraphQLRequest($data);
471
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
472
-    }
473
-
474
-
475
-    /**
476
-     * @return array|null
477
-     * @since $VID:$
478
-     */
479
-    protected function getGraphQLGeneralSettings()
480
-    {
481
-        $field_key = 'generalSettings';
482
-        $query = <<<QUERY
465
+		$data = [
466
+			'operation_name' => 'GET_CURRENT_USER',
467
+			'query' => $query,
468
+		];
469
+
470
+		$responseData = $this->makeGraphQLRequest($data);
471
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
472
+	}
473
+
474
+
475
+	/**
476
+	 * @return array|null
477
+	 * @since $VID:$
478
+	 */
479
+	protected function getGraphQLGeneralSettings()
480
+	{
481
+		$field_key = 'generalSettings';
482
+		$query = <<<QUERY
483 483
         query GET_GENERAL_SETTINGS {
484 484
             {$field_key} {
485 485
                 dateFormat
@@ -489,172 +489,172 @@  discard block
 block discarded – undo
489 489
             }
490 490
         }
491 491
 QUERY;
492
-        $data = [
493
-            'operation_name' => 'GET_CURRENT_USER',
494
-            'query' => $query,
495
-        ];
496
-
497
-        $responseData = $this->makeGraphQLRequest($data);
498
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
499
-    }
500
-
501
-
502
-    /**
503
-     * @param array $data
504
-     * @return array
505
-     * @since $VID:$
506
-     */
507
-    protected function makeGraphQLRequest($data)
508
-    {
509
-        try {
510
-            $response = graphql($data);
511
-            if (!empty($response['data'])) {
512
-                return $response['data'];
513
-            }
514
-            return null;
515
-        } catch (\Exception $e) {
516
-            // do something with the errors thrown
517
-            return null;
518
-        }
519
-    }
520
-
521
-
522
-    /**
523
-     * @param mixed       $source  The source that's passed down the GraphQL queries
524
-     * @param array       $args    The inputArgs on the field
525
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
526
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
527
-     * @return string
528
-     * @throws EE_Error
529
-     * @throws Exception
530
-     * @throws InvalidArgumentException
531
-     * @throws InvalidDataTypeException
532
-     * @throws InvalidInterfaceException
533
-     * @throws ReflectionException
534
-     * @throws UserError
535
-     * @throws UnexpectedEntityException
536
-     * @since $VID:$
537
-     */
538
-    public static function getRelationalData($eventId)
539
-    {
540
-        $data = [
541
-            'datetimes'  => [],
542
-            'tickets'    => [],
543
-            'prices'     => [],
544
-        ];
545
-
546
-        $eem_datetime   = EEM_Datetime::instance();
547
-        $eem_ticket     = EEM_Ticket::instance();
548
-        $eem_price      = EEM_Price::instance();
549
-        $eem_price_type = EEM_Price_Type::instance();
550
-
551
-        // PROCESS DATETIMES
552
-        $related_models = [
553
-            'tickets' => $eem_ticket,
554
-        ];
555
-        // Get the IDs of event datetimes.
556
-        $datetimeIds = $eem_datetime->get_col([[
557
-            'EVT_ID' => $eventId,
558
-            'DTT_deleted' => ['IN', [true, false]],
559
-        ]]);
560
-        foreach ($datetimeIds as $datetimeId) {
561
-            $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId);
562
-            foreach ($related_models as $key => $model) {
563
-                // Get the IDs of related entities for the datetime ID.
564
-                $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]);
565
-                if (! empty($Ids)) {
566
-                    $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
567
-                }
568
-            }
569
-        }
570
-
571
-        // PROCESS TICKETS
572
-        $related_models = [
573
-            'datetimes' => $eem_datetime,
574
-            'prices'    => $eem_price,
575
-        ];
576
-        // Get the IDs of all datetime tickets.
577
-        $ticketIds = $eem_ticket->get_col([[
578
-            'Datetime.DTT_ID' => ['in', $datetimeIds],
579
-            'TKT_deleted' => ['IN', [true, false]],
580
-        ]]);
581
-        foreach ($ticketIds as $ticketId) {
582
-            $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId);
583
-
584
-            foreach ($related_models as $key => $model) {
585
-                // Get the IDs of related entities for the ticket ID.
586
-                $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]);
587
-                if (! empty($Ids)) {
588
-                    $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
589
-                }
590
-            }
591
-        }
592
-
593
-        // PROCESS PRICES
594
-        $related_models = [
595
-            'tickets'    => $eem_ticket,
596
-            'priceTypes' => $eem_price_type,
597
-        ];
598
-        // Get the IDs of all ticket prices.
599
-        $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]);
600
-        foreach ($priceIds as $priceId) {
601
-            $GID = self::convertToGlobalId($eem_price->item_name(), $priceId);
602
-
603
-            foreach ($related_models as $key => $model) {
604
-                // Get the IDs of related entities for the price ID.
605
-                $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]);
606
-                if (! empty($Ids)) {
607
-                    $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
608
-                }
609
-            }
610
-        }
611
-
612
-        return $data;
613
-    }
614
-
615
-    /**
616
-     * Convert the DB ID into GID
617
-     *
618
-     * @param string    $type
619
-     * @param int|int[] $ID
620
-     * @return mixed
621
-     */
622
-    public static function convertToGlobalId($type, $ID)
623
-    {
624
-        if (is_array($ID)) {
625
-            return array_map(function ($id) use ($type) {
626
-                return self::convertToGlobalId($type, $id);
627
-            }, $ID);
628
-        }
629
-        return Relay::toGlobalId($type, $ID);
630
-    }
631
-
632
-
633
-    /**
634
-     * Returns Jed-formatted localization data.
635
-     *
636
-     * @param  string $domain Translation domain.
637
-     * @return array
638
-     */
639
-    public static function getJedLocaleData($domain)
640
-    {
641
-        $translations = get_translations_for_domain($domain);
642
-
643
-        $locale = array(
644
-            '' => array(
645
-                'domain' => $domain,
646
-                'lang'   => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale()
647
-            ),
648
-        );
649
-
650
-        if (! empty($translations->headers['Plural-Forms'])) {
651
-            $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
652
-        }
653
-
654
-        foreach ($translations->entries as $msgid => $entry) {
655
-            $locale[ $msgid ] = $entry->translations;
656
-        }
657
-
658
-        return $locale;
659
-    }
492
+		$data = [
493
+			'operation_name' => 'GET_CURRENT_USER',
494
+			'query' => $query,
495
+		];
496
+
497
+		$responseData = $this->makeGraphQLRequest($data);
498
+		return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
499
+	}
500
+
501
+
502
+	/**
503
+	 * @param array $data
504
+	 * @return array
505
+	 * @since $VID:$
506
+	 */
507
+	protected function makeGraphQLRequest($data)
508
+	{
509
+		try {
510
+			$response = graphql($data);
511
+			if (!empty($response['data'])) {
512
+				return $response['data'];
513
+			}
514
+			return null;
515
+		} catch (\Exception $e) {
516
+			// do something with the errors thrown
517
+			return null;
518
+		}
519
+	}
520
+
521
+
522
+	/**
523
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
524
+	 * @param array       $args    The inputArgs on the field
525
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
526
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
527
+	 * @return string
528
+	 * @throws EE_Error
529
+	 * @throws Exception
530
+	 * @throws InvalidArgumentException
531
+	 * @throws InvalidDataTypeException
532
+	 * @throws InvalidInterfaceException
533
+	 * @throws ReflectionException
534
+	 * @throws UserError
535
+	 * @throws UnexpectedEntityException
536
+	 * @since $VID:$
537
+	 */
538
+	public static function getRelationalData($eventId)
539
+	{
540
+		$data = [
541
+			'datetimes'  => [],
542
+			'tickets'    => [],
543
+			'prices'     => [],
544
+		];
545
+
546
+		$eem_datetime   = EEM_Datetime::instance();
547
+		$eem_ticket     = EEM_Ticket::instance();
548
+		$eem_price      = EEM_Price::instance();
549
+		$eem_price_type = EEM_Price_Type::instance();
550
+
551
+		// PROCESS DATETIMES
552
+		$related_models = [
553
+			'tickets' => $eem_ticket,
554
+		];
555
+		// Get the IDs of event datetimes.
556
+		$datetimeIds = $eem_datetime->get_col([[
557
+			'EVT_ID' => $eventId,
558
+			'DTT_deleted' => ['IN', [true, false]],
559
+		]]);
560
+		foreach ($datetimeIds as $datetimeId) {
561
+			$GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId);
562
+			foreach ($related_models as $key => $model) {
563
+				// Get the IDs of related entities for the datetime ID.
564
+				$Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]);
565
+				if (! empty($Ids)) {
566
+					$data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
567
+				}
568
+			}
569
+		}
570
+
571
+		// PROCESS TICKETS
572
+		$related_models = [
573
+			'datetimes' => $eem_datetime,
574
+			'prices'    => $eem_price,
575
+		];
576
+		// Get the IDs of all datetime tickets.
577
+		$ticketIds = $eem_ticket->get_col([[
578
+			'Datetime.DTT_ID' => ['in', $datetimeIds],
579
+			'TKT_deleted' => ['IN', [true, false]],
580
+		]]);
581
+		foreach ($ticketIds as $ticketId) {
582
+			$GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId);
583
+
584
+			foreach ($related_models as $key => $model) {
585
+				// Get the IDs of related entities for the ticket ID.
586
+				$Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]);
587
+				if (! empty($Ids)) {
588
+					$data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
589
+				}
590
+			}
591
+		}
592
+
593
+		// PROCESS PRICES
594
+		$related_models = [
595
+			'tickets'    => $eem_ticket,
596
+			'priceTypes' => $eem_price_type,
597
+		];
598
+		// Get the IDs of all ticket prices.
599
+		$priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]);
600
+		foreach ($priceIds as $priceId) {
601
+			$GID = self::convertToGlobalId($eem_price->item_name(), $priceId);
602
+
603
+			foreach ($related_models as $key => $model) {
604
+				// Get the IDs of related entities for the price ID.
605
+				$Ids = $model->get_col([['Price.PRC_ID' => $priceId]]);
606
+				if (! empty($Ids)) {
607
+					$data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
608
+				}
609
+			}
610
+		}
611
+
612
+		return $data;
613
+	}
614
+
615
+	/**
616
+	 * Convert the DB ID into GID
617
+	 *
618
+	 * @param string    $type
619
+	 * @param int|int[] $ID
620
+	 * @return mixed
621
+	 */
622
+	public static function convertToGlobalId($type, $ID)
623
+	{
624
+		if (is_array($ID)) {
625
+			return array_map(function ($id) use ($type) {
626
+				return self::convertToGlobalId($type, $id);
627
+			}, $ID);
628
+		}
629
+		return Relay::toGlobalId($type, $ID);
630
+	}
631
+
632
+
633
+	/**
634
+	 * Returns Jed-formatted localization data.
635
+	 *
636
+	 * @param  string $domain Translation domain.
637
+	 * @return array
638
+	 */
639
+	public static function getJedLocaleData($domain)
640
+	{
641
+		$translations = get_translations_for_domain($domain);
642
+
643
+		$locale = array(
644
+			'' => array(
645
+				'domain' => $domain,
646
+				'lang'   => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale()
647
+			),
648
+		);
649
+
650
+		if (! empty($translations->headers['Plural-Forms'])) {
651
+			$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
652
+		}
653
+
654
+		foreach ($translations->entries as $msgid => $entry) {
655
+			$locale[ $msgid ] = $entry->translations;
656
+		}
657
+
658
+		return $locale;
659
+	}
660 660
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         if ($this->admin_config->useAdvancedEditor()) {
105 105
             $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0;
106
-            if (! $eventId) {
106
+            if ( ! $eventId) {
107 107
                 global $post;
108 108
                 $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
109 109
                 $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $data = wp_json_encode($data);
116 116
                 add_action(
117 117
                     'admin_footer',
118
-                    static function () use ($data) {
118
+                    static function() use ($data) {
119 119
                         wp_add_inline_script(
120 120
                             EspressoEditorAssetManager::JS_HANDLE_EDITOR,
121 121
                             "
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 );
128 128
                 add_action(
129 129
                     'admin_footer',
130
-                    static function () use ($data) {
130
+                    static function() use ($data) {
131 131
                         wp_add_inline_script(
132 132
                             EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE,
133 133
                             "
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $event = $this->getEventGraphQLData($eventId);
161 161
         $event['dbId'] = $eventId;
162 162
 
163
-        $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : '';
163
+        $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : '';
164 164
         $graphqlEndpoint = esc_url($graphqlEndpoint);
165 165
 
166 166
         $currentUser = $this->getGraphQLCurrentUser();
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
             $datetimes = $this->getGraphQLDatetimes($eventId);
188 188
         }
189 189
 
190
-        if (! empty($datetimes['nodes'])) {
190
+        if ( ! empty($datetimes['nodes'])) {
191 191
             $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id');
192 192
 
193
-            if (! empty($datetimeIn)) {
193
+            if ( ! empty($datetimeIn)) {
194 194
                 $tickets = $this->getGraphQLTickets($datetimeIn);
195 195
             }
196 196
         }
197 197
 
198
-        if (! empty($tickets['nodes'])) {
198
+        if ( ! empty($tickets['nodes'])) {
199 199
             $ticketIn = wp_list_pluck($tickets['nodes'], 'id');
200 200
 
201
-            if (! empty($ticketIn)) {
201
+            if ( ! empty($ticketIn)) {
202 202
                 $prices = $this->getGraphQLPrices($ticketIn);
203 203
             }
204 204
         }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     protected function getGraphQLDatetimes($eventId)
252 252
     {
253
-        $field_key = lcfirst($this->namespace) . 'Datetimes';
253
+        $field_key = lcfirst($this->namespace).'Datetimes';
254 254
         $query = <<<QUERY
255 255
         query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs, \$first: Int, \$last: Int ) {
256 256
             {$field_key}(where: \$where, first: \$first, last: \$last) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         ];
292 292
 
293 293
         $responseData = $this->makeGraphQLRequest($data);
294
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
294
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
295 295
     }
296 296
 
297 297
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     protected function getGraphQLTickets(array $datetimeIn)
304 304
     {
305
-        $field_key = lcfirst($this->namespace) . 'Tickets';
305
+        $field_key = lcfirst($this->namespace).'Tickets';
306 306
         $query = <<<QUERY
307 307
         query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) {
308 308
             {$field_key}(where: \$where, first: \$first, last: \$last) {
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         ];
347 347
 
348 348
         $responseData = $this->makeGraphQLRequest($data);
349
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
349
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
350 350
     }
351 351
 
352 352
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      */
358 358
     protected function getGraphQLPrices(array $ticketIn)
359 359
     {
360
-        $field_key = lcfirst($this->namespace) . 'Prices';
360
+        $field_key = lcfirst($this->namespace).'Prices';
361 361
         $query = <<<QUERY
362 362
         query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) {
363 363
             {$field_key}(where: \$where, first: \$first, last: \$last) {
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         ];
394 394
 
395 395
         $responseData = $this->makeGraphQLRequest($data);
396
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
396
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
397 397
     }
398 398
 
399 399
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      */
404 404
     protected function getGraphQLPriceTypes()
405 405
     {
406
-        $field_key = lcfirst($this->namespace) . 'PriceTypes';
406
+        $field_key = lcfirst($this->namespace).'PriceTypes';
407 407
         $query = <<<QUERY
408 408
         query GET_PRICE_TYPES(\$first: Int, \$last: Int ) {
409 409
             {$field_key}(first: \$first, last: \$last) {
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
         ];
434 434
 
435 435
         $responseData = $this->makeGraphQLRequest($data);
436
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
436
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
437 437
     }
438 438
 
439 439
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
         ];
469 469
 
470 470
         $responseData = $this->makeGraphQLRequest($data);
471
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
471
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
472 472
     }
473 473
 
474 474
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         ];
496 496
 
497 497
         $responseData = $this->makeGraphQLRequest($data);
498
-        return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null;
498
+        return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null;
499 499
     }
500 500
 
501 501
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
     {
509 509
         try {
510 510
             $response = graphql($data);
511
-            if (!empty($response['data'])) {
511
+            if ( ! empty($response['data'])) {
512 512
                 return $response['data'];
513 513
             }
514 514
             return null;
@@ -562,8 +562,8 @@  discard block
 block discarded – undo
562 562
             foreach ($related_models as $key => $model) {
563 563
                 // Get the IDs of related entities for the datetime ID.
564 564
                 $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]);
565
-                if (! empty($Ids)) {
566
-                    $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
565
+                if ( ! empty($Ids)) {
566
+                    $data['datetimes'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids);
567 567
                 }
568 568
             }
569 569
         }
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
             foreach ($related_models as $key => $model) {
585 585
                 // Get the IDs of related entities for the ticket ID.
586 586
                 $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]);
587
-                if (! empty($Ids)) {
588
-                    $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
587
+                if ( ! empty($Ids)) {
588
+                    $data['tickets'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids);
589 589
                 }
590 590
             }
591 591
         }
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
             foreach ($related_models as $key => $model) {
604 604
                 // Get the IDs of related entities for the price ID.
605 605
                 $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]);
606
-                if (! empty($Ids)) {
607
-                    $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids);
606
+                if ( ! empty($Ids)) {
607
+                    $data['prices'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids);
608 608
                 }
609 609
             }
610 610
         }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
     public static function convertToGlobalId($type, $ID)
623 623
     {
624 624
         if (is_array($ID)) {
625
-            return array_map(function ($id) use ($type) {
625
+            return array_map(function($id) use ($type) {
626 626
                 return self::convertToGlobalId($type, $id);
627 627
             }, $ID);
628 628
         }
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
             ),
648 648
         );
649 649
 
650
-        if (! empty($translations->headers['Plural-Forms'])) {
650
+        if ( ! empty($translations->headers['Plural-Forms'])) {
651 651
             $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
652 652
         }
653 653
 
654 654
         foreach ($translations->entries as $msgid => $entry) {
655
-            $locale[ $msgid ] = $entry->translations;
655
+            $locale[$msgid] = $entry->translations;
656 656
         }
657 657
 
658 658
         return $locale;
Please login to merge, or discard this patch.