1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\graphql\data\mutations; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class EventMutation |
9
|
|
|
* |
10
|
|
|
* @package Event Espresso |
11
|
|
|
* @author Manzoor Wani |
12
|
|
|
*/ |
13
|
|
|
class EventMutation |
14
|
|
|
{ |
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
|
|
|
* @param string $mutation_name Name of the mutation being performed |
21
|
|
|
* @return array |
22
|
|
|
*/ |
23
|
|
|
public static function prepareFields(array $input, $mutation_name) |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
$args = []; |
27
|
|
|
|
28
|
|
|
if (! empty($input['additionalLimit'])) { |
29
|
|
|
$args['EVT_additional_limit'] = absint($input['additionalLimit']); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if (array_key_exists('allowOverflow', $input)) { |
33
|
|
|
$args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if (! empty($input['desc'])) { |
37
|
|
|
$args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (array_key_exists('displayDesc', $input)) { |
41
|
|
|
$args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if (array_key_exists('displayTicketSelector', $input)) { |
45
|
|
|
$args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if (array_key_exists('donations', $input)) { |
49
|
|
|
$args['EVT_donations'] = (bool) ($input['donations']); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
if (! empty($input['externalUrl'])) { |
53
|
|
|
$args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
if (array_key_exists('memberOnly', $input)) { |
57
|
|
|
$args['EVT_member_only'] = (bool) ($input['memberOnly']); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (! empty($input['name'])) { |
61
|
|
|
$args['EVT_name'] = sanitize_text_field($input['name']); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if (! empty($input['order'])) { |
65
|
|
|
$args['EVT_order'] = absint($input['order']); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (! empty($input['phone'])) { |
69
|
|
|
$args['EVT_phone'] = sanitize_text_field($input['phone']); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (! empty($input['shortDesc'])) { |
73
|
|
|
$args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if (! empty($input['timezoneString'])) { |
77
|
|
|
$args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if (! empty($input['visibleOn'])) { |
81
|
|
|
$args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if (! empty($input['wpUser'])) { |
85
|
|
|
$args['EVT_wp_user'] = absint($input['wpUser']); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $args; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|