@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | $format = 'f'; |
169 | 169 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
170 | 170 | // first get the decimal place and number of places |
171 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
171 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
172 | 172 | // currency symbol on right side. |
173 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
173 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
174 | 174 | return $format; |
175 | 175 | } |
176 | 176 | |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
191 | 191 | $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
192 | 192 | // first get the decimal place and number of places |
193 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
193 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
194 | 194 | // currency symbol on right side. |
195 | 195 | $format = $currency_config->sign_b4 |
196 | - ? $currency_config->sign . $format |
|
196 | + ? $currency_config->sign.$format |
|
197 | 197 | : $format |
198 | 198 | . $currency_config->sign; |
199 | 199 | $formatterObject = array( |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ? new EE_Currency_Config($CNT_ISO) |
226 | 226 | : null; |
227 | 227 | // default currency settings for site if not set |
228 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
228 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
229 | 229 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
230 | 230 | ? EE_Registry::instance()->CFG->currency |
231 | 231 | : new EE_Currency_Config(); |
@@ -12,226 +12,226 @@ |
||
12 | 12 | class EEH_Money extends EEH_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * This removes all localized money formatting from the incoming value |
|
17 | - * Note: uses this site's currency settings for deciding what is considered a |
|
18 | - * "thousands separator" (usually the character "," ) |
|
19 | - * and what is a "decimal mark" (usually the character ".") |
|
20 | - * |
|
21 | - * @param int|float|string $money_value |
|
22 | - * @param string $CNT_ISO |
|
23 | - * @return float |
|
24 | - * @throws EE_Error |
|
25 | - */ |
|
26 | - public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') |
|
27 | - { |
|
28 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
29 | - $money_value = str_replace( |
|
30 | - array( |
|
31 | - $currency_config->thsnds, |
|
32 | - $currency_config->dec_mrk, |
|
33 | - ), |
|
34 | - array( |
|
35 | - '', // remove thousands separator |
|
36 | - '.', // convert decimal mark to what PHP expects |
|
37 | - ), |
|
38 | - $money_value |
|
39 | - ); |
|
40 | - $money_value = filter_var( |
|
41 | - $money_value, |
|
42 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
43 | - FILTER_FLAG_ALLOW_FRACTION |
|
44 | - ); |
|
45 | - return $money_value; |
|
46 | - } |
|
15 | + /** |
|
16 | + * This removes all localized money formatting from the incoming value |
|
17 | + * Note: uses this site's currency settings for deciding what is considered a |
|
18 | + * "thousands separator" (usually the character "," ) |
|
19 | + * and what is a "decimal mark" (usually the character ".") |
|
20 | + * |
|
21 | + * @param int|float|string $money_value |
|
22 | + * @param string $CNT_ISO |
|
23 | + * @return float |
|
24 | + * @throws EE_Error |
|
25 | + */ |
|
26 | + public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') |
|
27 | + { |
|
28 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
29 | + $money_value = str_replace( |
|
30 | + array( |
|
31 | + $currency_config->thsnds, |
|
32 | + $currency_config->dec_mrk, |
|
33 | + ), |
|
34 | + array( |
|
35 | + '', // remove thousands separator |
|
36 | + '.', // convert decimal mark to what PHP expects |
|
37 | + ), |
|
38 | + $money_value |
|
39 | + ); |
|
40 | + $money_value = filter_var( |
|
41 | + $money_value, |
|
42 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
43 | + FILTER_FLAG_ALLOW_FRACTION |
|
44 | + ); |
|
45 | + return $money_value; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
51 | - * Only use this if you know the $money_value follows your currency configuration's |
|
52 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
53 | - * "thousands separator" (usually the character "," ) |
|
54 | - * and what is a "decimal mark" (usually the character ".") |
|
55 | - * |
|
56 | - * @param int|string $money_value |
|
57 | - * @return float |
|
58 | - * @throws EE_Error |
|
59 | - */ |
|
60 | - public static function convert_to_float_from_localized_money($money_value) |
|
61 | - { |
|
62 | - // float it! and round to three decimal places |
|
63 | - return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
64 | - } |
|
49 | + /** |
|
50 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
51 | + * Only use this if you know the $money_value follows your currency configuration's |
|
52 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
53 | + * "thousands separator" (usually the character "," ) |
|
54 | + * and what is a "decimal mark" (usually the character ".") |
|
55 | + * |
|
56 | + * @param int|string $money_value |
|
57 | + * @return float |
|
58 | + * @throws EE_Error |
|
59 | + */ |
|
60 | + public static function convert_to_float_from_localized_money($money_value) |
|
61 | + { |
|
62 | + // float it! and round to three decimal places |
|
63 | + return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
69 | - * This should be used to compare floats instead of normal '==' because floats |
|
70 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
71 | - * but actually differ by 0.00000001. |
|
72 | - * |
|
73 | - * @see http://biostall.com/php-function-to-compare-floating-point-numbers |
|
74 | - * @param float $float1 |
|
75 | - * @param float $float2 |
|
76 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
77 | - * @return bool whether the equation is true or false |
|
78 | - * @throws EE_Error |
|
79 | - */ |
|
80 | - public static function compare_floats($float1, $float2, $operator = '=') |
|
81 | - { |
|
82 | - // Check numbers to 5 digits of precision |
|
83 | - $epsilon = 0.00001; |
|
84 | - $float1 = (float) $float1; |
|
85 | - $float2 = (float) $float2; |
|
86 | - switch ($operator) { |
|
87 | - // equal |
|
88 | - case '=': |
|
89 | - case '==': |
|
90 | - case '===': |
|
91 | - case 'eq': |
|
92 | - if (abs($float1 - $float2) < $epsilon) { |
|
93 | - return true; |
|
94 | - } |
|
95 | - break; |
|
96 | - // less than |
|
97 | - case '<': |
|
98 | - case 'lt': |
|
99 | - if (abs($float1 - $float2) < $epsilon) { |
|
100 | - return false; |
|
101 | - } |
|
102 | - if ($float1 < $float2) { |
|
103 | - return true; |
|
104 | - } |
|
105 | - break; |
|
106 | - // less than or equal |
|
107 | - case '<=': |
|
108 | - case 'lte': |
|
109 | - if ( |
|
110 | - self::compare_floats($float1, $float2, '<') |
|
111 | - || self::compare_floats($float1, $float2, '=') |
|
112 | - ) { |
|
113 | - return true; |
|
114 | - } |
|
115 | - break; |
|
116 | - // greater than |
|
117 | - case '>': |
|
118 | - case 'gt': |
|
119 | - if (abs($float1 - $float2) < $epsilon) { |
|
120 | - return false; |
|
121 | - } |
|
122 | - if ($float1 > $float2) { |
|
123 | - return true; |
|
124 | - } |
|
125 | - break; |
|
126 | - // greater than or equal |
|
127 | - case '>=': |
|
128 | - case 'gte': |
|
129 | - if ( |
|
130 | - self::compare_floats($float1, $float2, '>') |
|
131 | - || self::compare_floats($float1, $float2, '=') |
|
132 | - ) { |
|
133 | - return true; |
|
134 | - } |
|
135 | - break; |
|
136 | - case '<>': |
|
137 | - case '!=': |
|
138 | - case '!==': |
|
139 | - case 'ne': |
|
140 | - if (abs($float1 - $float2) > $epsilon) { |
|
141 | - return true; |
|
142 | - } |
|
143 | - break; |
|
144 | - default: |
|
145 | - throw new EE_Error( |
|
146 | - sprintf( |
|
147 | - __( |
|
148 | - 'Unknown operator %s in EEH_Money::compare_floats()', |
|
149 | - 'event_espresso' |
|
150 | - ), |
|
151 | - $operator |
|
152 | - ) |
|
153 | - ); |
|
154 | - } |
|
155 | - return false; |
|
156 | - } |
|
67 | + /** |
|
68 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
69 | + * This should be used to compare floats instead of normal '==' because floats |
|
70 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
71 | + * but actually differ by 0.00000001. |
|
72 | + * |
|
73 | + * @see http://biostall.com/php-function-to-compare-floating-point-numbers |
|
74 | + * @param float $float1 |
|
75 | + * @param float $float2 |
|
76 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
77 | + * @return bool whether the equation is true or false |
|
78 | + * @throws EE_Error |
|
79 | + */ |
|
80 | + public static function compare_floats($float1, $float2, $operator = '=') |
|
81 | + { |
|
82 | + // Check numbers to 5 digits of precision |
|
83 | + $epsilon = 0.00001; |
|
84 | + $float1 = (float) $float1; |
|
85 | + $float2 = (float) $float2; |
|
86 | + switch ($operator) { |
|
87 | + // equal |
|
88 | + case '=': |
|
89 | + case '==': |
|
90 | + case '===': |
|
91 | + case 'eq': |
|
92 | + if (abs($float1 - $float2) < $epsilon) { |
|
93 | + return true; |
|
94 | + } |
|
95 | + break; |
|
96 | + // less than |
|
97 | + case '<': |
|
98 | + case 'lt': |
|
99 | + if (abs($float1 - $float2) < $epsilon) { |
|
100 | + return false; |
|
101 | + } |
|
102 | + if ($float1 < $float2) { |
|
103 | + return true; |
|
104 | + } |
|
105 | + break; |
|
106 | + // less than or equal |
|
107 | + case '<=': |
|
108 | + case 'lte': |
|
109 | + if ( |
|
110 | + self::compare_floats($float1, $float2, '<') |
|
111 | + || self::compare_floats($float1, $float2, '=') |
|
112 | + ) { |
|
113 | + return true; |
|
114 | + } |
|
115 | + break; |
|
116 | + // greater than |
|
117 | + case '>': |
|
118 | + case 'gt': |
|
119 | + if (abs($float1 - $float2) < $epsilon) { |
|
120 | + return false; |
|
121 | + } |
|
122 | + if ($float1 > $float2) { |
|
123 | + return true; |
|
124 | + } |
|
125 | + break; |
|
126 | + // greater than or equal |
|
127 | + case '>=': |
|
128 | + case 'gte': |
|
129 | + if ( |
|
130 | + self::compare_floats($float1, $float2, '>') |
|
131 | + || self::compare_floats($float1, $float2, '=') |
|
132 | + ) { |
|
133 | + return true; |
|
134 | + } |
|
135 | + break; |
|
136 | + case '<>': |
|
137 | + case '!=': |
|
138 | + case '!==': |
|
139 | + case 'ne': |
|
140 | + if (abs($float1 - $float2) > $epsilon) { |
|
141 | + return true; |
|
142 | + } |
|
143 | + break; |
|
144 | + default: |
|
145 | + throw new EE_Error( |
|
146 | + sprintf( |
|
147 | + __( |
|
148 | + 'Unknown operator %s in EEH_Money::compare_floats()', |
|
149 | + 'event_espresso' |
|
150 | + ), |
|
151 | + $operator |
|
152 | + ) |
|
153 | + ); |
|
154 | + } |
|
155 | + return false; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | |
159 | - /** |
|
160 | - * This returns a localized format string suitable for jQplot. |
|
161 | - * |
|
162 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
163 | - * Otherwise will use currency settings for current active country on site. |
|
164 | - * @return string |
|
165 | - * @throws EE_Error |
|
166 | - */ |
|
167 | - public static function get_format_for_jqplot($CNT_ISO = '') |
|
168 | - { |
|
169 | - // default format |
|
170 | - $format = 'f'; |
|
171 | - $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
172 | - // first get the decimal place and number of places |
|
173 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
174 | - // currency symbol on right side. |
|
175 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
176 | - return $format; |
|
177 | - } |
|
159 | + /** |
|
160 | + * This returns a localized format string suitable for jQplot. |
|
161 | + * |
|
162 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
163 | + * Otherwise will use currency settings for current active country on site. |
|
164 | + * @return string |
|
165 | + * @throws EE_Error |
|
166 | + */ |
|
167 | + public static function get_format_for_jqplot($CNT_ISO = '') |
|
168 | + { |
|
169 | + // default format |
|
170 | + $format = 'f'; |
|
171 | + $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
172 | + // first get the decimal place and number of places |
|
173 | + $format = "%'." . $currency_config->dec_plc . $format; |
|
174 | + // currency symbol on right side. |
|
175 | + $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
176 | + return $format; |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | - /** |
|
181 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
182 | - * |
|
183 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
184 | - * Otherwise will use currency settings for current active country on site. |
|
185 | - * Note: GoogleCharts uses ICU pattern set |
|
186 | - * (@return array |
|
187 | - * @throws EE_Error |
|
188 | - * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
189 | - */ |
|
190 | - public static function get_format_for_google_charts($CNT_ISO = '') |
|
191 | - { |
|
192 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
193 | - $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
194 | - // first get the decimal place and number of places |
|
195 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
196 | - // currency symbol on right side. |
|
197 | - $format = $currency_config->sign_b4 |
|
198 | - ? $currency_config->sign . $format |
|
199 | - : $format |
|
200 | - . $currency_config->sign; |
|
201 | - $formatterObject = array( |
|
202 | - 'decimalSymbol' => $currency_config->dec_mrk, |
|
203 | - 'groupingSymbol' => $currency_config->thsnds, |
|
204 | - 'fractionDigits' => $currency_config->dec_plc, |
|
205 | - ); |
|
206 | - if ($currency_config->sign_b4) { |
|
207 | - $formatterObject['prefix'] = $currency_config->sign; |
|
208 | - } else { |
|
209 | - $formatterObject['suffix'] = $currency_config->sign; |
|
210 | - } |
|
211 | - return array( |
|
212 | - 'format' => $format, |
|
213 | - 'formatterObject' => $formatterObject, |
|
214 | - ); |
|
215 | - } |
|
180 | + /** |
|
181 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
182 | + * |
|
183 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
184 | + * Otherwise will use currency settings for current active country on site. |
|
185 | + * Note: GoogleCharts uses ICU pattern set |
|
186 | + * (@return array |
|
187 | + * @throws EE_Error |
|
188 | + * @see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
189 | + */ |
|
190 | + public static function get_format_for_google_charts($CNT_ISO = '') |
|
191 | + { |
|
192 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
193 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
194 | + // first get the decimal place and number of places |
|
195 | + $format = '#,##0.' . $decimal_places_placeholder; |
|
196 | + // currency symbol on right side. |
|
197 | + $format = $currency_config->sign_b4 |
|
198 | + ? $currency_config->sign . $format |
|
199 | + : $format |
|
200 | + . $currency_config->sign; |
|
201 | + $formatterObject = array( |
|
202 | + 'decimalSymbol' => $currency_config->dec_mrk, |
|
203 | + 'groupingSymbol' => $currency_config->thsnds, |
|
204 | + 'fractionDigits' => $currency_config->dec_plc, |
|
205 | + ); |
|
206 | + if ($currency_config->sign_b4) { |
|
207 | + $formatterObject['prefix'] = $currency_config->sign; |
|
208 | + } else { |
|
209 | + $formatterObject['suffix'] = $currency_config->sign; |
|
210 | + } |
|
211 | + return array( |
|
212 | + 'format' => $format, |
|
213 | + 'formatterObject' => $formatterObject, |
|
214 | + ); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * @param string $CNT_ISO |
|
220 | - * @return EE_Currency_Config |
|
221 | - * @throws EE_Error |
|
222 | - */ |
|
223 | - public static function get_currency_config($CNT_ISO = '') |
|
224 | - { |
|
225 | - // if CNT_ISO passed lets try to get currency settings for it. |
|
226 | - $currency_config = $CNT_ISO !== '' |
|
227 | - ? new EE_Currency_Config($CNT_ISO) |
|
228 | - : null; |
|
229 | - // default currency settings for site if not set |
|
230 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
231 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
232 | - ? EE_Registry::instance()->CFG->currency |
|
233 | - : new EE_Currency_Config(); |
|
234 | - } |
|
235 | - return $currency_config; |
|
236 | - } |
|
218 | + /** |
|
219 | + * @param string $CNT_ISO |
|
220 | + * @return EE_Currency_Config |
|
221 | + * @throws EE_Error |
|
222 | + */ |
|
223 | + public static function get_currency_config($CNT_ISO = '') |
|
224 | + { |
|
225 | + // if CNT_ISO passed lets try to get currency settings for it. |
|
226 | + $currency_config = $CNT_ISO !== '' |
|
227 | + ? new EE_Currency_Config($CNT_ISO) |
|
228 | + : null; |
|
229 | + // default currency settings for site if not set |
|
230 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
231 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
232 | + ? EE_Registry::instance()->CFG->currency |
|
233 | + : new EE_Currency_Config(); |
|
234 | + } |
|
235 | + return $currency_config; |
|
236 | + } |
|
237 | 237 | } |
@@ -13,10 +13,10 @@ |
||
13 | 13 | interface AdminPageHeaderDecoratorInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param string $text |
|
18 | - * @return string |
|
19 | - * @since 4.10.2.p |
|
20 | - */ |
|
21 | - public function getHeaderText($text = ''); |
|
16 | + /** |
|
17 | + * @param string $text |
|
18 | + * @return string |
|
19 | + * @since 4.10.2.p |
|
20 | + */ |
|
21 | + public function getHeaderText($text = ''); |
|
22 | 22 | } |
@@ -24,63 +24,63 @@ |
||
24 | 24 | class EventFilterHeader extends AdminPageHeaderDecorator |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EEM_Event $event_model |
|
29 | - */ |
|
30 | - private $event_model; |
|
27 | + /** |
|
28 | + * @var EEM_Event $event_model |
|
29 | + */ |
|
30 | + private $event_model; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * EventFilterHeader constructor. |
|
35 | - * |
|
36 | - * @param RequestInterface $request |
|
37 | - * @param EEM_Event $event_model |
|
38 | - */ |
|
39 | - public function __construct(RequestInterface $request, EEM_Event $event_model) |
|
40 | - { |
|
41 | - parent::__construct($request); |
|
42 | - $this->event_model = $event_model; |
|
43 | - } |
|
33 | + /** |
|
34 | + * EventFilterHeader constructor. |
|
35 | + * |
|
36 | + * @param RequestInterface $request |
|
37 | + * @param EEM_Event $event_model |
|
38 | + */ |
|
39 | + public function __construct(RequestInterface $request, EEM_Event $event_model) |
|
40 | + { |
|
41 | + parent::__construct($request); |
|
42 | + $this->event_model = $event_model; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param string $text |
|
48 | - * @return string |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidDataTypeException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws ReflectionException |
|
54 | - * @since 4.10.2.p |
|
55 | - */ |
|
56 | - public function getHeaderText($text = '') |
|
57 | - { |
|
58 | - $EVT_ID = $this->request->getRequestParam('EVT_ID'); |
|
59 | - $EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID); |
|
60 | - $EVT_ID = absint($EVT_ID); |
|
61 | - if ($EVT_ID) { |
|
62 | - $event = $this->event_model->get_one_by_ID($EVT_ID); |
|
63 | - if ($event instanceof EE_Event) { |
|
64 | - $text .= sprintf( |
|
65 | - /* translators: %s: <h3> %s: <a href>Event Name</a> %s: </h3> */ |
|
66 | - // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText |
|
67 | - esc_html__('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
68 | - '<h3 style="line-height:1.5em;">', |
|
69 | - ' <a href="' |
|
70 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
71 | - array( |
|
72 | - 'action' => 'edit', |
|
73 | - 'post' => $event->ID(), |
|
74 | - ), |
|
75 | - EVENTS_ADMIN_URL |
|
76 | - ) |
|
77 | - . '">' |
|
78 | - . $event->get('EVT_name') |
|
79 | - . '</a> ', |
|
80 | - '</h3>' |
|
81 | - ); |
|
82 | - } |
|
83 | - } |
|
84 | - return $text; |
|
85 | - } |
|
46 | + /** |
|
47 | + * @param string $text |
|
48 | + * @return string |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidDataTypeException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws ReflectionException |
|
54 | + * @since 4.10.2.p |
|
55 | + */ |
|
56 | + public function getHeaderText($text = '') |
|
57 | + { |
|
58 | + $EVT_ID = $this->request->getRequestParam('EVT_ID'); |
|
59 | + $EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID); |
|
60 | + $EVT_ID = absint($EVT_ID); |
|
61 | + if ($EVT_ID) { |
|
62 | + $event = $this->event_model->get_one_by_ID($EVT_ID); |
|
63 | + if ($event instanceof EE_Event) { |
|
64 | + $text .= sprintf( |
|
65 | + /* translators: %s: <h3> %s: <a href>Event Name</a> %s: </h3> */ |
|
66 | + // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText |
|
67 | + esc_html__('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
68 | + '<h3 style="line-height:1.5em;">', |
|
69 | + ' <a href="' |
|
70 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
71 | + array( |
|
72 | + 'action' => 'edit', |
|
73 | + 'post' => $event->ID(), |
|
74 | + ), |
|
75 | + EVENTS_ADMIN_URL |
|
76 | + ) |
|
77 | + . '">' |
|
78 | + . $event->get('EVT_name') |
|
79 | + . '</a> ', |
|
80 | + '</h3>' |
|
81 | + ); |
|
82 | + } |
|
83 | + } |
|
84 | + return $text; |
|
85 | + } |
|
86 | 86 | } |
@@ -49,137 +49,137 @@ |
||
49 | 49 | class RestApiSpoofer |
50 | 50 | { |
51 | 51 | |
52 | - /** |
|
53 | - * @var WP_REST_Server $wp_rest_server |
|
54 | - */ |
|
55 | - protected $wp_rest_server; |
|
52 | + /** |
|
53 | + * @var WP_REST_Server $wp_rest_server |
|
54 | + */ |
|
55 | + protected $wp_rest_server; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var Read |
|
59 | - */ |
|
60 | - protected $rest_controller; |
|
57 | + /** |
|
58 | + * @var Read |
|
59 | + */ |
|
60 | + protected $rest_controller; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var EED_Core_Rest_Api $rest_module |
|
64 | - */ |
|
65 | - protected $rest_module; |
|
62 | + /** |
|
63 | + * @var EED_Core_Rest_Api $rest_module |
|
64 | + */ |
|
65 | + protected $rest_module; |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * RestApiSpoofer constructor. |
|
70 | - * |
|
71 | - * @param WP_REST_Server $wp_rest_server |
|
72 | - * @param EED_Core_Rest_Api $rest_module |
|
73 | - * @param Read $rest_api |
|
74 | - * @param string $api_version |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - WP_REST_Server $wp_rest_server, |
|
78 | - EED_Core_Rest_Api $rest_module, |
|
79 | - Read $rest_api, |
|
80 | - $api_version = '4.8.36' |
|
81 | - ) { |
|
82 | - $this->wp_rest_server = $wp_rest_server; |
|
83 | - $this->rest_module = $rest_module; |
|
84 | - $this->rest_controller = $rest_api; |
|
85 | - $this->rest_controller->setRequestedVersion($api_version); |
|
86 | - $this->setUpRestServer(); |
|
87 | - } |
|
68 | + /** |
|
69 | + * RestApiSpoofer constructor. |
|
70 | + * |
|
71 | + * @param WP_REST_Server $wp_rest_server |
|
72 | + * @param EED_Core_Rest_Api $rest_module |
|
73 | + * @param Read $rest_api |
|
74 | + * @param string $api_version |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + WP_REST_Server $wp_rest_server, |
|
78 | + EED_Core_Rest_Api $rest_module, |
|
79 | + Read $rest_api, |
|
80 | + $api_version = '4.8.36' |
|
81 | + ) { |
|
82 | + $this->wp_rest_server = $wp_rest_server; |
|
83 | + $this->rest_module = $rest_module; |
|
84 | + $this->rest_controller = $rest_api; |
|
85 | + $this->rest_controller->setRequestedVersion($api_version); |
|
86 | + $this->setUpRestServer(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - private function setUpRestServer() |
|
91 | - { |
|
92 | - /* @var WP_REST_Server $wp_rest_server */ |
|
93 | - global $wp_rest_server; |
|
94 | - $wp_rest_server = $this->wp_rest_server; |
|
95 | - EED_Core_Rest_Api::set_hooks_both(); |
|
96 | - do_action('rest_api_init', $this->wp_rest_server); |
|
97 | - } |
|
90 | + private function setUpRestServer() |
|
91 | + { |
|
92 | + /* @var WP_REST_Server $wp_rest_server */ |
|
93 | + global $wp_rest_server; |
|
94 | + $wp_rest_server = $this->wp_rest_server; |
|
95 | + EED_Core_Rest_Api::set_hooks_both(); |
|
96 | + do_action('rest_api_init', $this->wp_rest_server); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param EEM_Base $model |
|
101 | - * @param array $query_params |
|
102 | - * @param string $include |
|
103 | - * @return array |
|
104 | - * @throws EE_Error |
|
105 | - * @throws InvalidArgumentException |
|
106 | - * @throws InvalidDataTypeException |
|
107 | - * @throws InvalidInterfaceException |
|
108 | - * @throws ModelConfigurationException |
|
109 | - * @throws ReflectionException |
|
110 | - * @throws RestException |
|
111 | - * @throws RestPasswordIncorrectException |
|
112 | - * @throws RestPasswordRequiredException |
|
113 | - * @throws UnexpectedEntityException |
|
114 | - * @throws DomainException |
|
115 | - * @since $VID:$ |
|
116 | - */ |
|
117 | - public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | - { |
|
119 | - if (! array_key_exists('limit', $query_params)) { |
|
120 | - $query_params['limit'] = 1; |
|
121 | - } |
|
122 | - $result = $this->getApiResults($model, $query_params, $include); |
|
123 | - return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | - } |
|
99 | + /** |
|
100 | + * @param EEM_Base $model |
|
101 | + * @param array $query_params |
|
102 | + * @param string $include |
|
103 | + * @return array |
|
104 | + * @throws EE_Error |
|
105 | + * @throws InvalidArgumentException |
|
106 | + * @throws InvalidDataTypeException |
|
107 | + * @throws InvalidInterfaceException |
|
108 | + * @throws ModelConfigurationException |
|
109 | + * @throws ReflectionException |
|
110 | + * @throws RestException |
|
111 | + * @throws RestPasswordIncorrectException |
|
112 | + * @throws RestPasswordRequiredException |
|
113 | + * @throws UnexpectedEntityException |
|
114 | + * @throws DomainException |
|
115 | + * @since $VID:$ |
|
116 | + */ |
|
117 | + public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | + { |
|
119 | + if (! array_key_exists('limit', $query_params)) { |
|
120 | + $query_params['limit'] = 1; |
|
121 | + } |
|
122 | + $result = $this->getApiResults($model, $query_params, $include); |
|
123 | + return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param EEM_Base $model |
|
128 | - * @param array $query_params |
|
129 | - * @param string $include |
|
130 | - * @return array |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - * @throws ModelConfigurationException |
|
136 | - * @throws ReflectionException |
|
137 | - * @throws RestException |
|
138 | - * @throws RestPasswordIncorrectException |
|
139 | - * @throws RestPasswordRequiredException |
|
140 | - * @throws UnexpectedEntityException |
|
141 | - * @throws DomainException |
|
142 | - * @since $VID:$ |
|
143 | - */ |
|
144 | - public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | - { |
|
146 | - if (! array_key_exists('caps', $query_params)) { |
|
147 | - $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | - } |
|
149 | - if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | - $query_params['default_where_conditions'] = 'none'; |
|
151 | - } |
|
152 | - /** @type array $results */ |
|
153 | - $results = $model->get_all_wpdb_results($query_params); |
|
154 | - $rest_request = new WP_REST_Request(); |
|
155 | - $rest_request->set_param('include', $include); |
|
156 | - $rest_request->set_param('caps', 'edit'); |
|
157 | - $nice_results = array(); |
|
158 | - foreach ($results as $result) { |
|
159 | - $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | - $model, |
|
161 | - $result, |
|
162 | - $rest_request |
|
163 | - ); |
|
164 | - } |
|
165 | - return $nice_results; |
|
166 | - } |
|
126 | + /** |
|
127 | + * @param EEM_Base $model |
|
128 | + * @param array $query_params |
|
129 | + * @param string $include |
|
130 | + * @return array |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + * @throws ModelConfigurationException |
|
136 | + * @throws ReflectionException |
|
137 | + * @throws RestException |
|
138 | + * @throws RestPasswordIncorrectException |
|
139 | + * @throws RestPasswordRequiredException |
|
140 | + * @throws UnexpectedEntityException |
|
141 | + * @throws DomainException |
|
142 | + * @since $VID:$ |
|
143 | + */ |
|
144 | + public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | + { |
|
146 | + if (! array_key_exists('caps', $query_params)) { |
|
147 | + $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | + } |
|
149 | + if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | + $query_params['default_where_conditions'] = 'none'; |
|
151 | + } |
|
152 | + /** @type array $results */ |
|
153 | + $results = $model->get_all_wpdb_results($query_params); |
|
154 | + $rest_request = new WP_REST_Request(); |
|
155 | + $rest_request->set_param('include', $include); |
|
156 | + $rest_request->set_param('caps', 'edit'); |
|
157 | + $nice_results = array(); |
|
158 | + foreach ($results as $result) { |
|
159 | + $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | + $model, |
|
161 | + $result, |
|
162 | + $rest_request |
|
163 | + ); |
|
164 | + } |
|
165 | + return $nice_results; |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * @param string $endpoint |
|
171 | - * @return array |
|
172 | - * @throws EE_Error |
|
173 | - * @since $VID:$ |
|
174 | - */ |
|
175 | - public function getModelSchema($endpoint) |
|
176 | - { |
|
177 | - $response = $this->wp_rest_server->dispatch( |
|
178 | - new WP_REST_Request( |
|
179 | - 'OPTIONS', |
|
180 | - "/ee/v4.8.36/{$endpoint}" |
|
181 | - ) |
|
182 | - ); |
|
183 | - return $response->get_data(); |
|
184 | - } |
|
169 | + /** |
|
170 | + * @param string $endpoint |
|
171 | + * @return array |
|
172 | + * @throws EE_Error |
|
173 | + * @since $VID:$ |
|
174 | + */ |
|
175 | + public function getModelSchema($endpoint) |
|
176 | + { |
|
177 | + $response = $this->wp_rest_server->dispatch( |
|
178 | + new WP_REST_Request( |
|
179 | + 'OPTIONS', |
|
180 | + "/ee/v4.8.36/{$endpoint}" |
|
181 | + ) |
|
182 | + ); |
|
183 | + return $response->get_data(); |
|
184 | + } |
|
185 | 185 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
118 | 118 | { |
119 | - if (! array_key_exists('limit', $query_params)) { |
|
119 | + if ( ! array_key_exists('limit', $query_params)) { |
|
120 | 120 | $query_params['limit'] = 1; |
121 | 121 | } |
122 | 122 | $result = $this->getApiResults($model, $query_params, $include); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
145 | 145 | { |
146 | - if (! array_key_exists('caps', $query_params)) { |
|
146 | + if ( ! array_key_exists('caps', $query_params)) { |
|
147 | 147 | $query_params['caps'] = EEM_Base::caps_read_admin; |
148 | 148 | } |
149 | - if (! array_key_exists('default_where_conditions', $query_params)) { |
|
149 | + if ( ! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | 150 | $query_params['default_where_conditions'] = 'none'; |
151 | 151 | } |
152 | 152 | /** @type array $results */ |
@@ -13,50 +13,50 @@ |
||
13 | 13 | interface ModelObjectToJsonConverterInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $entities |
|
18 | - * @return array |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function convertAndEncodeArrayOf(array $entities); |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param $entity |
|
26 | - * @return false|string |
|
27 | - * @since $VID:$ |
|
28 | - */ |
|
29 | - public function convertAndEncode($entity); |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param array $entities |
|
34 | - * @return array |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function convertArrayOf(array $entities); |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param $entity |
|
42 | - * @return array |
|
43 | - * @since $VID:$ |
|
44 | - */ |
|
45 | - public function convert($entity); |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @param array $entities |
|
50 | - * @return array |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function encodeArrayOf(array $entities); |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param array $entity_array |
|
58 | - * @return false|string |
|
59 | - * @since $VID:$ |
|
60 | - */ |
|
61 | - public function encode(array $entity_array); |
|
16 | + /** |
|
17 | + * @param array $entities |
|
18 | + * @return array |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function convertAndEncodeArrayOf(array $entities); |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param $entity |
|
26 | + * @return false|string |
|
27 | + * @since $VID:$ |
|
28 | + */ |
|
29 | + public function convertAndEncode($entity); |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param array $entities |
|
34 | + * @return array |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function convertArrayOf(array $entities); |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param $entity |
|
42 | + * @return array |
|
43 | + * @since $VID:$ |
|
44 | + */ |
|
45 | + public function convert($entity); |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @param array $entities |
|
50 | + * @return array |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function encodeArrayOf(array $entities); |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param array $entity_array |
|
58 | + * @return false|string |
|
59 | + * @since $VID:$ |
|
60 | + */ |
|
61 | + public function encode(array $entity_array); |
|
62 | 62 | } |
@@ -16,13 +16,13 @@ |
||
16 | 16 | interface ResolverInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param $source |
|
21 | - * @param array $args |
|
22 | - * @param AppContext $context |
|
23 | - * @param ResolveInfo $info |
|
24 | - * @return mixed |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
19 | + /** |
|
20 | + * @param $source |
|
21 | + * @param array $args |
|
22 | + * @param AppContext $context |
|
23 | + * @param ResolveInfo $info |
|
24 | + * @return mixed |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
28 | 28 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $config = $field->toArray(); |
76 | 76 | if ($field->useForInput()) { |
77 | 77 | // Register input fields for existing mutations. |
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
78 | + register_graphql_field('Update'.$typeName.'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create'.$typeName.'Input', $fieldName, $config); |
|
80 | 80 | } |
81 | 81 | if ($field->useForOutput()) { |
82 | 82 | $config['resolve'] = [$type, 'resolveField']; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | $fieldName = $field->name(); |
103 | 103 | $config = $field->toArray(); |
104 | 104 | if ($field->useForInput()) { |
105 | - $inputFields[ $fieldName ] = $config; |
|
105 | + $inputFields[$fieldName] = $config; |
|
106 | 106 | } |
107 | 107 | if ($field->useForOutput()) { |
108 | 108 | $config['resolve'] = [$type, 'resolveField']; |
109 | - $outputFields[ $fieldName ] = $config; |
|
109 | + $outputFields[$fieldName] = $config; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $typeName = $type->name(); |
113 | - if (! empty($outputFields)) { |
|
113 | + if ( ! empty($outputFields)) { |
|
114 | 114 | // Register the object type. |
115 | 115 | register_graphql_object_type( |
116 | 116 | $typeName, |
@@ -18,110 +18,110 @@ |
||
18 | 18 | class TypesManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var TypeCollection|TypeInterface[] $types |
|
23 | - */ |
|
24 | - private $types; |
|
21 | + /** |
|
22 | + * @var TypeCollection|TypeInterface[] $types |
|
23 | + */ |
|
24 | + private $types; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * TypesManager constructor. |
|
29 | - * |
|
30 | - * @param TypeCollection|TypeInterface[] $types |
|
31 | - */ |
|
32 | - public function __construct(TypeCollection $types) |
|
33 | - { |
|
34 | - $this->types = $types; |
|
35 | - } |
|
27 | + /** |
|
28 | + * TypesManager constructor. |
|
29 | + * |
|
30 | + * @param TypeCollection|TypeInterface[] $types |
|
31 | + */ |
|
32 | + public function __construct(TypeCollection $types) |
|
33 | + { |
|
34 | + $this->types = $types; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->types->loadTypes(); |
|
46 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->types->loadTypes(); |
|
46 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function configureTypes() |
|
54 | - { |
|
55 | - // loop through the collection of types and register their fields |
|
56 | - foreach ($this->types as $type) { |
|
57 | - if ($type->isCustomPostType()) { |
|
58 | - $this->extendCustomPostType($type); |
|
59 | - } else { |
|
60 | - $this->registerType($type); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function configureTypes() |
|
54 | + { |
|
55 | + // loop through the collection of types and register their fields |
|
56 | + foreach ($this->types as $type) { |
|
57 | + if ($type->isCustomPostType()) { |
|
58 | + $this->extendCustomPostType($type); |
|
59 | + } else { |
|
60 | + $this->registerType($type); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param TypeInterface $type |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - public function extendCustomPostType(TypeInterface $type) |
|
71 | - { |
|
72 | - $typeName = $type->name(); |
|
73 | - foreach ($type->fields() as $field) { |
|
74 | - $fieldName = $field->name(); |
|
75 | - $config = $field->toArray(); |
|
76 | - if ($field->useForInput()) { |
|
77 | - // Register input fields for existing mutations. |
|
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | - } |
|
81 | - if ($field->useForOutput()) { |
|
82 | - $config['resolve'] = [$type, 'resolveField']; |
|
83 | - // Register fields for queries. |
|
84 | - register_graphql_field($typeName, $fieldName, $config); |
|
85 | - } |
|
86 | - } |
|
87 | - if (is_callable([$type, 'extendMutations'])) { |
|
88 | - $type->extendMutations(); |
|
89 | - } |
|
90 | - } |
|
66 | + /** |
|
67 | + * @param TypeInterface $type |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + public function extendCustomPostType(TypeInterface $type) |
|
71 | + { |
|
72 | + $typeName = $type->name(); |
|
73 | + foreach ($type->fields() as $field) { |
|
74 | + $fieldName = $field->name(); |
|
75 | + $config = $field->toArray(); |
|
76 | + if ($field->useForInput()) { |
|
77 | + // Register input fields for existing mutations. |
|
78 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | + } |
|
81 | + if ($field->useForOutput()) { |
|
82 | + $config['resolve'] = [$type, 'resolveField']; |
|
83 | + // Register fields for queries. |
|
84 | + register_graphql_field($typeName, $fieldName, $config); |
|
85 | + } |
|
86 | + } |
|
87 | + if (is_callable([$type, 'extendMutations'])) { |
|
88 | + $type->extendMutations(); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @param TypeInterface $type |
|
95 | - * @since $VID:$ |
|
96 | - */ |
|
97 | - public function registerType(TypeInterface $type) |
|
98 | - { |
|
99 | - $outputFields = []; |
|
100 | - $inputFields = []; |
|
101 | - foreach ($type->fields() as $field) { |
|
102 | - $fieldName = $field->name(); |
|
103 | - $config = $field->toArray(); |
|
104 | - if ($field->useForInput()) { |
|
105 | - $inputFields[ $fieldName ] = $config; |
|
106 | - } |
|
107 | - if ($field->useForOutput()) { |
|
108 | - $config['resolve'] = [$type, 'resolveField']; |
|
109 | - $outputFields[ $fieldName ] = $config; |
|
110 | - } |
|
111 | - } |
|
112 | - $typeName = $type->name(); |
|
113 | - if (! empty($outputFields)) { |
|
114 | - // Register the object type. |
|
115 | - register_graphql_object_type( |
|
116 | - $typeName, |
|
117 | - [ |
|
118 | - 'description' => $type->description(), |
|
119 | - 'fields' => $outputFields, |
|
120 | - ] |
|
121 | - ); |
|
122 | - } |
|
123 | - if (is_callable([$type, 'registerMutations'])) { |
|
124 | - $type->registerMutations($inputFields); |
|
125 | - } |
|
126 | - } |
|
93 | + /** |
|
94 | + * @param TypeInterface $type |
|
95 | + * @since $VID:$ |
|
96 | + */ |
|
97 | + public function registerType(TypeInterface $type) |
|
98 | + { |
|
99 | + $outputFields = []; |
|
100 | + $inputFields = []; |
|
101 | + foreach ($type->fields() as $field) { |
|
102 | + $fieldName = $field->name(); |
|
103 | + $config = $field->toArray(); |
|
104 | + if ($field->useForInput()) { |
|
105 | + $inputFields[ $fieldName ] = $config; |
|
106 | + } |
|
107 | + if ($field->useForOutput()) { |
|
108 | + $config['resolve'] = [$type, 'resolveField']; |
|
109 | + $outputFields[ $fieldName ] = $config; |
|
110 | + } |
|
111 | + } |
|
112 | + $typeName = $type->name(); |
|
113 | + if (! empty($outputFields)) { |
|
114 | + // Register the object type. |
|
115 | + register_graphql_object_type( |
|
116 | + $typeName, |
|
117 | + [ |
|
118 | + 'description' => $type->description(), |
|
119 | + 'fields' => $outputFields, |
|
120 | + ] |
|
121 | + ); |
|
122 | + } |
|
123 | + if (is_callable([$type, 'registerMutations'])) { |
|
124 | + $type->registerMutations($inputFields); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | $fields = []; |
156 | 156 | foreach ($this->fields() as $field) { |
157 | 157 | if ($field->useForOutput()) { |
158 | - $fields[ $field->name() ] = $field; |
|
158 | + $fields[$field->name()] = $field; |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | return $fields; |
@@ -35,270 +35,270 @@ |
||
35 | 35 | abstract class TypeBase implements TypeInterface |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * @var string $namespace The graphql namespace/prefix. |
|
40 | - */ |
|
41 | - protected $namespace = 'Espresso'; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EEM_Base $model |
|
45 | - */ |
|
46 | - protected $model; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var string $name |
|
50 | - */ |
|
51 | - protected $name = ''; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var string $description |
|
55 | - */ |
|
56 | - protected $description = ''; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var GraphQLFieldInterface[] $fields |
|
60 | - */ |
|
61 | - protected $fields = []; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var array $graphql_to_model_map |
|
65 | - */ |
|
66 | - protected $graphql_to_model_map = []; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var FieldResolver $field_resolver |
|
70 | - */ |
|
71 | - protected $field_resolver; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var bool $is_custom_post_type |
|
75 | - */ |
|
76 | - protected $is_custom_post_type = false; |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * TypeBase constructor. |
|
81 | - * |
|
82 | - * @param EEM_Base|null $model |
|
83 | - */ |
|
84 | - public function __construct(EEM_Base $model = null) |
|
85 | - { |
|
86 | - $this->model = $model; |
|
87 | - $this->setFields($this->getFields()); |
|
88 | - $this->field_resolver = new FieldResolver( |
|
89 | - $this->model, |
|
90 | - $this->getFieldsForResolver() |
|
91 | - ); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return GraphQLFieldInterface[] |
|
97 | - * @since $VID:$ |
|
98 | - */ |
|
99 | - abstract protected function getFields(): array; |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function name(): string |
|
106 | - { |
|
107 | - return $this->name; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $name |
|
113 | - */ |
|
114 | - protected function setName(string $name) |
|
115 | - { |
|
116 | - $this->name = $name; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function description(): string |
|
124 | - { |
|
125 | - return $this->description; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @param string $description |
|
131 | - */ |
|
132 | - protected function setDescription(string $description) |
|
133 | - { |
|
134 | - $this->description = $description; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @return GraphQLFieldInterface[] |
|
140 | - * @since $VID:$ |
|
141 | - */ |
|
142 | - public function fields(): array |
|
143 | - { |
|
144 | - return (array) $this->fields; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param GraphQLFieldInterface[] $fields |
|
150 | - */ |
|
151 | - protected function setFields(array $fields) |
|
152 | - { |
|
153 | - foreach ($fields as $field) { |
|
154 | - if ($field instanceof GraphQLField) { |
|
155 | - $this->fields[] = $field; |
|
156 | - } |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Creates a key map for internal resolver. |
|
163 | - * |
|
164 | - * @return array |
|
165 | - * @since $VID:$ |
|
166 | - */ |
|
167 | - public function getFieldsForResolver(): array |
|
168 | - { |
|
169 | - $fields = []; |
|
170 | - foreach ($this->fields() as $field) { |
|
171 | - if ($field->useForOutput()) { |
|
172 | - $fields[ $field->name() ] = $field; |
|
173 | - } |
|
174 | - } |
|
175 | - return $fields; |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * @return bool |
|
181 | - */ |
|
182 | - public function isCustomPostType(): bool |
|
183 | - { |
|
184 | - return $this->is_custom_post_type; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * @param bool $is_custom_post_type |
|
190 | - */ |
|
191 | - protected function setIsCustomPostType(bool $is_custom_post_type) |
|
192 | - { |
|
193 | - $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @param int|float $value |
|
199 | - * @return int |
|
200 | - * @since $VID:$ |
|
201 | - */ |
|
202 | - public function parseInfiniteValue($value): int |
|
203 | - { |
|
204 | - $value = trim($value); |
|
205 | - return $value === null |
|
206 | - || $value === '' |
|
207 | - || $value === '∞' |
|
208 | - || $value === 'INF' |
|
209 | - || $value === INF |
|
210 | - || $value === EE_INF |
|
211 | - || is_infinite((float) $value) |
|
212 | - ? -1 |
|
213 | - : $value; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * @param mixed $source |
|
219 | - * @return EE_Base_Class|null |
|
220 | - * @throws EE_Error |
|
221 | - */ |
|
222 | - private function getModel($source): ?EE_Base_Class |
|
223 | - { |
|
224 | - // If it comes from a custom connection |
|
225 | - // where the $source is already instantiated. |
|
226 | - if ($source instanceof EE_Base_Class) { |
|
227 | - return $source; |
|
228 | - } |
|
229 | - return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
235 | - * @param array $args The inputArgs on the field |
|
236 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
237 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
238 | - * @return EE_Base_Class|Deferred|string|null |
|
239 | - * @throws EE_Error |
|
240 | - * @throws InvalidDataTypeException |
|
241 | - * @throws InvalidInterfaceException |
|
242 | - * @throws UnexpectedEntityException |
|
243 | - * @throws UserError |
|
244 | - * @throws InvalidArgumentException |
|
245 | - * @throws ReflectionException |
|
246 | - * @since $VID:$ |
|
247 | - */ |
|
248 | - public function resolveField($source, array $args, AppContext $context, ResolveInfo $info) |
|
249 | - { |
|
250 | - $source = $source instanceof RootQuery ? $source : $this->getModel($source); |
|
251 | - |
|
252 | - return $this->field_resolver->resolve($source, $args, $context, $info); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * @param mixed $payload The payload returned after mutation |
|
258 | - * @param array $args The inputArgs on the field |
|
259 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
260 | - * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null |
|
261 | - * @throws EE_Error |
|
262 | - */ |
|
263 | - public function resolveFromPayload($payload, array $args, AppContext $context) |
|
264 | - { |
|
265 | - if (empty($payload['id'])) { |
|
266 | - return null; |
|
267 | - } |
|
268 | - return $this->model->get_one_by_ID($payload['id']); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * Prepares a datetime value in ISO8601/RFC3339 format. |
|
274 | - * It is assumed that the value of $datetime is in the format |
|
275 | - * returned by EE_Base_Class::get_format(). |
|
276 | - * |
|
277 | - * @param string $datetime The datetime value. |
|
278 | - * @param EE_Base_Class $source The source object. |
|
279 | - * @return string ISO8601/RFC3339 formatted datetime. |
|
280 | - */ |
|
281 | - public function formatDatetime(string $datetime, EE_Base_Class $source): string |
|
282 | - { |
|
283 | - $format = $source->get_format(); |
|
284 | - // create date object based on local timezone |
|
285 | - $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone())); |
|
286 | - // change the timezone to UTC |
|
287 | - $datetime->setTimezone(new DateTimeZone('UTC')); |
|
288 | - |
|
289 | - return $datetime->format(DateTime::RFC3339); |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Converts an object to JSON. The object must have a "toJson" method. |
|
295 | - * |
|
296 | - * @param string $object The object/value. |
|
297 | - * @param EE_Base_Class $source The source object. |
|
298 | - * @return string JSON representation of the object. |
|
299 | - */ |
|
300 | - public function toJson(JsonableInterface $object, EE_Base_Class $source): string |
|
301 | - { |
|
302 | - return $object->toJson(); |
|
303 | - } |
|
38 | + /** |
|
39 | + * @var string $namespace The graphql namespace/prefix. |
|
40 | + */ |
|
41 | + protected $namespace = 'Espresso'; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EEM_Base $model |
|
45 | + */ |
|
46 | + protected $model; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var string $name |
|
50 | + */ |
|
51 | + protected $name = ''; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var string $description |
|
55 | + */ |
|
56 | + protected $description = ''; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var GraphQLFieldInterface[] $fields |
|
60 | + */ |
|
61 | + protected $fields = []; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var array $graphql_to_model_map |
|
65 | + */ |
|
66 | + protected $graphql_to_model_map = []; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var FieldResolver $field_resolver |
|
70 | + */ |
|
71 | + protected $field_resolver; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var bool $is_custom_post_type |
|
75 | + */ |
|
76 | + protected $is_custom_post_type = false; |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * TypeBase constructor. |
|
81 | + * |
|
82 | + * @param EEM_Base|null $model |
|
83 | + */ |
|
84 | + public function __construct(EEM_Base $model = null) |
|
85 | + { |
|
86 | + $this->model = $model; |
|
87 | + $this->setFields($this->getFields()); |
|
88 | + $this->field_resolver = new FieldResolver( |
|
89 | + $this->model, |
|
90 | + $this->getFieldsForResolver() |
|
91 | + ); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return GraphQLFieldInterface[] |
|
97 | + * @since $VID:$ |
|
98 | + */ |
|
99 | + abstract protected function getFields(): array; |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function name(): string |
|
106 | + { |
|
107 | + return $this->name; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $name |
|
113 | + */ |
|
114 | + protected function setName(string $name) |
|
115 | + { |
|
116 | + $this->name = $name; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function description(): string |
|
124 | + { |
|
125 | + return $this->description; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @param string $description |
|
131 | + */ |
|
132 | + protected function setDescription(string $description) |
|
133 | + { |
|
134 | + $this->description = $description; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @return GraphQLFieldInterface[] |
|
140 | + * @since $VID:$ |
|
141 | + */ |
|
142 | + public function fields(): array |
|
143 | + { |
|
144 | + return (array) $this->fields; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param GraphQLFieldInterface[] $fields |
|
150 | + */ |
|
151 | + protected function setFields(array $fields) |
|
152 | + { |
|
153 | + foreach ($fields as $field) { |
|
154 | + if ($field instanceof GraphQLField) { |
|
155 | + $this->fields[] = $field; |
|
156 | + } |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Creates a key map for internal resolver. |
|
163 | + * |
|
164 | + * @return array |
|
165 | + * @since $VID:$ |
|
166 | + */ |
|
167 | + public function getFieldsForResolver(): array |
|
168 | + { |
|
169 | + $fields = []; |
|
170 | + foreach ($this->fields() as $field) { |
|
171 | + if ($field->useForOutput()) { |
|
172 | + $fields[ $field->name() ] = $field; |
|
173 | + } |
|
174 | + } |
|
175 | + return $fields; |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * @return bool |
|
181 | + */ |
|
182 | + public function isCustomPostType(): bool |
|
183 | + { |
|
184 | + return $this->is_custom_post_type; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * @param bool $is_custom_post_type |
|
190 | + */ |
|
191 | + protected function setIsCustomPostType(bool $is_custom_post_type) |
|
192 | + { |
|
193 | + $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @param int|float $value |
|
199 | + * @return int |
|
200 | + * @since $VID:$ |
|
201 | + */ |
|
202 | + public function parseInfiniteValue($value): int |
|
203 | + { |
|
204 | + $value = trim($value); |
|
205 | + return $value === null |
|
206 | + || $value === '' |
|
207 | + || $value === '∞' |
|
208 | + || $value === 'INF' |
|
209 | + || $value === INF |
|
210 | + || $value === EE_INF |
|
211 | + || is_infinite((float) $value) |
|
212 | + ? -1 |
|
213 | + : $value; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * @param mixed $source |
|
219 | + * @return EE_Base_Class|null |
|
220 | + * @throws EE_Error |
|
221 | + */ |
|
222 | + private function getModel($source): ?EE_Base_Class |
|
223 | + { |
|
224 | + // If it comes from a custom connection |
|
225 | + // where the $source is already instantiated. |
|
226 | + if ($source instanceof EE_Base_Class) { |
|
227 | + return $source; |
|
228 | + } |
|
229 | + return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
235 | + * @param array $args The inputArgs on the field |
|
236 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
237 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
238 | + * @return EE_Base_Class|Deferred|string|null |
|
239 | + * @throws EE_Error |
|
240 | + * @throws InvalidDataTypeException |
|
241 | + * @throws InvalidInterfaceException |
|
242 | + * @throws UnexpectedEntityException |
|
243 | + * @throws UserError |
|
244 | + * @throws InvalidArgumentException |
|
245 | + * @throws ReflectionException |
|
246 | + * @since $VID:$ |
|
247 | + */ |
|
248 | + public function resolveField($source, array $args, AppContext $context, ResolveInfo $info) |
|
249 | + { |
|
250 | + $source = $source instanceof RootQuery ? $source : $this->getModel($source); |
|
251 | + |
|
252 | + return $this->field_resolver->resolve($source, $args, $context, $info); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * @param mixed $payload The payload returned after mutation |
|
258 | + * @param array $args The inputArgs on the field |
|
259 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
260 | + * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null |
|
261 | + * @throws EE_Error |
|
262 | + */ |
|
263 | + public function resolveFromPayload($payload, array $args, AppContext $context) |
|
264 | + { |
|
265 | + if (empty($payload['id'])) { |
|
266 | + return null; |
|
267 | + } |
|
268 | + return $this->model->get_one_by_ID($payload['id']); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * Prepares a datetime value in ISO8601/RFC3339 format. |
|
274 | + * It is assumed that the value of $datetime is in the format |
|
275 | + * returned by EE_Base_Class::get_format(). |
|
276 | + * |
|
277 | + * @param string $datetime The datetime value. |
|
278 | + * @param EE_Base_Class $source The source object. |
|
279 | + * @return string ISO8601/RFC3339 formatted datetime. |
|
280 | + */ |
|
281 | + public function formatDatetime(string $datetime, EE_Base_Class $source): string |
|
282 | + { |
|
283 | + $format = $source->get_format(); |
|
284 | + // create date object based on local timezone |
|
285 | + $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone())); |
|
286 | + // change the timezone to UTC |
|
287 | + $datetime->setTimezone(new DateTimeZone('UTC')); |
|
288 | + |
|
289 | + return $datetime->format(DateTime::RFC3339); |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Converts an object to JSON. The object must have a "toJson" method. |
|
295 | + * |
|
296 | + * @param string $object The object/value. |
|
297 | + * @param EE_Base_Class $source The source object. |
|
298 | + * @return string JSON representation of the object. |
|
299 | + */ |
|
300 | + public function toJson(JsonableInterface $object, EE_Base_Class $source): string |
|
301 | + { |
|
302 | + return $object->toJson(); |
|
303 | + } |
|
304 | 304 | } |
@@ -11,30 +11,30 @@ |
||
11 | 11 | class GraphQLInputField extends GraphQLField |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $name |
|
16 | - * @param string|string[] $type |
|
17 | - * @param string|null $key |
|
18 | - * @param string $description |
|
19 | - * @param array $caps |
|
20 | - */ |
|
21 | - public function __construct( |
|
22 | - $name, |
|
23 | - $type, |
|
24 | - $key = null, |
|
25 | - $description = '', |
|
26 | - array $caps = [] |
|
27 | - ) { |
|
28 | - parent::__construct( |
|
29 | - $name, |
|
30 | - $type, |
|
31 | - $key, |
|
32 | - $description, |
|
33 | - null, |
|
34 | - null, |
|
35 | - $caps |
|
36 | - ); |
|
14 | + /** |
|
15 | + * @param string $name |
|
16 | + * @param string|string[] $type |
|
17 | + * @param string|null $key |
|
18 | + * @param string $description |
|
19 | + * @param array $caps |
|
20 | + */ |
|
21 | + public function __construct( |
|
22 | + $name, |
|
23 | + $type, |
|
24 | + $key = null, |
|
25 | + $description = '', |
|
26 | + array $caps = [] |
|
27 | + ) { |
|
28 | + parent::__construct( |
|
29 | + $name, |
|
30 | + $type, |
|
31 | + $key, |
|
32 | + $description, |
|
33 | + null, |
|
34 | + null, |
|
35 | + $caps |
|
36 | + ); |
|
37 | 37 | |
38 | - $this->setUseForOutput(false); |
|
39 | - } |
|
38 | + $this->setUseForOutput(false); |
|
39 | + } |
|
40 | 40 | } |