@@ -44,7 +44,7 @@ |
||
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | // if the incoming country has a set format, use that, else use the default |
47 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
47 | + $formatted_address = $address_formats[$CNT_ISO] ?? $address_formats['ZZZ']; |
|
48 | 48 | return $this->parse_formatted_address( |
49 | 49 | $address, |
50 | 50 | $address2, |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class InlineAddressFormatter extends AddressFormatter implements AddressFormatterInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $CNT_ISO |
|
24 | - * @return string|null |
|
25 | - */ |
|
26 | - public function format( |
|
27 | - string $address, |
|
28 | - string $address2, |
|
29 | - string $city, |
|
30 | - string $state, |
|
31 | - string $zip, |
|
32 | - string $country, |
|
33 | - string $CNT_ISO |
|
34 | - ): ?string { |
|
35 | - $address_formats = apply_filters( |
|
36 | - 'FHEE__EE_Inline_Address_Formatter__address_formats', |
|
37 | - array( |
|
38 | - 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | - 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | - 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | - 'ZZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | - ) |
|
43 | - ); |
|
44 | - // if the incoming country has a set format, use that, else use the default |
|
45 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
46 | - return $this->parse_formatted_address( |
|
47 | - $address, |
|
48 | - $address2, |
|
49 | - $city, |
|
50 | - $state, |
|
51 | - $zip, |
|
52 | - $country, |
|
53 | - $formatted_address, |
|
54 | - ', ' |
|
55 | - ); |
|
56 | - } |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $CNT_ISO |
|
24 | + * @return string|null |
|
25 | + */ |
|
26 | + public function format( |
|
27 | + string $address, |
|
28 | + string $address2, |
|
29 | + string $city, |
|
30 | + string $state, |
|
31 | + string $zip, |
|
32 | + string $country, |
|
33 | + string $CNT_ISO |
|
34 | + ): ?string { |
|
35 | + $address_formats = apply_filters( |
|
36 | + 'FHEE__EE_Inline_Address_Formatter__address_formats', |
|
37 | + array( |
|
38 | + 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | + 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | + 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | + 'ZZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | + ) |
|
43 | + ); |
|
44 | + // if the incoming country has a set format, use that, else use the default |
|
45 | + $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZZ']; |
|
46 | + return $this->parse_formatted_address( |
|
47 | + $address, |
|
48 | + $address2, |
|
49 | + $city, |
|
50 | + $state, |
|
51 | + $zip, |
|
52 | + $country, |
|
53 | + $formatted_address, |
|
54 | + ', ' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | // if the incoming country has a set format, use that, else use the default |
47 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
47 | + $formatted_address = $address_formats[$CNT_ISO] ?? $address_formats['ZZ']; |
|
48 | 48 | return $this->parse_formatted_address( |
49 | 49 | $address, |
50 | 50 | $address2, |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class MultiLineAddressFormatter extends AddressFormatter implements AddressFormatterInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $CNT_ISO |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function format( |
|
27 | - string $address, |
|
28 | - string $address2, |
|
29 | - string $city, |
|
30 | - string $state, |
|
31 | - string $zip, |
|
32 | - string $country, |
|
33 | - string $CNT_ISO |
|
34 | - ): ?string { |
|
35 | - $address_formats = apply_filters( |
|
36 | - 'FHEE__EE_MultiLine_Address_Formatter__address_formats', |
|
37 | - array( |
|
38 | - 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | - 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | - 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | - 'ZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | - ) |
|
43 | - ); |
|
44 | - // if the incoming country has a set format, use that, else use the default |
|
45 | - $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
46 | - return $this->parse_formatted_address( |
|
47 | - $address, |
|
48 | - $address2, |
|
49 | - $city, |
|
50 | - $state, |
|
51 | - $zip, |
|
52 | - $country, |
|
53 | - $formatted_address, |
|
54 | - '<br />' |
|
55 | - ); |
|
56 | - } |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $CNT_ISO |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function format( |
|
27 | + string $address, |
|
28 | + string $address2, |
|
29 | + string $city, |
|
30 | + string $state, |
|
31 | + string $zip, |
|
32 | + string $country, |
|
33 | + string $CNT_ISO |
|
34 | + ): ?string { |
|
35 | + $address_formats = apply_filters( |
|
36 | + 'FHEE__EE_MultiLine_Address_Formatter__address_formats', |
|
37 | + array( |
|
38 | + 'CA' => "{address}%{address2}%{city}%{state}%{country}%{zip}", |
|
39 | + 'GB' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
40 | + 'US' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
41 | + 'ZZ' => "{address}%{address2}%{city}%{state}%{zip}%{country}", |
|
42 | + ) |
|
43 | + ); |
|
44 | + // if the incoming country has a set format, use that, else use the default |
|
45 | + $formatted_address = $address_formats[ $CNT_ISO ] ?? $address_formats['ZZ']; |
|
46 | + return $this->parse_formatted_address( |
|
47 | + $address, |
|
48 | + $address2, |
|
49 | + $city, |
|
50 | + $state, |
|
51 | + $zip, |
|
52 | + $country, |
|
53 | + $formatted_address, |
|
54 | + '<br />' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | } |
@@ -12,38 +12,38 @@ |
||
12 | 12 | */ |
13 | 13 | class AddressFormatter |
14 | 14 | { |
15 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $formatted_address |
|
24 | - * @param string $sub |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - protected function parse_formatted_address( |
|
28 | - string $address, |
|
29 | - string $address2, |
|
30 | - string $city, |
|
31 | - string $state, |
|
32 | - string $zip, |
|
33 | - string $country, |
|
34 | - string $formatted_address, |
|
35 | - string $sub |
|
36 | - ): string { |
|
37 | - // swap address part placeholders for the real text |
|
38 | - $formatted_address = str_replace( |
|
39 | - // find |
|
40 | - array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | - // replace |
|
42 | - array($address, $address2, $city, $state, $zip, $country), |
|
43 | - // string |
|
44 | - $formatted_address |
|
45 | - ); |
|
46 | - // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | - return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | - } |
|
15 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $formatted_address |
|
24 | + * @param string $sub |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + protected function parse_formatted_address( |
|
28 | + string $address, |
|
29 | + string $address2, |
|
30 | + string $city, |
|
31 | + string $state, |
|
32 | + string $zip, |
|
33 | + string $country, |
|
34 | + string $formatted_address, |
|
35 | + string $sub |
|
36 | + ): string { |
|
37 | + // swap address part placeholders for the real text |
|
38 | + $formatted_address = str_replace( |
|
39 | + // find |
|
40 | + array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | + // replace |
|
42 | + array($address, $address2, $city, $state, $zip, $country), |
|
43 | + // string |
|
44 | + $formatted_address |
|
45 | + ); |
|
46 | + // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | + return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | + } |
|
49 | 49 | } |
@@ -19,261 +19,261 @@ |
||
19 | 19 | */ |
20 | 20 | class GraphQLField implements GraphQLFieldInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string $name |
|
24 | - */ |
|
25 | - protected $name; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string|string[] $type |
|
29 | - */ |
|
30 | - protected $type; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string|null $key |
|
34 | - */ |
|
35 | - protected $key; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $description |
|
39 | - */ |
|
40 | - protected $description; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var callable $formatter |
|
44 | - */ |
|
45 | - protected $formatter; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var callable $resolve |
|
49 | - */ |
|
50 | - protected $resolver; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var array $caps |
|
54 | - */ |
|
55 | - protected $caps; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var array $args |
|
59 | - */ |
|
60 | - protected $args; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var bool $use_for_input |
|
64 | - */ |
|
65 | - protected $use_for_input = true; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var bool $use_for_output |
|
69 | - */ |
|
70 | - protected $use_for_output = true; |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param string $name |
|
75 | - * @param string|string[] $type |
|
76 | - * @param string|null $key |
|
77 | - * @param string $description |
|
78 | - * @param callable|null $formatter |
|
79 | - * @param callable|null $resolver |
|
80 | - * @param array $caps |
|
81 | - * @param array $args |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - string $name, |
|
85 | - $type, |
|
86 | - string $key = null, |
|
87 | - string $description = '', |
|
88 | - callable $formatter = null, |
|
89 | - callable $resolver = null, |
|
90 | - array $caps = [], |
|
91 | - array $args = [] |
|
92 | - ) { |
|
93 | - $this->name = $name; |
|
94 | - $this->type = $type; |
|
95 | - $this->key = $key; |
|
96 | - $this->description = $description; |
|
97 | - $this->formatter = $formatter; |
|
98 | - $this->resolver = $resolver; |
|
99 | - $this->caps = $caps; |
|
100 | - $this->args = $args; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - public function caps(): array |
|
108 | - { |
|
109 | - return $this->caps; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function description(): string |
|
117 | - { |
|
118 | - return $this->description; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return string |
|
124 | - */ |
|
125 | - public function key(): ?string |
|
126 | - { |
|
127 | - return $this->key; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function name(): string |
|
135 | - { |
|
136 | - return $this->name; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return string|string[] |
|
142 | - */ |
|
143 | - public function type() |
|
144 | - { |
|
145 | - return $this->type; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Convert the field to array to be |
|
151 | - * able to pass as config to WP GraphQL |
|
152 | - * |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - public function toArray(): array |
|
156 | - { |
|
157 | - return get_object_vars($this); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Sets the value for use_for_input. |
|
163 | - * |
|
164 | - * @param bool $use_for_input |
|
165 | - */ |
|
166 | - protected function setUseForInput(bool $use_for_input) |
|
167 | - { |
|
168 | - $this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Whether the field should be used for |
|
174 | - * mutation inputs. |
|
175 | - * |
|
176 | - * @return bool |
|
177 | - */ |
|
178 | - public function useForInput(): bool |
|
179 | - { |
|
180 | - return $this->use_for_input; |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * Whether the field should be used for |
|
186 | - * query outputs. |
|
187 | - * |
|
188 | - * @return bool |
|
189 | - */ |
|
190 | - public function useForOutput(): bool |
|
191 | - { |
|
192 | - return $this->use_for_output; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * Sets the value for use_for_output |
|
198 | - * |
|
199 | - * @param bool $use_for_output |
|
200 | - */ |
|
201 | - protected function setUseForOutput(bool $use_for_output) |
|
202 | - { |
|
203 | - $this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * Whether the field should resolve |
|
209 | - * based on the user caps etc. |
|
210 | - * |
|
211 | - * @return boolean |
|
212 | - */ |
|
213 | - public function shouldResolve(): bool |
|
214 | - { |
|
215 | - foreach ($this->caps as $cap) { |
|
216 | - if (! current_user_can($cap)) { |
|
217 | - return false; |
|
218 | - } |
|
219 | - } |
|
220 | - return true; |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * Whether the field has an explicit resolver set. |
|
226 | - * |
|
227 | - * @return boolean |
|
228 | - */ |
|
229 | - public function hasInternalResolver(): bool |
|
230 | - { |
|
231 | - return is_callable($this->resolver); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Whether the field has an explicit resolver set. |
|
237 | - * |
|
238 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
239 | - * @param array $args The inputArgs on the field |
|
240 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
241 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
242 | - * @return mixed |
|
243 | - * @throws LogicException |
|
244 | - */ |
|
245 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
246 | - { |
|
247 | - if (! $this->hasInternalResolver()) { |
|
248 | - throw new LogicException('GraphQLField has no internal resolver.'); |
|
249 | - } |
|
250 | - // dynamic methods using $this don't play nice |
|
251 | - // so capture resolver to a single var first |
|
252 | - $resolver = $this->resolver; |
|
253 | - return $resolver($source, $args, $context, $info); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * Checks if the format callback is set. |
|
259 | - * If yes, then uses it to format the value. |
|
260 | - * |
|
261 | - * @param mixed $value |
|
262 | - * @param EE_Base_Class $source |
|
263 | - * @return mixed The formatted value. |
|
264 | - * @throws InvalidDataTypeException |
|
265 | - * @throws InvalidInterfaceException |
|
266 | - * @throws InvalidArgumentException |
|
267 | - * @throws ReflectionException |
|
268 | - */ |
|
269 | - public function mayBeFormatValue($value, EE_Base_Class $source) |
|
270 | - { |
|
271 | - if (is_callable($this->formatter)) { |
|
272 | - // dynamic methods using $this don't play nice |
|
273 | - // so capture formatter to a single var first |
|
274 | - $formatter = $this->formatter; |
|
275 | - return $formatter($value, $source); |
|
276 | - } |
|
277 | - return $value; |
|
278 | - } |
|
22 | + /** |
|
23 | + * @var string $name |
|
24 | + */ |
|
25 | + protected $name; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string|string[] $type |
|
29 | + */ |
|
30 | + protected $type; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string|null $key |
|
34 | + */ |
|
35 | + protected $key; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $description |
|
39 | + */ |
|
40 | + protected $description; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var callable $formatter |
|
44 | + */ |
|
45 | + protected $formatter; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var callable $resolve |
|
49 | + */ |
|
50 | + protected $resolver; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var array $caps |
|
54 | + */ |
|
55 | + protected $caps; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var array $args |
|
59 | + */ |
|
60 | + protected $args; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var bool $use_for_input |
|
64 | + */ |
|
65 | + protected $use_for_input = true; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var bool $use_for_output |
|
69 | + */ |
|
70 | + protected $use_for_output = true; |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param string $name |
|
75 | + * @param string|string[] $type |
|
76 | + * @param string|null $key |
|
77 | + * @param string $description |
|
78 | + * @param callable|null $formatter |
|
79 | + * @param callable|null $resolver |
|
80 | + * @param array $caps |
|
81 | + * @param array $args |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + string $name, |
|
85 | + $type, |
|
86 | + string $key = null, |
|
87 | + string $description = '', |
|
88 | + callable $formatter = null, |
|
89 | + callable $resolver = null, |
|
90 | + array $caps = [], |
|
91 | + array $args = [] |
|
92 | + ) { |
|
93 | + $this->name = $name; |
|
94 | + $this->type = $type; |
|
95 | + $this->key = $key; |
|
96 | + $this->description = $description; |
|
97 | + $this->formatter = $formatter; |
|
98 | + $this->resolver = $resolver; |
|
99 | + $this->caps = $caps; |
|
100 | + $this->args = $args; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + public function caps(): array |
|
108 | + { |
|
109 | + return $this->caps; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function description(): string |
|
117 | + { |
|
118 | + return $this->description; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return string |
|
124 | + */ |
|
125 | + public function key(): ?string |
|
126 | + { |
|
127 | + return $this->key; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function name(): string |
|
135 | + { |
|
136 | + return $this->name; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return string|string[] |
|
142 | + */ |
|
143 | + public function type() |
|
144 | + { |
|
145 | + return $this->type; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Convert the field to array to be |
|
151 | + * able to pass as config to WP GraphQL |
|
152 | + * |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + public function toArray(): array |
|
156 | + { |
|
157 | + return get_object_vars($this); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Sets the value for use_for_input. |
|
163 | + * |
|
164 | + * @param bool $use_for_input |
|
165 | + */ |
|
166 | + protected function setUseForInput(bool $use_for_input) |
|
167 | + { |
|
168 | + $this->use_for_input = filter_var($use_for_input, FILTER_VALIDATE_BOOLEAN); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * Whether the field should be used for |
|
174 | + * mutation inputs. |
|
175 | + * |
|
176 | + * @return bool |
|
177 | + */ |
|
178 | + public function useForInput(): bool |
|
179 | + { |
|
180 | + return $this->use_for_input; |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * Whether the field should be used for |
|
186 | + * query outputs. |
|
187 | + * |
|
188 | + * @return bool |
|
189 | + */ |
|
190 | + public function useForOutput(): bool |
|
191 | + { |
|
192 | + return $this->use_for_output; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * Sets the value for use_for_output |
|
198 | + * |
|
199 | + * @param bool $use_for_output |
|
200 | + */ |
|
201 | + protected function setUseForOutput(bool $use_for_output) |
|
202 | + { |
|
203 | + $this->use_for_output = filter_var($use_for_output, FILTER_VALIDATE_BOOLEAN); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * Whether the field should resolve |
|
209 | + * based on the user caps etc. |
|
210 | + * |
|
211 | + * @return boolean |
|
212 | + */ |
|
213 | + public function shouldResolve(): bool |
|
214 | + { |
|
215 | + foreach ($this->caps as $cap) { |
|
216 | + if (! current_user_can($cap)) { |
|
217 | + return false; |
|
218 | + } |
|
219 | + } |
|
220 | + return true; |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * Whether the field has an explicit resolver set. |
|
226 | + * |
|
227 | + * @return boolean |
|
228 | + */ |
|
229 | + public function hasInternalResolver(): bool |
|
230 | + { |
|
231 | + return is_callable($this->resolver); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Whether the field has an explicit resolver set. |
|
237 | + * |
|
238 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
239 | + * @param array $args The inputArgs on the field |
|
240 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
241 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
242 | + * @return mixed |
|
243 | + * @throws LogicException |
|
244 | + */ |
|
245 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
246 | + { |
|
247 | + if (! $this->hasInternalResolver()) { |
|
248 | + throw new LogicException('GraphQLField has no internal resolver.'); |
|
249 | + } |
|
250 | + // dynamic methods using $this don't play nice |
|
251 | + // so capture resolver to a single var first |
|
252 | + $resolver = $this->resolver; |
|
253 | + return $resolver($source, $args, $context, $info); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * Checks if the format callback is set. |
|
259 | + * If yes, then uses it to format the value. |
|
260 | + * |
|
261 | + * @param mixed $value |
|
262 | + * @param EE_Base_Class $source |
|
263 | + * @return mixed The formatted value. |
|
264 | + * @throws InvalidDataTypeException |
|
265 | + * @throws InvalidInterfaceException |
|
266 | + * @throws InvalidArgumentException |
|
267 | + * @throws ReflectionException |
|
268 | + */ |
|
269 | + public function mayBeFormatValue($value, EE_Base_Class $source) |
|
270 | + { |
|
271 | + if (is_callable($this->formatter)) { |
|
272 | + // dynamic methods using $this don't play nice |
|
273 | + // so capture formatter to a single var first |
|
274 | + $formatter = $this->formatter; |
|
275 | + return $formatter($value, $source); |
|
276 | + } |
|
277 | + return $value; |
|
278 | + } |
|
279 | 279 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function shouldResolve(): bool |
214 | 214 | { |
215 | 215 | foreach ($this->caps as $cap) { |
216 | - if (! current_user_can($cap)) { |
|
216 | + if ( ! current_user_can($cap)) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
246 | 246 | { |
247 | - if (! $this->hasInternalResolver()) { |
|
247 | + if ( ! $this->hasInternalResolver()) { |
|
248 | 248 | throw new LogicException('GraphQLField has no internal resolver.'); |
249 | 249 | } |
250 | 250 | // dynamic methods using $this don't play nice |
@@ -18,127 +18,127 @@ |
||
18 | 18 | */ |
19 | 19 | class TrashLogger |
20 | 20 | { |
21 | - /** |
|
22 | - * extra meta key for tracking when entities are trashed and by who |
|
23 | - * |
|
24 | - * @type string |
|
25 | - */ |
|
26 | - const EXTRA_META_KEY_ENTITY_TRASHED = 'entity-trashed'; |
|
27 | - |
|
28 | - /** |
|
29 | - * extra meta key for tracking when entities are restored and by who |
|
30 | - * |
|
31 | - * @type string |
|
32 | - */ |
|
33 | - const EXTRA_META_KEY_ENTITY_RESTORED = 'entity-restored'; |
|
34 | - |
|
35 | - /** |
|
36 | - * extra meta key for tracking when entities are deleted and by who |
|
37 | - * |
|
38 | - * @type string |
|
39 | - */ |
|
40 | - const EXTRA_META_KEY_ENTITY_DELETED = 'entity-deleted'; |
|
41 | - |
|
42 | - |
|
43 | - public function __construct() |
|
44 | - { |
|
45 | - add_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', [$this, 'logSoftDelete'], 10, 3); |
|
46 | - add_action('AHEE__EE_Base_Class__delete_permanently__end', [$this, 'logHardDelete'], 10, 2); |
|
47 | - add_action( |
|
48 | - 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', |
|
49 | - [$this, 'logBatchDelete'], |
|
50 | - 10, |
|
51 | - 2 |
|
52 | - ); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param EE_Soft_Delete_Base_Class $entity |
|
58 | - * @param bool $delete |
|
59 | - * @param bool $result |
|
60 | - * @throws EE_Error |
|
61 | - * @throws ReflectionException |
|
62 | - */ |
|
63 | - public function logSoftDelete(EE_Soft_Delete_Base_Class $entity, $delete, $result) |
|
64 | - { |
|
65 | - // which base meta key to use... trashed or restored? |
|
66 | - $action = $delete |
|
67 | - ? TrashLogger::EXTRA_META_KEY_ENTITY_TRASHED |
|
68 | - : TrashLogger::EXTRA_META_KEY_ENTITY_RESTORED; |
|
69 | - |
|
70 | - $entity_class = $this->getEntityClass($entity); |
|
71 | - $this->logDelete($entity->ID(), $entity_class, $action, $result); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @param EE_Base_Class $entity |
|
77 | - * @param bool $result |
|
78 | - * @throws EE_Error |
|
79 | - * @throws ReflectionException |
|
80 | - */ |
|
81 | - public function logHardDelete(EE_Base_Class $entity, $result) |
|
82 | - { |
|
83 | - $entity_class = $this->getEntityClass($entity); |
|
84 | - $this->logDelete($entity->ID(), $entity_class, TrashLogger::EXTRA_META_KEY_ENTITY_DELETED, $result); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param int|string $entity_ID |
|
90 | - * @param string $entity_type |
|
91 | - * @throws EE_Error |
|
92 | - * @throws ReflectionException |
|
93 | - */ |
|
94 | - public function logBatchDelete($entity_ID, $entity_type) |
|
95 | - { |
|
96 | - $entity_type = str_replace(['EE_', 'EEM_'], '', $entity_type); |
|
97 | - $this->logDelete($entity_ID, $entity_type, TrashLogger::EXTRA_META_KEY_ENTITY_DELETED, true); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * converts entity class like 'EE_Registration' to 'registration' |
|
103 | - * |
|
104 | - * @param EE_Base_Class $entity |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - private function getEntityClass(EE_Base_Class $entity) |
|
108 | - { |
|
109 | - return str_replace('EE_', '', get_class($entity)); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @param string $entity_ID |
|
115 | - * @param string $entity_type |
|
116 | - * @param string $action |
|
117 | - * @param bool $result |
|
118 | - * @throws EE_Error |
|
119 | - * @throws ReflectionException |
|
120 | - */ |
|
121 | - private function logDelete($entity_ID, $entity_type, $action, $result) |
|
122 | - { |
|
123 | - // if trash/restore/delete was not successful, then get out |
|
124 | - if (! $result) { |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - // convert 'entity-deleted' to just 'deleted' |
|
129 | - $action = str_replace('entity-', '', $action); |
|
130 | - $current_user = wp_get_current_user(); |
|
131 | - $user_name = $current_user->ID ? $current_user->display_name : 'unknown user'; |
|
132 | - $timestamp = date("D M j, Y @ g:i:s a", current_time('timestamp')); |
|
133 | - |
|
134 | - $log = EE_Change_Log::new_instance( |
|
135 | - [ |
|
136 | - 'OBJ_ID' => $entity_ID, |
|
137 | - 'OBJ_type' => $entity_type, |
|
138 | - 'LOG_type' => EEM_Change_Log::type_delete, |
|
139 | - 'LOG_message' => "$action by $user_name on $timestamp", |
|
140 | - ] |
|
141 | - ); |
|
142 | - $log->save(); |
|
143 | - } |
|
21 | + /** |
|
22 | + * extra meta key for tracking when entities are trashed and by who |
|
23 | + * |
|
24 | + * @type string |
|
25 | + */ |
|
26 | + const EXTRA_META_KEY_ENTITY_TRASHED = 'entity-trashed'; |
|
27 | + |
|
28 | + /** |
|
29 | + * extra meta key for tracking when entities are restored and by who |
|
30 | + * |
|
31 | + * @type string |
|
32 | + */ |
|
33 | + const EXTRA_META_KEY_ENTITY_RESTORED = 'entity-restored'; |
|
34 | + |
|
35 | + /** |
|
36 | + * extra meta key for tracking when entities are deleted and by who |
|
37 | + * |
|
38 | + * @type string |
|
39 | + */ |
|
40 | + const EXTRA_META_KEY_ENTITY_DELETED = 'entity-deleted'; |
|
41 | + |
|
42 | + |
|
43 | + public function __construct() |
|
44 | + { |
|
45 | + add_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', [$this, 'logSoftDelete'], 10, 3); |
|
46 | + add_action('AHEE__EE_Base_Class__delete_permanently__end', [$this, 'logHardDelete'], 10, 2); |
|
47 | + add_action( |
|
48 | + 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', |
|
49 | + [$this, 'logBatchDelete'], |
|
50 | + 10, |
|
51 | + 2 |
|
52 | + ); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param EE_Soft_Delete_Base_Class $entity |
|
58 | + * @param bool $delete |
|
59 | + * @param bool $result |
|
60 | + * @throws EE_Error |
|
61 | + * @throws ReflectionException |
|
62 | + */ |
|
63 | + public function logSoftDelete(EE_Soft_Delete_Base_Class $entity, $delete, $result) |
|
64 | + { |
|
65 | + // which base meta key to use... trashed or restored? |
|
66 | + $action = $delete |
|
67 | + ? TrashLogger::EXTRA_META_KEY_ENTITY_TRASHED |
|
68 | + : TrashLogger::EXTRA_META_KEY_ENTITY_RESTORED; |
|
69 | + |
|
70 | + $entity_class = $this->getEntityClass($entity); |
|
71 | + $this->logDelete($entity->ID(), $entity_class, $action, $result); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @param EE_Base_Class $entity |
|
77 | + * @param bool $result |
|
78 | + * @throws EE_Error |
|
79 | + * @throws ReflectionException |
|
80 | + */ |
|
81 | + public function logHardDelete(EE_Base_Class $entity, $result) |
|
82 | + { |
|
83 | + $entity_class = $this->getEntityClass($entity); |
|
84 | + $this->logDelete($entity->ID(), $entity_class, TrashLogger::EXTRA_META_KEY_ENTITY_DELETED, $result); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param int|string $entity_ID |
|
90 | + * @param string $entity_type |
|
91 | + * @throws EE_Error |
|
92 | + * @throws ReflectionException |
|
93 | + */ |
|
94 | + public function logBatchDelete($entity_ID, $entity_type) |
|
95 | + { |
|
96 | + $entity_type = str_replace(['EE_', 'EEM_'], '', $entity_type); |
|
97 | + $this->logDelete($entity_ID, $entity_type, TrashLogger::EXTRA_META_KEY_ENTITY_DELETED, true); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * converts entity class like 'EE_Registration' to 'registration' |
|
103 | + * |
|
104 | + * @param EE_Base_Class $entity |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + private function getEntityClass(EE_Base_Class $entity) |
|
108 | + { |
|
109 | + return str_replace('EE_', '', get_class($entity)); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @param string $entity_ID |
|
115 | + * @param string $entity_type |
|
116 | + * @param string $action |
|
117 | + * @param bool $result |
|
118 | + * @throws EE_Error |
|
119 | + * @throws ReflectionException |
|
120 | + */ |
|
121 | + private function logDelete($entity_ID, $entity_type, $action, $result) |
|
122 | + { |
|
123 | + // if trash/restore/delete was not successful, then get out |
|
124 | + if (! $result) { |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + // convert 'entity-deleted' to just 'deleted' |
|
129 | + $action = str_replace('entity-', '', $action); |
|
130 | + $current_user = wp_get_current_user(); |
|
131 | + $user_name = $current_user->ID ? $current_user->display_name : 'unknown user'; |
|
132 | + $timestamp = date("D M j, Y @ g:i:s a", current_time('timestamp')); |
|
133 | + |
|
134 | + $log = EE_Change_Log::new_instance( |
|
135 | + [ |
|
136 | + 'OBJ_ID' => $entity_ID, |
|
137 | + 'OBJ_type' => $entity_type, |
|
138 | + 'LOG_type' => EEM_Change_Log::type_delete, |
|
139 | + 'LOG_message' => "$action by $user_name on $timestamp", |
|
140 | + ] |
|
141 | + ); |
|
142 | + $log->save(); |
|
143 | + } |
|
144 | 144 | } |
@@ -121,7 +121,7 @@ |
||
121 | 121 | private function logDelete($entity_ID, $entity_type, $action, $result) |
122 | 122 | { |
123 | 123 | // if trash/restore/delete was not successful, then get out |
124 | - if (! $result) { |
|
124 | + if ( ! $result) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | 'espresso_events_edit', |
33 | 33 | $EVT_ID |
34 | 34 | ) |
35 | - ? '<a href="' . esc_url_raw($event_url) . '" aria-label="' |
|
36 | - . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
37 | - . esc_html($registration->event_name()) . '</a>' |
|
35 | + ? '<a href="'.esc_url_raw($event_url).'" aria-label="' |
|
36 | + . esc_attr__('Edit Event', 'event_espresso').'">' |
|
37 | + . esc_html($registration->event_name()).'</a>' |
|
38 | 38 | : esc_html($registration->event_name()); |
39 | 39 | ?> |
40 | 40 | </td> |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | 'espresso_registrations_view_registration', |
51 | 51 | $REG_ID |
52 | 52 | ) |
53 | - ? '<a href="' . esc_url_raw($reg_url) . '" aria-label="' |
|
54 | - . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
55 | - . esc_html__('View Registration', 'event_espresso') . '</a>' |
|
53 | + ? '<a href="'.esc_url_raw($reg_url).'" aria-label="' |
|
54 | + . esc_attr__('View Registration Details', 'event_espresso').'">' |
|
55 | + . esc_html__('View Registration', 'event_espresso').'</a>' |
|
56 | 56 | : $REG_ID; |
57 | 57 | ?> |
58 | 58 | </td> |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | 'ee_read_transaction', |
68 | 68 | 'espresso_transactions_view_transaction' |
69 | 69 | ) |
70 | - ? '<a href="' . esc_url_raw($txn_url) . '" aria-label="' |
|
71 | - . esc_attr__('View Transaction Details', 'event_espresso') . '">' |
|
70 | + ? '<a href="'.esc_url_raw($txn_url).'" aria-label="' |
|
71 | + . esc_attr__('View Transaction Details', 'event_espresso').'">' |
|
72 | 72 | . sprintf( |
73 | 73 | esc_html__('View Transaction %d', 'event_espresso'), |
74 | 74 | $TXN_ID |
75 | - ) . |
|
75 | + ). |
|
76 | 76 | '</a>' |
77 | 77 | : $TXN_ID; |
78 | 78 | ?> |
@@ -26,67 +26,67 @@ |
||
26 | 26 | <tr> |
27 | 27 | <td class="jst-left"> |
28 | 28 | <?php |
29 | - $EVT_ID = absint($registration->event_ID()); |
|
30 | - $event_url = add_query_arg( |
|
31 | - ['action' => 'edit', 'post' => $EVT_ID], |
|
32 | - admin_url('admin.php?page=espresso_events') |
|
33 | - ); |
|
34 | - echo EE_Registry::instance()->CAP->current_user_can( |
|
35 | - 'ee_edit_event', |
|
36 | - 'espresso_events_edit', |
|
37 | - $EVT_ID |
|
38 | - ) |
|
39 | - ? '<a href="' . esc_url_raw($event_url) . '" aria-label="' |
|
40 | - . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
41 | - . esc_html($registration->event_name()) . '</a>' |
|
42 | - : esc_html($registration->event_name()); |
|
43 | - ?> |
|
29 | + $EVT_ID = absint($registration->event_ID()); |
|
30 | + $event_url = add_query_arg( |
|
31 | + ['action' => 'edit', 'post' => $EVT_ID], |
|
32 | + admin_url('admin.php?page=espresso_events') |
|
33 | + ); |
|
34 | + echo EE_Registry::instance()->CAP->current_user_can( |
|
35 | + 'ee_edit_event', |
|
36 | + 'espresso_events_edit', |
|
37 | + $EVT_ID |
|
38 | + ) |
|
39 | + ? '<a href="' . esc_url_raw($event_url) . '" aria-label="' |
|
40 | + . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
41 | + . esc_html($registration->event_name()) . '</a>' |
|
42 | + : esc_html($registration->event_name()); |
|
43 | + ?> |
|
44 | 44 | </td> |
45 | 45 | <td class="jst-left"> |
46 | 46 | <?php |
47 | - $REG_ID = absint($registration->ID()); |
|
48 | - $reg_url = EE_Admin_Page::add_query_args_and_nonce( |
|
49 | - ['action' => 'view_registration', '_REG_ID' => $REG_ID], |
|
50 | - REG_ADMIN_URL |
|
51 | - ); |
|
52 | - echo EE_Registry::instance()->CAP->current_user_can( |
|
53 | - 'ee_read_registration', |
|
54 | - 'espresso_registrations_view_registration', |
|
55 | - $REG_ID |
|
56 | - ) |
|
57 | - ? '<a href="' . esc_url_raw($reg_url) . '" aria-label="' |
|
58 | - . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
59 | - . esc_html__('View Registration', 'event_espresso') . '</a>' |
|
60 | - : $REG_ID; |
|
61 | - ?> |
|
47 | + $REG_ID = absint($registration->ID()); |
|
48 | + $reg_url = EE_Admin_Page::add_query_args_and_nonce( |
|
49 | + ['action' => 'view_registration', '_REG_ID' => $REG_ID], |
|
50 | + REG_ADMIN_URL |
|
51 | + ); |
|
52 | + echo EE_Registry::instance()->CAP->current_user_can( |
|
53 | + 'ee_read_registration', |
|
54 | + 'espresso_registrations_view_registration', |
|
55 | + $REG_ID |
|
56 | + ) |
|
57 | + ? '<a href="' . esc_url_raw($reg_url) . '" aria-label="' |
|
58 | + . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
59 | + . esc_html__('View Registration', 'event_espresso') . '</a>' |
|
60 | + : $REG_ID; |
|
61 | + ?> |
|
62 | 62 | </td> |
63 | 63 | <td class="jst-left"> |
64 | 64 | <?php |
65 | - $TXN_ID = absint($registration->transaction_ID()); |
|
66 | - $txn_url = EE_Admin_Page::add_query_args_and_nonce( |
|
67 | - ['action' => 'view_transaction', 'TXN_ID' => $TXN_ID], |
|
68 | - TXN_ADMIN_URL |
|
69 | - ); |
|
70 | - echo EE_Registry::instance()->CAP->current_user_can( |
|
71 | - 'ee_read_transaction', |
|
72 | - 'espresso_transactions_view_transaction' |
|
73 | - ) |
|
74 | - ? '<a href="' . esc_url_raw($txn_url) . '" aria-label="' |
|
75 | - . esc_attr__('View Transaction Details', 'event_espresso') . '">' |
|
76 | - . sprintf( |
|
77 | - esc_html__('View Transaction %d', 'event_espresso'), |
|
78 | - $TXN_ID |
|
79 | - ) . |
|
80 | - '</a>' |
|
81 | - : $TXN_ID; |
|
82 | - ?> |
|
65 | + $TXN_ID = absint($registration->transaction_ID()); |
|
66 | + $txn_url = EE_Admin_Page::add_query_args_and_nonce( |
|
67 | + ['action' => 'view_transaction', 'TXN_ID' => $TXN_ID], |
|
68 | + TXN_ADMIN_URL |
|
69 | + ); |
|
70 | + echo EE_Registry::instance()->CAP->current_user_can( |
|
71 | + 'ee_read_transaction', |
|
72 | + 'espresso_transactions_view_transaction' |
|
73 | + ) |
|
74 | + ? '<a href="' . esc_url_raw($txn_url) . '" aria-label="' |
|
75 | + . esc_attr__('View Transaction Details', 'event_espresso') . '">' |
|
76 | + . sprintf( |
|
77 | + esc_html__('View Transaction %d', 'event_espresso'), |
|
78 | + $TXN_ID |
|
79 | + ) . |
|
80 | + '</a>' |
|
81 | + : $TXN_ID; |
|
82 | + ?> |
|
83 | 83 | </td> |
84 | 84 | <td class="jst-left"><?php echo esc_html($registration->reg_code()); ?></td> |
85 | 85 | <td class="jst-rght"> |
86 | 86 | <?php echo wp_kses( |
87 | - EEH_Template::format_currency($registration->final_price()), |
|
88 | - AllowedTags::getAllowedTags() |
|
89 | - ); ?> |
|
87 | + EEH_Template::format_currency($registration->final_price()), |
|
88 | + AllowedTags::getAllowedTags() |
|
89 | + ); ?> |
|
90 | 90 | </td> |
91 | 91 | </tr> |
92 | 92 | <?php endforeach; ?> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ), |
70 | 70 | 7 => array( |
71 | 71 | 'content_id' => 'tkt-status-archived', |
72 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::archived, |
|
72 | + 'target' => '.ticket-row .tkt-status-'.EE_Ticket::archived, |
|
73 | 73 | 'content' => $this->_ticket_status_legend(EE_Ticket::archived), |
74 | 74 | 'options' => array( |
75 | 75 | 'position' => array( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ), |
83 | 83 | 8 => array( |
84 | 84 | 'content_id' => 'tkt-status-expired', |
85 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::expired, |
|
85 | + 'target' => '.ticket-row .tkt-status-'.EE_Ticket::expired, |
|
86 | 86 | 'content' => $this->_ticket_status_legend(EE_Ticket::expired), |
87 | 87 | 'options' => array( |
88 | 88 | 'position' => array( |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ), |
96 | 96 | 9 => array( |
97 | 97 | 'content_id' => 'tkt-status-sold_out', |
98 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::sold_out, |
|
98 | + 'target' => '.ticket-row .tkt-status-'.EE_Ticket::sold_out, |
|
99 | 99 | 'content' => $this->_ticket_status_legend(EE_Ticket::sold_out), |
100 | 100 | 'options' => array( |
101 | 101 | 'position' => array( |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ), |
109 | 109 | 10 => array( |
110 | 110 | 'content_id' => 'tkt-status-pending', |
111 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::pending, |
|
111 | + 'target' => '.ticket-row .tkt-status-'.EE_Ticket::pending, |
|
112 | 112 | 'content' => $this->_ticket_status_legend(EE_Ticket::pending), |
113 | 113 | 'options' => array( |
114 | 114 | 'position' => array( |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ), |
122 | 122 | 11 => array( |
123 | 123 | 'content_id' => 'tkt-status-onsale', |
124 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::onsale, |
|
124 | + 'target' => '.ticket-row .tkt-status-'.EE_Ticket::onsale, |
|
125 | 125 | 'content' => $this->_ticket_status_legend(EE_Ticket::onsale), |
126 | 126 | 'options' => array( |
127 | 127 | 'position' => array( |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | 'Clicking the taxable ticket toggle checkbox has enabled taxes for this ticket. What this means is that when a person purchases this ticket, the tax will be applied to all prices on this ticket. You can edit the existing tax price modifier that was setup in Event Espresso by going to %sDefault Pricing Admin Page%s (labelled "Pricing" in the Event Espresso Menu)', |
172 | 172 | 'event_espresso' |
173 | 173 | ), |
174 | - '<a href="' . $price_admin_link . '" aria-label="' . esc_attr__( |
|
174 | + '<a href="'.$price_admin_link.'" aria-label="'.esc_attr__( |
|
175 | 175 | 'Pricing Admin Page', |
176 | 176 | 'event_espresso' |
177 | - ) . '">', |
|
177 | + ).'">', |
|
178 | 178 | '</a>' |
179 | - ) . '</p>'; |
|
179 | + ).'</p>'; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -13,133 +13,133 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Event_Editor_Tips extends EE_Qtip_Config |
15 | 15 | { |
16 | - protected function _set_tips_array() |
|
17 | - { |
|
18 | - $this->_qtipsa = array( |
|
19 | - 0 => array( |
|
20 | - 'content_id' => 'about-taxable-toggle', |
|
21 | - 'target' => '.TKT-taxable-checkbox', |
|
22 | - 'content' => $this->_get_taxable_info_content(), |
|
23 | - 'options' => array( |
|
24 | - 'show_only_once' => true, |
|
25 | - 'content' => array( |
|
26 | - 'title' => esc_html__('Taxable Ticket Toggle', 'event_espresso'), |
|
27 | - 'button' => true, |
|
28 | - ), |
|
29 | - 'show' => array( |
|
30 | - 'event' => 'click', |
|
31 | - ), |
|
32 | - 'hide' => array( |
|
33 | - 'event' => false, |
|
34 | - ), |
|
35 | - 'style' => array( |
|
36 | - 'classes' => '', |
|
37 | - ), |
|
38 | - )// defaults |
|
39 | - ), |
|
40 | - 7 => array( |
|
41 | - 'content_id' => 'tkt-status-archived', |
|
42 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::archived, |
|
43 | - 'content' => $this->_ticket_status_legend(EE_Ticket::archived), |
|
44 | - 'options' => array( |
|
45 | - 'position' => array( |
|
46 | - 'target' => 'mouse', |
|
47 | - 'adjust' => array( |
|
48 | - 'mouse' => false, |
|
49 | - ), |
|
50 | - ), |
|
51 | - ), |
|
52 | - ), |
|
53 | - 8 => array( |
|
54 | - 'content_id' => 'tkt-status-expired', |
|
55 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::expired, |
|
56 | - 'content' => $this->_ticket_status_legend(EE_Ticket::expired), |
|
57 | - 'options' => array( |
|
58 | - 'position' => array( |
|
59 | - 'target' => 'mouse', |
|
60 | - 'adjust' => array( |
|
61 | - 'mouse' => false, |
|
62 | - ), |
|
63 | - ), |
|
64 | - ), |
|
65 | - ), |
|
66 | - 9 => array( |
|
67 | - 'content_id' => 'tkt-status-sold_out', |
|
68 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::sold_out, |
|
69 | - 'content' => $this->_ticket_status_legend(EE_Ticket::sold_out), |
|
70 | - 'options' => array( |
|
71 | - 'position' => array( |
|
72 | - 'target' => 'mouse', |
|
73 | - 'adjust' => array( |
|
74 | - 'mouse' => false, |
|
75 | - ), |
|
76 | - ), |
|
77 | - ), |
|
78 | - ), |
|
79 | - 10 => array( |
|
80 | - 'content_id' => 'tkt-status-pending', |
|
81 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::pending, |
|
82 | - 'content' => $this->_ticket_status_legend(EE_Ticket::pending), |
|
83 | - 'options' => array( |
|
84 | - 'position' => array( |
|
85 | - 'target' => 'mouse', |
|
86 | - 'adjust' => array( |
|
87 | - 'mouse' => false, |
|
88 | - ), |
|
89 | - ), |
|
90 | - ), |
|
91 | - ), |
|
92 | - 11 => array( |
|
93 | - 'content_id' => 'tkt-status-onsale', |
|
94 | - 'target' => '.ticket-row .tkt-status-' . EE_Ticket::onsale, |
|
95 | - 'content' => $this->_ticket_status_legend(EE_Ticket::onsale), |
|
96 | - 'options' => array( |
|
97 | - 'position' => array( |
|
98 | - 'target' => 'mouse', |
|
99 | - 'adjust' => array( |
|
100 | - 'mouse' => false, |
|
101 | - ), |
|
102 | - ), |
|
103 | - ), |
|
104 | - ), |
|
105 | - ); |
|
106 | - } |
|
16 | + protected function _set_tips_array() |
|
17 | + { |
|
18 | + $this->_qtipsa = array( |
|
19 | + 0 => array( |
|
20 | + 'content_id' => 'about-taxable-toggle', |
|
21 | + 'target' => '.TKT-taxable-checkbox', |
|
22 | + 'content' => $this->_get_taxable_info_content(), |
|
23 | + 'options' => array( |
|
24 | + 'show_only_once' => true, |
|
25 | + 'content' => array( |
|
26 | + 'title' => esc_html__('Taxable Ticket Toggle', 'event_espresso'), |
|
27 | + 'button' => true, |
|
28 | + ), |
|
29 | + 'show' => array( |
|
30 | + 'event' => 'click', |
|
31 | + ), |
|
32 | + 'hide' => array( |
|
33 | + 'event' => false, |
|
34 | + ), |
|
35 | + 'style' => array( |
|
36 | + 'classes' => '', |
|
37 | + ), |
|
38 | + )// defaults |
|
39 | + ), |
|
40 | + 7 => array( |
|
41 | + 'content_id' => 'tkt-status-archived', |
|
42 | + 'target' => '.ticket-row .tkt-status-' . EE_Ticket::archived, |
|
43 | + 'content' => $this->_ticket_status_legend(EE_Ticket::archived), |
|
44 | + 'options' => array( |
|
45 | + 'position' => array( |
|
46 | + 'target' => 'mouse', |
|
47 | + 'adjust' => array( |
|
48 | + 'mouse' => false, |
|
49 | + ), |
|
50 | + ), |
|
51 | + ), |
|
52 | + ), |
|
53 | + 8 => array( |
|
54 | + 'content_id' => 'tkt-status-expired', |
|
55 | + 'target' => '.ticket-row .tkt-status-' . EE_Ticket::expired, |
|
56 | + 'content' => $this->_ticket_status_legend(EE_Ticket::expired), |
|
57 | + 'options' => array( |
|
58 | + 'position' => array( |
|
59 | + 'target' => 'mouse', |
|
60 | + 'adjust' => array( |
|
61 | + 'mouse' => false, |
|
62 | + ), |
|
63 | + ), |
|
64 | + ), |
|
65 | + ), |
|
66 | + 9 => array( |
|
67 | + 'content_id' => 'tkt-status-sold_out', |
|
68 | + 'target' => '.ticket-row .tkt-status-' . EE_Ticket::sold_out, |
|
69 | + 'content' => $this->_ticket_status_legend(EE_Ticket::sold_out), |
|
70 | + 'options' => array( |
|
71 | + 'position' => array( |
|
72 | + 'target' => 'mouse', |
|
73 | + 'adjust' => array( |
|
74 | + 'mouse' => false, |
|
75 | + ), |
|
76 | + ), |
|
77 | + ), |
|
78 | + ), |
|
79 | + 10 => array( |
|
80 | + 'content_id' => 'tkt-status-pending', |
|
81 | + 'target' => '.ticket-row .tkt-status-' . EE_Ticket::pending, |
|
82 | + 'content' => $this->_ticket_status_legend(EE_Ticket::pending), |
|
83 | + 'options' => array( |
|
84 | + 'position' => array( |
|
85 | + 'target' => 'mouse', |
|
86 | + 'adjust' => array( |
|
87 | + 'mouse' => false, |
|
88 | + ), |
|
89 | + ), |
|
90 | + ), |
|
91 | + ), |
|
92 | + 11 => array( |
|
93 | + 'content_id' => 'tkt-status-onsale', |
|
94 | + 'target' => '.ticket-row .tkt-status-' . EE_Ticket::onsale, |
|
95 | + 'content' => $this->_ticket_status_legend(EE_Ticket::onsale), |
|
96 | + 'options' => array( |
|
97 | + 'position' => array( |
|
98 | + 'target' => 'mouse', |
|
99 | + 'adjust' => array( |
|
100 | + 'mouse' => false, |
|
101 | + ), |
|
102 | + ), |
|
103 | + ), |
|
104 | + ), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - private function _get_taxable_info_content() |
|
110 | - { |
|
111 | - $price_admin_link = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), PRICING_ADMIN_URL); |
|
112 | - return '<p>' |
|
113 | - . sprintf( |
|
114 | - esc_html__( |
|
115 | - 'Clicking the taxable ticket toggle checkbox has enabled taxes for this ticket. What this means is that when a person purchases this ticket, the tax will be applied to all prices on this ticket. You can edit the existing tax price modifier that was setup in Event Espresso by going to %sDefault Pricing Admin Page%s (labelled "Pricing" in the Event Espresso Menu)', |
|
116 | - 'event_espresso' |
|
117 | - ), |
|
118 | - '<a href="' . $price_admin_link . '" aria-label="' . esc_attr__( |
|
119 | - 'Pricing Admin Page', |
|
120 | - 'event_espresso' |
|
121 | - ) . '">', |
|
122 | - '</a>' |
|
123 | - ) . '</p>'; |
|
124 | - } |
|
109 | + private function _get_taxable_info_content() |
|
110 | + { |
|
111 | + $price_admin_link = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), PRICING_ADMIN_URL); |
|
112 | + return '<p>' |
|
113 | + . sprintf( |
|
114 | + esc_html__( |
|
115 | + 'Clicking the taxable ticket toggle checkbox has enabled taxes for this ticket. What this means is that when a person purchases this ticket, the tax will be applied to all prices on this ticket. You can edit the existing tax price modifier that was setup in Event Espresso by going to %sDefault Pricing Admin Page%s (labelled "Pricing" in the Event Espresso Menu)', |
|
116 | + 'event_espresso' |
|
117 | + ), |
|
118 | + '<a href="' . $price_admin_link . '" aria-label="' . esc_attr__( |
|
119 | + 'Pricing Admin Page', |
|
120 | + 'event_espresso' |
|
121 | + ) . '">', |
|
122 | + '</a>' |
|
123 | + ) . '</p>'; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * output the relevant ee-status-legend with the designated status highlighted. |
|
128 | - * |
|
129 | - * @param EE_Ticket constant $status What status is set (by class) |
|
130 | - * @return string The status legend with the related status highlighted |
|
131 | - */ |
|
132 | - private function _ticket_status_legend($status) |
|
133 | - { |
|
126 | + /** |
|
127 | + * output the relevant ee-status-legend with the designated status highlighted. |
|
128 | + * |
|
129 | + * @param EE_Ticket constant $status What status is set (by class) |
|
130 | + * @return string The status legend with the related status highlighted |
|
131 | + */ |
|
132 | + private function _ticket_status_legend($status) |
|
133 | + { |
|
134 | 134 | |
135 | - $status_array = array( |
|
136 | - 'archived' => EE_Ticket::archived, |
|
137 | - 'expired' => EE_Ticket::expired, |
|
138 | - 'sold_out' => EE_Ticket::sold_out, |
|
139 | - 'pending' => EE_Ticket::pending, |
|
140 | - 'onsale' => EE_Ticket::onsale, |
|
141 | - ); |
|
135 | + $status_array = array( |
|
136 | + 'archived' => EE_Ticket::archived, |
|
137 | + 'expired' => EE_Ticket::expired, |
|
138 | + 'sold_out' => EE_Ticket::sold_out, |
|
139 | + 'pending' => EE_Ticket::pending, |
|
140 | + 'onsale' => EE_Ticket::onsale, |
|
141 | + ); |
|
142 | 142 | |
143 | - return EEH_Template::status_legend($status_array, $status); |
|
144 | - } |
|
143 | + return EEH_Template::status_legend($status_array, $status); |
|
144 | + } |
|
145 | 145 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->reg_status = $reg_status; |
91 | 91 | // grab the related ticket object for this line_item if one wasn't already supplied |
92 | 92 | $this->ticket = $ticket instanceof EE_Ticket ? $ticket : $this->ticket_line_item->ticket(); |
93 | - if (! $this->ticket instanceof EE_Ticket) { |
|
93 | + if ( ! $this->ticket instanceof EE_Ticket) { |
|
94 | 94 | throw new InvalidEntityException( |
95 | 95 | is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
96 | 96 | 'EE_Ticket', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getCapCheck() |
111 | 111 | { |
112 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
112 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
113 | 113 | // need cap for non-AJAX admin requests |
114 | 114 | $this->cap_check = ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin() |
115 | 115 | ? new CapCheck('ee_edit_registrations', 'create_new_registration') |
@@ -26,158 +26,158 @@ |
||
26 | 26 | */ |
27 | 27 | class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface |
28 | 28 | { |
29 | - /** |
|
30 | - * @var EE_Transaction $transaction |
|
31 | - */ |
|
32 | - private $transaction; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var EE_Ticket $ticket |
|
36 | - */ |
|
37 | - private $ticket; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var EE_Line_Item $ticket_line_item |
|
41 | - */ |
|
42 | - private $ticket_line_item; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var int $reg_count |
|
46 | - */ |
|
47 | - private $reg_count; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var int $reg_group_size |
|
51 | - */ |
|
52 | - private $reg_group_size; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string $reg_status |
|
56 | - */ |
|
57 | - private $reg_status; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var EE_Registration $registration |
|
61 | - */ |
|
62 | - protected $registration; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * CreateRegistrationCommand constructor. |
|
67 | - * |
|
68 | - * @param EE_Transaction $transaction |
|
69 | - * @param EE_Line_Item $ticket_line_item |
|
70 | - * @param int $reg_count |
|
71 | - * @param int $reg_group_size |
|
72 | - * @param string $reg_status |
|
73 | - * @param EE_Ticket|null $ticket |
|
74 | - * @throws InvalidEntityException |
|
75 | - * @throws EE_Error |
|
76 | - */ |
|
77 | - public function __construct( |
|
78 | - EE_Transaction $transaction, |
|
79 | - EE_Line_Item $ticket_line_item, |
|
80 | - $reg_count = 1, |
|
81 | - $reg_group_size = 0, |
|
82 | - $reg_status = RegStatus::INCOMPLETE, |
|
83 | - EE_Ticket $ticket = null |
|
84 | - ) { |
|
85 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
86 | - $this->transaction = $transaction; |
|
87 | - $this->ticket_line_item = $ticket_line_item; |
|
88 | - $this->reg_count = absint($reg_count); |
|
89 | - $this->reg_group_size = absint($reg_group_size); |
|
90 | - $this->reg_status = $reg_status; |
|
91 | - // grab the related ticket object for this line_item if one wasn't already supplied |
|
92 | - $this->ticket = $ticket instanceof EE_Ticket ? $ticket : $this->ticket_line_item->ticket(); |
|
93 | - if (! $this->ticket instanceof EE_Ticket) { |
|
94 | - throw new InvalidEntityException( |
|
95 | - is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
96 | - 'EE_Ticket', |
|
97 | - sprintf( |
|
98 | - esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
99 | - $ticket_line_item->ID() |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return CapCheckInterface |
|
108 | - * @throws InvalidDataTypeException |
|
109 | - */ |
|
110 | - public function getCapCheck() |
|
111 | - { |
|
112 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
113 | - // need cap for non-AJAX admin requests |
|
114 | - $this->cap_check = ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin() |
|
115 | - ? new CapCheck('ee_edit_registrations', 'create_new_registration') |
|
116 | - : new PublicCapabilities('', 'create_new_registration'); |
|
117 | - } |
|
118 | - return $this->cap_check; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return EE_Transaction |
|
124 | - */ |
|
125 | - public function transaction() |
|
126 | - { |
|
127 | - return $this->transaction; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return EE_Ticket |
|
133 | - */ |
|
134 | - public function ticket() |
|
135 | - { |
|
136 | - return $this->ticket; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return EE_Line_Item |
|
142 | - */ |
|
143 | - public function ticketLineItem() |
|
144 | - { |
|
145 | - return $this->ticket_line_item; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @return int |
|
151 | - */ |
|
152 | - public function regCount() |
|
153 | - { |
|
154 | - return $this->reg_count; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return int |
|
160 | - */ |
|
161 | - public function regGroupSize() |
|
162 | - { |
|
163 | - return $this->reg_group_size; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function regStatus() |
|
171 | - { |
|
172 | - return $this->reg_status; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @return EE_Registration |
|
178 | - */ |
|
179 | - public function registration() |
|
180 | - { |
|
181 | - return $this->registration; |
|
182 | - } |
|
29 | + /** |
|
30 | + * @var EE_Transaction $transaction |
|
31 | + */ |
|
32 | + private $transaction; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var EE_Ticket $ticket |
|
36 | + */ |
|
37 | + private $ticket; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var EE_Line_Item $ticket_line_item |
|
41 | + */ |
|
42 | + private $ticket_line_item; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var int $reg_count |
|
46 | + */ |
|
47 | + private $reg_count; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var int $reg_group_size |
|
51 | + */ |
|
52 | + private $reg_group_size; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string $reg_status |
|
56 | + */ |
|
57 | + private $reg_status; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var EE_Registration $registration |
|
61 | + */ |
|
62 | + protected $registration; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * CreateRegistrationCommand constructor. |
|
67 | + * |
|
68 | + * @param EE_Transaction $transaction |
|
69 | + * @param EE_Line_Item $ticket_line_item |
|
70 | + * @param int $reg_count |
|
71 | + * @param int $reg_group_size |
|
72 | + * @param string $reg_status |
|
73 | + * @param EE_Ticket|null $ticket |
|
74 | + * @throws InvalidEntityException |
|
75 | + * @throws EE_Error |
|
76 | + */ |
|
77 | + public function __construct( |
|
78 | + EE_Transaction $transaction, |
|
79 | + EE_Line_Item $ticket_line_item, |
|
80 | + $reg_count = 1, |
|
81 | + $reg_group_size = 0, |
|
82 | + $reg_status = RegStatus::INCOMPLETE, |
|
83 | + EE_Ticket $ticket = null |
|
84 | + ) { |
|
85 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
86 | + $this->transaction = $transaction; |
|
87 | + $this->ticket_line_item = $ticket_line_item; |
|
88 | + $this->reg_count = absint($reg_count); |
|
89 | + $this->reg_group_size = absint($reg_group_size); |
|
90 | + $this->reg_status = $reg_status; |
|
91 | + // grab the related ticket object for this line_item if one wasn't already supplied |
|
92 | + $this->ticket = $ticket instanceof EE_Ticket ? $ticket : $this->ticket_line_item->ticket(); |
|
93 | + if (! $this->ticket instanceof EE_Ticket) { |
|
94 | + throw new InvalidEntityException( |
|
95 | + is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
96 | + 'EE_Ticket', |
|
97 | + sprintf( |
|
98 | + esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
99 | + $ticket_line_item->ID() |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return CapCheckInterface |
|
108 | + * @throws InvalidDataTypeException |
|
109 | + */ |
|
110 | + public function getCapCheck() |
|
111 | + { |
|
112 | + if (! $this->cap_check instanceof CapCheckInterface) { |
|
113 | + // need cap for non-AJAX admin requests |
|
114 | + $this->cap_check = ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin() |
|
115 | + ? new CapCheck('ee_edit_registrations', 'create_new_registration') |
|
116 | + : new PublicCapabilities('', 'create_new_registration'); |
|
117 | + } |
|
118 | + return $this->cap_check; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return EE_Transaction |
|
124 | + */ |
|
125 | + public function transaction() |
|
126 | + { |
|
127 | + return $this->transaction; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return EE_Ticket |
|
133 | + */ |
|
134 | + public function ticket() |
|
135 | + { |
|
136 | + return $this->ticket; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return EE_Line_Item |
|
142 | + */ |
|
143 | + public function ticketLineItem() |
|
144 | + { |
|
145 | + return $this->ticket_line_item; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @return int |
|
151 | + */ |
|
152 | + public function regCount() |
|
153 | + { |
|
154 | + return $this->reg_count; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return int |
|
160 | + */ |
|
161 | + public function regGroupSize() |
|
162 | + { |
|
163 | + return $this->reg_group_size; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function regStatus() |
|
171 | + { |
|
172 | + return $this->reg_status; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @return EE_Registration |
|
178 | + */ |
|
179 | + public function registration() |
|
180 | + { |
|
181 | + return $this->registration; |
|
182 | + } |
|
183 | 183 | } |
@@ -6,57 +6,57 @@ |
||
6 | 6 | |
7 | 7 | class DecimalValues |
8 | 8 | { |
9 | - /** |
|
10 | - * number of decimal places to round numbers to when performing calculations |
|
11 | - * |
|
12 | - * @var integer |
|
13 | - */ |
|
14 | - protected $decimal_precision = 6; |
|
15 | - |
|
16 | - /** |
|
17 | - * number of decimal places to round numbers to for display |
|
18 | - * |
|
19 | - * @var integer |
|
20 | - */ |
|
21 | - protected $locale_precision = 6; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param EE_Currency_Config $currency_config |
|
26 | - */ |
|
27 | - public function __construct(EE_Currency_Config $currency_config) |
|
28 | - { |
|
29 | - $this->locale_precision = $currency_config->dec_plc; |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * strips formatting, rounds the provided number, and returns a float |
|
34 | - * if $round is set to true, then the decimal precision for the site locale will be used, |
|
35 | - * otherwise the default decimal precision of 6 will be used |
|
36 | - * |
|
37 | - * @param float|int|string $number unformatted number value, ex: 1234.5678956789 |
|
38 | - * @param bool $round whether to round the price off according to the locale settings |
|
39 | - * @return float rounded value, ex: 1,234.567896 |
|
40 | - */ |
|
41 | - public function roundDecimalValue($number, bool $round = false): float |
|
42 | - { |
|
43 | - $precision = $round ? $this->locale_precision : $this->decimal_precision; |
|
44 | - return round( |
|
45 | - $this->filterDecimalValue($number), |
|
46 | - $precision ?? $this->decimal_precision, |
|
47 | - PHP_ROUND_HALF_UP |
|
48 | - ); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Removes all characters except digits, +- and . |
|
54 | - * |
|
55 | - * @param float|int|string $number |
|
56 | - * @return float |
|
57 | - */ |
|
58 | - public function filterDecimalValue($number): float |
|
59 | - { |
|
60 | - return (float) $number; |
|
61 | - } |
|
9 | + /** |
|
10 | + * number of decimal places to round numbers to when performing calculations |
|
11 | + * |
|
12 | + * @var integer |
|
13 | + */ |
|
14 | + protected $decimal_precision = 6; |
|
15 | + |
|
16 | + /** |
|
17 | + * number of decimal places to round numbers to for display |
|
18 | + * |
|
19 | + * @var integer |
|
20 | + */ |
|
21 | + protected $locale_precision = 6; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param EE_Currency_Config $currency_config |
|
26 | + */ |
|
27 | + public function __construct(EE_Currency_Config $currency_config) |
|
28 | + { |
|
29 | + $this->locale_precision = $currency_config->dec_plc; |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * strips formatting, rounds the provided number, and returns a float |
|
34 | + * if $round is set to true, then the decimal precision for the site locale will be used, |
|
35 | + * otherwise the default decimal precision of 6 will be used |
|
36 | + * |
|
37 | + * @param float|int|string $number unformatted number value, ex: 1234.5678956789 |
|
38 | + * @param bool $round whether to round the price off according to the locale settings |
|
39 | + * @return float rounded value, ex: 1,234.567896 |
|
40 | + */ |
|
41 | + public function roundDecimalValue($number, bool $round = false): float |
|
42 | + { |
|
43 | + $precision = $round ? $this->locale_precision : $this->decimal_precision; |
|
44 | + return round( |
|
45 | + $this->filterDecimalValue($number), |
|
46 | + $precision ?? $this->decimal_precision, |
|
47 | + PHP_ROUND_HALF_UP |
|
48 | + ); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Removes all characters except digits, +- and . |
|
54 | + * |
|
55 | + * @param float|int|string $number |
|
56 | + * @return float |
|
57 | + */ |
|
58 | + public function filterDecimalValue($number): float |
|
59 | + { |
|
60 | + return (float) $number; |
|
61 | + } |
|
62 | 62 | } |