@@ -13,63 +13,63 @@ |
||
13 | 13 | class PriceMutation |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Maps the GraphQL input to a format that the model functions can use |
|
18 | - * |
|
19 | - * @param array $input Data coming from the GraphQL mutation query input |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public static function prepareFields(array $input) |
|
23 | - { |
|
24 | - $args = []; |
|
16 | + /** |
|
17 | + * Maps the GraphQL input to a format that the model functions can use |
|
18 | + * |
|
19 | + * @param array $input Data coming from the GraphQL mutation query input |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public static function prepareFields(array $input) |
|
23 | + { |
|
24 | + $args = []; |
|
25 | 25 | |
26 | - if (! empty($input['amount'])) { |
|
27 | - $args['PRC_amount'] = (float) $input['amount']; |
|
28 | - } |
|
26 | + if (! empty($input['amount'])) { |
|
27 | + $args['PRC_amount'] = (float) $input['amount']; |
|
28 | + } |
|
29 | 29 | |
30 | - if (! empty($input['description'])) { |
|
31 | - $args['PRC_desc'] = sanitize_text_field($input['description']); |
|
32 | - } |
|
30 | + if (! empty($input['description'])) { |
|
31 | + $args['PRC_desc'] = sanitize_text_field($input['description']); |
|
32 | + } |
|
33 | 33 | |
34 | - if (array_key_exists('isDefault', $input)) { |
|
35 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | - } |
|
34 | + if (array_key_exists('isDefault', $input)) { |
|
35 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | + } |
|
37 | 37 | |
38 | - if (array_key_exists('isTrashed', $input)) { |
|
39 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | - } |
|
38 | + if (array_key_exists('isTrashed', $input)) { |
|
39 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | + } |
|
41 | 41 | |
42 | - if (! empty($input['name'])) { |
|
43 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | - } |
|
42 | + if (! empty($input['name'])) { |
|
43 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | + } |
|
45 | 45 | |
46 | - if (! empty($input['order'])) { |
|
47 | - $args['PRC_order'] = (int) $input['order']; |
|
48 | - } |
|
46 | + if (! empty($input['order'])) { |
|
47 | + $args['PRC_order'] = (int) $input['order']; |
|
48 | + } |
|
49 | 49 | |
50 | - if (! empty($input['overrides'])) { |
|
51 | - $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | - } |
|
50 | + if (! empty($input['overrides'])) { |
|
51 | + $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | + } |
|
53 | 53 | |
54 | - if (! empty($input['parent'])) { |
|
55 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | - } |
|
54 | + if (! empty($input['parent'])) { |
|
55 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | + } |
|
58 | 58 | |
59 | - if (! empty($input['priceType'])) { |
|
60 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | - } |
|
59 | + if (! empty($input['priceType'])) { |
|
60 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | + } |
|
63 | 63 | |
64 | - if (! empty($input['wpUser'])) { |
|
65 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | - } |
|
64 | + if (! empty($input['wpUser'])) { |
|
65 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | + $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + } |
|
68 | 68 | |
69 | - return apply_filters( |
|
70 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | - $args, |
|
72 | - $input |
|
73 | - ); |
|
74 | - } |
|
69 | + return apply_filters( |
|
70 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | + $args, |
|
72 | + $input |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | } |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | { |
24 | 24 | $args = []; |
25 | 25 | |
26 | - if (! empty($input['amount'])) { |
|
26 | + if ( ! empty($input['amount'])) { |
|
27 | 27 | $args['PRC_amount'] = (float) $input['amount']; |
28 | 28 | } |
29 | 29 | |
30 | - if (! empty($input['description'])) { |
|
30 | + if ( ! empty($input['description'])) { |
|
31 | 31 | $args['PRC_desc'] = sanitize_text_field($input['description']); |
32 | 32 | } |
33 | 33 | |
@@ -39,31 +39,31 @@ discard block |
||
39 | 39 | $args['PRC_deleted'] = (bool) $input['isTrashed']; |
40 | 40 | } |
41 | 41 | |
42 | - if (! empty($input['name'])) { |
|
42 | + if ( ! empty($input['name'])) { |
|
43 | 43 | $args['PRC_name'] = sanitize_text_field($input['name']); |
44 | 44 | } |
45 | 45 | |
46 | - if (! empty($input['order'])) { |
|
46 | + if ( ! empty($input['order'])) { |
|
47 | 47 | $args['PRC_order'] = (int) $input['order']; |
48 | 48 | } |
49 | 49 | |
50 | - if (! empty($input['overrides'])) { |
|
50 | + if ( ! empty($input['overrides'])) { |
|
51 | 51 | $args['PRC_overrides'] = (int) $input['overrides']; |
52 | 52 | } |
53 | 53 | |
54 | - if (! empty($input['parent'])) { |
|
54 | + if ( ! empty($input['parent'])) { |
|
55 | 55 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
56 | 56 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
57 | 57 | } |
58 | 58 | |
59 | - if (! empty($input['priceType'])) { |
|
59 | + if ( ! empty($input['priceType'])) { |
|
60 | 60 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
61 | 61 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($input['wpUser'])) { |
|
64 | + if ( ! empty($input['wpUser'])) { |
|
65 | 65 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
66 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
66 | + $args['PRC_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return apply_filters( |
@@ -11,36 +11,36 @@ |
||
11 | 11 | class VenueMutation |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Maps the GraphQL input to a format that the model functions can use |
|
16 | - * |
|
17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
18 | - * @param string $mutation_name Name of the mutation being performed |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public static function prepareFields(array $input, $mutation_name) |
|
22 | - { |
|
23 | - |
|
24 | - $args = []; |
|
25 | - |
|
26 | - if (! empty($input['name'])) { |
|
27 | - $args['VNU_name'] = sanitize_text_field($input['name']); |
|
28 | - } |
|
29 | - |
|
30 | - if (! empty($input['desc'])) { |
|
31 | - $args['VNU_desc'] = sanitize_text_field($input['desc']); |
|
32 | - } |
|
33 | - |
|
34 | - if (! empty($input['shortDesc'])) { |
|
35 | - $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
|
36 | - } |
|
37 | - |
|
38 | - // Likewise the other fields... |
|
39 | - |
|
40 | - return apply_filters( |
|
41 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
42 | - $args, |
|
43 | - $input |
|
44 | - ); |
|
45 | - } |
|
14 | + /** |
|
15 | + * Maps the GraphQL input to a format that the model functions can use |
|
16 | + * |
|
17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
18 | + * @param string $mutation_name Name of the mutation being performed |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public static function prepareFields(array $input, $mutation_name) |
|
22 | + { |
|
23 | + |
|
24 | + $args = []; |
|
25 | + |
|
26 | + if (! empty($input['name'])) { |
|
27 | + $args['VNU_name'] = sanitize_text_field($input['name']); |
|
28 | + } |
|
29 | + |
|
30 | + if (! empty($input['desc'])) { |
|
31 | + $args['VNU_desc'] = sanitize_text_field($input['desc']); |
|
32 | + } |
|
33 | + |
|
34 | + if (! empty($input['shortDesc'])) { |
|
35 | + $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
|
36 | + } |
|
37 | + |
|
38 | + // Likewise the other fields... |
|
39 | + |
|
40 | + return apply_filters( |
|
41 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
42 | + $args, |
|
43 | + $input |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | } |
@@ -14,82 +14,82 @@ |
||
14 | 14 | class EventMutation |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Maps the GraphQL input to a format that the model functions can use |
|
19 | - * |
|
20 | - * @param array $input Data coming from the GraphQL mutation query input |
|
21 | - * @param string $mutation_name Name of the mutation being performed |
|
22 | - * @return array |
|
23 | - * @throws Exception |
|
24 | - */ |
|
25 | - public static function prepareFields(array $input, $mutation_name) |
|
26 | - { |
|
27 | - $args = []; |
|
28 | - |
|
29 | - if (! empty($input['additionalLimit'])) { |
|
30 | - $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
31 | - } |
|
32 | - |
|
33 | - if (array_key_exists('allowOverflow', $input)) { |
|
34 | - $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
35 | - } |
|
36 | - |
|
37 | - if (! empty($input['description'])) { |
|
38 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, $context = 'db'); |
|
39 | - } |
|
40 | - |
|
41 | - if (array_key_exists('displayDesc', $input)) { |
|
42 | - $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
43 | - } |
|
44 | - |
|
45 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
46 | - $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
47 | - } |
|
48 | - |
|
49 | - if (array_key_exists('donations', $input)) { |
|
50 | - $args['EVT_donations'] = (bool) ($input['donations']); |
|
51 | - } |
|
52 | - |
|
53 | - if (! empty($input['externalUrl'])) { |
|
54 | - $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
55 | - } |
|
56 | - |
|
57 | - if (array_key_exists('memberOnly', $input)) { |
|
58 | - $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
59 | - } |
|
60 | - |
|
61 | - if (! empty($input['name'])) { |
|
62 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
63 | - } |
|
64 | - |
|
65 | - if (! empty($input['order'])) { |
|
66 | - $args['EVT_order'] = absint($input['order']); |
|
67 | - } |
|
68 | - |
|
69 | - if (! empty($input['phone'])) { |
|
70 | - $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
71 | - } |
|
72 | - |
|
73 | - if (! empty($input['shortDescription'])) { |
|
74 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, $context = 'db'); |
|
75 | - } |
|
76 | - |
|
77 | - if (! empty($input['timezoneString'])) { |
|
78 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
79 | - } |
|
80 | - |
|
81 | - if (! empty($input['visibleOn'])) { |
|
82 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
83 | - } |
|
84 | - |
|
85 | - if (! empty($input['wpUser'])) { |
|
86 | - $args['EVT_wp_user'] = absint($input['wpUser']); |
|
87 | - } |
|
88 | - |
|
89 | - return apply_filters( |
|
90 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
91 | - $args, |
|
92 | - $input |
|
93 | - ); |
|
94 | - } |
|
17 | + /** |
|
18 | + * Maps the GraphQL input to a format that the model functions can use |
|
19 | + * |
|
20 | + * @param array $input Data coming from the GraphQL mutation query input |
|
21 | + * @param string $mutation_name Name of the mutation being performed |
|
22 | + * @return array |
|
23 | + * @throws Exception |
|
24 | + */ |
|
25 | + public static function prepareFields(array $input, $mutation_name) |
|
26 | + { |
|
27 | + $args = []; |
|
28 | + |
|
29 | + if (! empty($input['additionalLimit'])) { |
|
30 | + $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
31 | + } |
|
32 | + |
|
33 | + if (array_key_exists('allowOverflow', $input)) { |
|
34 | + $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
35 | + } |
|
36 | + |
|
37 | + if (! empty($input['description'])) { |
|
38 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, $context = 'db'); |
|
39 | + } |
|
40 | + |
|
41 | + if (array_key_exists('displayDesc', $input)) { |
|
42 | + $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
43 | + } |
|
44 | + |
|
45 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
46 | + $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
47 | + } |
|
48 | + |
|
49 | + if (array_key_exists('donations', $input)) { |
|
50 | + $args['EVT_donations'] = (bool) ($input['donations']); |
|
51 | + } |
|
52 | + |
|
53 | + if (! empty($input['externalUrl'])) { |
|
54 | + $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
55 | + } |
|
56 | + |
|
57 | + if (array_key_exists('memberOnly', $input)) { |
|
58 | + $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
59 | + } |
|
60 | + |
|
61 | + if (! empty($input['name'])) { |
|
62 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
63 | + } |
|
64 | + |
|
65 | + if (! empty($input['order'])) { |
|
66 | + $args['EVT_order'] = absint($input['order']); |
|
67 | + } |
|
68 | + |
|
69 | + if (! empty($input['phone'])) { |
|
70 | + $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
71 | + } |
|
72 | + |
|
73 | + if (! empty($input['shortDescription'])) { |
|
74 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, $context = 'db'); |
|
75 | + } |
|
76 | + |
|
77 | + if (! empty($input['timezoneString'])) { |
|
78 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
79 | + } |
|
80 | + |
|
81 | + if (! empty($input['visibleOn'])) { |
|
82 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
83 | + } |
|
84 | + |
|
85 | + if (! empty($input['wpUser'])) { |
|
86 | + $args['EVT_wp_user'] = absint($input['wpUser']); |
|
87 | + } |
|
88 | + |
|
89 | + return apply_filters( |
|
90 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
91 | + $args, |
|
92 | + $input |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | } |
@@ -21,106 +21,106 @@ |
||
21 | 21 | class DatetimeMutation |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Maps the GraphQL input to a format that the model functions can use |
|
26 | - * |
|
27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
28 | - * @return array |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - public static function prepareFields(array $input) |
|
32 | - { |
|
33 | - $args = []; |
|
34 | - |
|
35 | - if (array_key_exists('capacity', $input)) { |
|
36 | - $args['DTT_reg_limit'] = (int) $input['capacity']; |
|
37 | - } |
|
38 | - |
|
39 | - if (isset($input['description'])) { |
|
40 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
41 | - } |
|
42 | - |
|
43 | - if (! empty($input['endDate'])) { |
|
44 | - $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['eventId'])) { |
|
48 | - $args['EVT_ID'] = absint($input['eventId']); |
|
49 | - } elseif (! empty($input['event'])) { |
|
50 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['event'])); |
|
51 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
52 | - } |
|
53 | - |
|
54 | - if (array_key_exists('isPrimary', $input)) { |
|
55 | - $args['DTT_is_primary'] = (bool) $input['isPrimary']; |
|
56 | - } |
|
57 | - |
|
58 | - if (array_key_exists('isTrashed', $input)) { |
|
59 | - $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
60 | - } |
|
61 | - |
|
62 | - if (isset($input['name'])) { |
|
63 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
64 | - } |
|
65 | - |
|
66 | - if (array_key_exists('order', $input)) { |
|
67 | - $args['DTT_order'] = (int) $input['order']; |
|
68 | - } |
|
69 | - |
|
70 | - if (! empty($input['parent'])) { |
|
71 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
72 | - $args['DTT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
73 | - } |
|
74 | - |
|
75 | - if (array_key_exists('reserved', $input)) { |
|
76 | - $args['DTT_reserved'] = (int) $input['reserved']; |
|
77 | - } |
|
78 | - |
|
79 | - if (array_key_exists('sold', $input)) { |
|
80 | - $args['DTT_sold'] = (int) $input['sold']; |
|
81 | - } |
|
82 | - |
|
83 | - if (! empty($input['startDate'])) { |
|
84 | - $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
85 | - } |
|
86 | - |
|
87 | - if (! empty($input['tickets'])) { |
|
88 | - $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
89 | - } |
|
90 | - |
|
91 | - return apply_filters( |
|
92 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args', |
|
93 | - $args, |
|
94 | - $input |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Sets the related tickets for the given datetime. |
|
101 | - * |
|
102 | - * @param EE_Datetime $entity The datetime instance. |
|
103 | - * @param array $tickets Array of ticket IDs to relate. |
|
104 | - * @throws EE_Error |
|
105 | - * @throws InvalidDataTypeException |
|
106 | - * @throws InvalidInterfaceException |
|
107 | - * @throws InvalidArgumentException |
|
108 | - * @throws ReflectionException |
|
109 | - */ |
|
110 | - public static function setRelatedTickets($entity, array $tickets) |
|
111 | - { |
|
112 | - $relationName = 'Ticket'; |
|
113 | - // Remove all the existing related tickets |
|
114 | - $entity->_remove_relations($relationName); |
|
115 | - |
|
116 | - foreach ($tickets as $ID) { |
|
117 | - $parts = Relay::fromGlobalId($ID); |
|
118 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
119 | - $entity->_add_relation_to( |
|
120 | - $parts['id'], |
|
121 | - $relationName |
|
122 | - ); |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
24 | + /** |
|
25 | + * Maps the GraphQL input to a format that the model functions can use |
|
26 | + * |
|
27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
28 | + * @return array |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + public static function prepareFields(array $input) |
|
32 | + { |
|
33 | + $args = []; |
|
34 | + |
|
35 | + if (array_key_exists('capacity', $input)) { |
|
36 | + $args['DTT_reg_limit'] = (int) $input['capacity']; |
|
37 | + } |
|
38 | + |
|
39 | + if (isset($input['description'])) { |
|
40 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
41 | + } |
|
42 | + |
|
43 | + if (! empty($input['endDate'])) { |
|
44 | + $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['eventId'])) { |
|
48 | + $args['EVT_ID'] = absint($input['eventId']); |
|
49 | + } elseif (! empty($input['event'])) { |
|
50 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['event'])); |
|
51 | + $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
52 | + } |
|
53 | + |
|
54 | + if (array_key_exists('isPrimary', $input)) { |
|
55 | + $args['DTT_is_primary'] = (bool) $input['isPrimary']; |
|
56 | + } |
|
57 | + |
|
58 | + if (array_key_exists('isTrashed', $input)) { |
|
59 | + $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
60 | + } |
|
61 | + |
|
62 | + if (isset($input['name'])) { |
|
63 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
64 | + } |
|
65 | + |
|
66 | + if (array_key_exists('order', $input)) { |
|
67 | + $args['DTT_order'] = (int) $input['order']; |
|
68 | + } |
|
69 | + |
|
70 | + if (! empty($input['parent'])) { |
|
71 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
72 | + $args['DTT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
73 | + } |
|
74 | + |
|
75 | + if (array_key_exists('reserved', $input)) { |
|
76 | + $args['DTT_reserved'] = (int) $input['reserved']; |
|
77 | + } |
|
78 | + |
|
79 | + if (array_key_exists('sold', $input)) { |
|
80 | + $args['DTT_sold'] = (int) $input['sold']; |
|
81 | + } |
|
82 | + |
|
83 | + if (! empty($input['startDate'])) { |
|
84 | + $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
85 | + } |
|
86 | + |
|
87 | + if (! empty($input['tickets'])) { |
|
88 | + $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
89 | + } |
|
90 | + |
|
91 | + return apply_filters( |
|
92 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args', |
|
93 | + $args, |
|
94 | + $input |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Sets the related tickets for the given datetime. |
|
101 | + * |
|
102 | + * @param EE_Datetime $entity The datetime instance. |
|
103 | + * @param array $tickets Array of ticket IDs to relate. |
|
104 | + * @throws EE_Error |
|
105 | + * @throws InvalidDataTypeException |
|
106 | + * @throws InvalidInterfaceException |
|
107 | + * @throws InvalidArgumentException |
|
108 | + * @throws ReflectionException |
|
109 | + */ |
|
110 | + public static function setRelatedTickets($entity, array $tickets) |
|
111 | + { |
|
112 | + $relationName = 'Ticket'; |
|
113 | + // Remove all the existing related tickets |
|
114 | + $entity->_remove_relations($relationName); |
|
115 | + |
|
116 | + foreach ($tickets as $ID) { |
|
117 | + $parts = Relay::fromGlobalId($ID); |
|
118 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
119 | + $entity->_add_relation_to( |
|
120 | + $parts['id'], |
|
121 | + $relationName |
|
122 | + ); |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |