@@ -6,54 +6,54 @@ |
||
6 | 6 | |
7 | 7 | class Utilities |
8 | 8 | { |
9 | - /** |
|
10 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
11 | - * friendly keys. |
|
12 | - * |
|
13 | - * @param array $where_args |
|
14 | - * @param array $arg_mapping |
|
15 | - * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
16 | - * @return array |
|
17 | - */ |
|
18 | - public function sanitizeWhereArgs(array $where_args, array $arg_mapping, array $id_fields) |
|
19 | - { |
|
20 | - foreach ($where_args as $arg => $value) { |
|
21 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
22 | - continue; |
|
23 | - } |
|
24 | - if (is_array($value) && ! empty($value)) { |
|
25 | - $value = array_map( |
|
26 | - static function ($value) { |
|
27 | - if (is_string($value)) { |
|
28 | - $value = sanitize_text_field($value); |
|
29 | - } |
|
30 | - return $value; |
|
31 | - }, |
|
32 | - $value |
|
33 | - ); |
|
34 | - } elseif (is_string($value)) { |
|
35 | - $value = sanitize_text_field($value); |
|
36 | - } |
|
37 | - $where_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true) |
|
38 | - ? $this->convertGlobalId($value) |
|
39 | - : $value; |
|
40 | - } |
|
41 | - return $where_args; |
|
42 | - } |
|
9 | + /** |
|
10 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
11 | + * friendly keys. |
|
12 | + * |
|
13 | + * @param array $where_args |
|
14 | + * @param array $arg_mapping |
|
15 | + * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
16 | + * @return array |
|
17 | + */ |
|
18 | + public function sanitizeWhereArgs(array $where_args, array $arg_mapping, array $id_fields) |
|
19 | + { |
|
20 | + foreach ($where_args as $arg => $value) { |
|
21 | + if (! array_key_exists($arg, $arg_mapping)) { |
|
22 | + continue; |
|
23 | + } |
|
24 | + if (is_array($value) && ! empty($value)) { |
|
25 | + $value = array_map( |
|
26 | + static function ($value) { |
|
27 | + if (is_string($value)) { |
|
28 | + $value = sanitize_text_field($value); |
|
29 | + } |
|
30 | + return $value; |
|
31 | + }, |
|
32 | + $value |
|
33 | + ); |
|
34 | + } elseif (is_string($value)) { |
|
35 | + $value = sanitize_text_field($value); |
|
36 | + } |
|
37 | + $where_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true) |
|
38 | + ? $this->convertGlobalId($value) |
|
39 | + : $value; |
|
40 | + } |
|
41 | + return $where_args; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Converts global ID to DB ID. |
|
47 | - * |
|
48 | - * @param string|string[] $ID |
|
49 | - * @return mixed |
|
50 | - */ |
|
51 | - protected function convertGlobalId($ID) |
|
52 | - { |
|
53 | - if (is_array($ID)) { |
|
54 | - return array_map([$this, 'convertGlobalId'], $ID); |
|
55 | - } |
|
56 | - $parts = Relay::fromGlobalId($ID); |
|
57 | - return ! empty($parts['id']) ? $parts['id'] : null; |
|
58 | - } |
|
45 | + /** |
|
46 | + * Converts global ID to DB ID. |
|
47 | + * |
|
48 | + * @param string|string[] $ID |
|
49 | + * @return mixed |
|
50 | + */ |
|
51 | + protected function convertGlobalId($ID) |
|
52 | + { |
|
53 | + if (is_array($ID)) { |
|
54 | + return array_map([$this, 'convertGlobalId'], $ID); |
|
55 | + } |
|
56 | + $parts = Relay::fromGlobalId($ID); |
|
57 | + return ! empty($parts['id']) ? $parts['id'] : null; |
|
58 | + } |
|
59 | 59 | } |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | public function sanitizeWhereArgs(array $where_args, array $arg_mapping, array $id_fields) |
19 | 19 | { |
20 | 20 | foreach ($where_args as $arg => $value) { |
21 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
21 | + if ( ! array_key_exists($arg, $arg_mapping)) { |
|
22 | 22 | continue; |
23 | 23 | } |
24 | 24 | if (is_array($value) && ! empty($value)) { |
25 | 25 | $value = array_map( |
26 | - static function ($value) { |
|
26 | + static function($value) { |
|
27 | 27 | if (is_string($value)) { |
28 | 28 | $value = sanitize_text_field($value); |
29 | 29 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } elseif (is_string($value)) { |
35 | 35 | $value = sanitize_text_field($value); |
36 | 36 | } |
37 | - $where_args[ $arg_mapping[ $arg ] ] = in_array($arg, $id_fields, true) |
|
37 | + $where_args[$arg_mapping[$arg]] = in_array($arg, $id_fields, true) |
|
38 | 38 | ? $this->convertGlobalId($value) |
39 | 39 | : $value; |
40 | 40 | } |
@@ -17,24 +17,24 @@ |
||
17 | 17 | class EspressoEditor implements GQLDataDomainInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $loaders The loaders accessible in the AppContext |
|
22 | - * @param AppContext $context The AppContext |
|
23 | - * @return array |
|
24 | - * @return array |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function registerLoaders(array $loaders, AppContext $context) |
|
28 | - { |
|
29 | - $newLoaders = [ |
|
30 | - 'espresso_attendee' => new Loaders\AttendeeLoader($context), |
|
31 | - 'espresso_datetime' => new Loaders\DatetimeLoader($context), |
|
32 | - 'espresso_price' => new Loaders\PriceLoader($context), |
|
33 | - 'espresso_priceType' => new Loaders\PriceTypeLoader($context), |
|
34 | - 'espresso_ticket' => new Loaders\TicketLoader($context), |
|
35 | - 'espresso_venue' => new Loaders\VenueLoader($context), |
|
36 | - ]; |
|
20 | + /** |
|
21 | + * @param array $loaders The loaders accessible in the AppContext |
|
22 | + * @param AppContext $context The AppContext |
|
23 | + * @return array |
|
24 | + * @return array |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function registerLoaders(array $loaders, AppContext $context) |
|
28 | + { |
|
29 | + $newLoaders = [ |
|
30 | + 'espresso_attendee' => new Loaders\AttendeeLoader($context), |
|
31 | + 'espresso_datetime' => new Loaders\DatetimeLoader($context), |
|
32 | + 'espresso_price' => new Loaders\PriceLoader($context), |
|
33 | + 'espresso_priceType' => new Loaders\PriceTypeLoader($context), |
|
34 | + 'espresso_ticket' => new Loaders\TicketLoader($context), |
|
35 | + 'espresso_venue' => new Loaders\VenueLoader($context), |
|
36 | + ]; |
|
37 | 37 | |
38 | - return array_merge($loaders, $newLoaders); |
|
39 | - } |
|
38 | + return array_merge($loaders, $newLoaders); |
|
39 | + } |
|
40 | 40 | } |
@@ -15,12 +15,12 @@ |
||
15 | 15 | interface GQLDataDomainInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param array $loaders The loaders accessible in the AppContext |
|
20 | - * @param AppContext $context The AppContext |
|
21 | - * @return array |
|
22 | - * @return array |
|
23 | - * @since $VID:$ |
|
24 | - */ |
|
25 | - public function registerLoaders(array $loaders, AppContext $context); |
|
18 | + /** |
|
19 | + * @param array $loaders The loaders accessible in the AppContext |
|
20 | + * @param AppContext $context The AppContext |
|
21 | + * @return array |
|
22 | + * @return array |
|
23 | + * @since $VID:$ |
|
24 | + */ |
|
25 | + public function registerLoaders(array $loaders, AppContext $context); |
|
26 | 26 | } |