@@ -25,83 +25,83 @@ |
||
25 | 25 | { |
26 | 26 | $args = []; |
27 | 27 | |
28 | - if (! empty($input['name'])) { |
|
28 | + if ( ! empty($input['name'])) { |
|
29 | 29 | $args['VNU_name'] = sanitize_text_field($input['name']); |
30 | 30 | } |
31 | 31 | |
32 | - if (! empty($input['description'])) { |
|
32 | + if ( ! empty($input['description'])) { |
|
33 | 33 | $args['VNU_desc'] = wp_kses_post($input['description']); |
34 | 34 | } |
35 | 35 | |
36 | - if (! empty($input['shortDescription'])) { |
|
36 | + if ( ! empty($input['shortDescription'])) { |
|
37 | 37 | $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
38 | 38 | } |
39 | 39 | |
40 | - if (! empty($input['identifier'])) { |
|
40 | + if ( ! empty($input['identifier'])) { |
|
41 | 41 | $args['VNU_identifier'] = sanitize_title($input['identifier']); |
42 | 42 | } |
43 | 43 | |
44 | - if (! empty($input['created'])) { |
|
44 | + if ( ! empty($input['created'])) { |
|
45 | 45 | $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
46 | 46 | } |
47 | 47 | |
48 | - if (! empty($input['order'])) { |
|
48 | + if ( ! empty($input['order'])) { |
|
49 | 49 | $args['VNU_order'] = absint($input['order']); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($input['wpUser'])) { |
|
52 | + if ( ! empty($input['wpUser'])) { |
|
53 | 53 | $args['VNU_wp_user'] = absint($input['wpUser']); |
54 | 54 | } |
55 | 55 | |
56 | - if (! empty($input['address'])) { |
|
56 | + if ( ! empty($input['address'])) { |
|
57 | 57 | $args['VNU_address'] = sanitize_text_field($input['address']); |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['address2'])) { |
|
60 | + if ( ! empty($input['address2'])) { |
|
61 | 61 | $args['VNU_address2'] = sanitize_text_field($input['address2']); |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($input['city'])) { |
|
64 | + if ( ! empty($input['city'])) { |
|
65 | 65 | $args['VNU_city'] = sanitize_text_field($input['city']); |
66 | 66 | } |
67 | 67 | |
68 | - if (! empty($input['state'])) { |
|
68 | + if ( ! empty($input['state'])) { |
|
69 | 69 | $args['STA_ID'] = absint($input['state']); |
70 | 70 | } |
71 | 71 | |
72 | - if (! empty($input['country'])) { |
|
72 | + if ( ! empty($input['country'])) { |
|
73 | 73 | $args['CNT_ISO'] = sanitize_text_field($input['country']); |
74 | 74 | } |
75 | 75 | |
76 | - if (! empty($input['zip'])) { |
|
76 | + if ( ! empty($input['zip'])) { |
|
77 | 77 | $args['VNU_zip'] = sanitize_text_field($input['zip']); |
78 | 78 | } |
79 | 79 | |
80 | - if (! empty($input['capacity'])) { |
|
80 | + if ( ! empty($input['capacity'])) { |
|
81 | 81 | $args['VNU_capacity'] = absint($input['capacity']); |
82 | 82 | } |
83 | 83 | |
84 | - if (! empty($input['phone'])) { |
|
84 | + if ( ! empty($input['phone'])) { |
|
85 | 85 | $args['VNU_phone'] = sanitize_text_field($input['phone']); |
86 | 86 | } |
87 | 87 | |
88 | - if (! empty($input['virtualPhone'])) { |
|
88 | + if ( ! empty($input['virtualPhone'])) { |
|
89 | 89 | $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
90 | 90 | } |
91 | 91 | |
92 | - if (! empty($input['url'])) { |
|
92 | + if ( ! empty($input['url'])) { |
|
93 | 93 | $args['VNU_url'] = sanitize_text_field($input['url']); |
94 | 94 | } |
95 | 95 | |
96 | - if (! empty($input['virtualUrl'])) { |
|
96 | + if ( ! empty($input['virtualUrl'])) { |
|
97 | 97 | $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
98 | 98 | } |
99 | 99 | |
100 | - if (! empty($input['googleMapLink'])) { |
|
100 | + if ( ! empty($input['googleMapLink'])) { |
|
101 | 101 | $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
102 | 102 | } |
103 | 103 | |
104 | - if (! empty($input['enableForGmap'])) { |
|
104 | + if ( ! empty($input['enableForGmap'])) { |
|
105 | 105 | $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
106 | 106 | } |
107 | 107 |
@@ -13,101 +13,101 @@ |
||
13 | 13 | */ |
14 | 14 | class VenueMutation |
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 | - * @throws Exception |
|
22 | - */ |
|
23 | - public static function prepareFields(array $input): array |
|
24 | - { |
|
25 | - $args = []; |
|
26 | - |
|
27 | - if (! empty($input['name'])) { |
|
28 | - $args['VNU_name'] = sanitize_text_field($input['name']); |
|
29 | - } |
|
30 | - |
|
31 | - if (! empty($input['description'])) { |
|
32 | - $args['VNU_desc'] = wp_kses_post($input['description']); |
|
33 | - } |
|
34 | - |
|
35 | - if (! empty($input['shortDescription'])) { |
|
36 | - $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
|
37 | - } |
|
38 | - |
|
39 | - if (! empty($input['identifier'])) { |
|
40 | - $args['VNU_identifier'] = sanitize_title($input['identifier']); |
|
41 | - } |
|
42 | - |
|
43 | - if (! empty($input['created'])) { |
|
44 | - $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['order'])) { |
|
48 | - $args['VNU_order'] = absint($input['order']); |
|
49 | - } |
|
50 | - |
|
51 | - if (! empty($input['wpUser'])) { |
|
52 | - $args['VNU_wp_user'] = absint($input['wpUser']); |
|
53 | - } |
|
54 | - |
|
55 | - if (! empty($input['address'])) { |
|
56 | - $args['VNU_address'] = sanitize_text_field($input['address']); |
|
57 | - } |
|
58 | - |
|
59 | - if (! empty($input['address2'])) { |
|
60 | - $args['VNU_address2'] = sanitize_text_field($input['address2']); |
|
61 | - } |
|
62 | - |
|
63 | - if (! empty($input['city'])) { |
|
64 | - $args['VNU_city'] = sanitize_text_field($input['city']); |
|
65 | - } |
|
66 | - |
|
67 | - if (! empty($input['state'])) { |
|
68 | - $args['STA_ID'] = absint($input['state']); |
|
69 | - } |
|
70 | - |
|
71 | - if (! empty($input['country'])) { |
|
72 | - $args['CNT_ISO'] = sanitize_text_field($input['country']); |
|
73 | - } |
|
74 | - |
|
75 | - if (! empty($input['zip'])) { |
|
76 | - $args['VNU_zip'] = sanitize_text_field($input['zip']); |
|
77 | - } |
|
78 | - |
|
79 | - if (! empty($input['capacity'])) { |
|
80 | - $args['VNU_capacity'] = absint($input['capacity']); |
|
81 | - } |
|
82 | - |
|
83 | - if (! empty($input['phone'])) { |
|
84 | - $args['VNU_phone'] = sanitize_text_field($input['phone']); |
|
85 | - } |
|
86 | - |
|
87 | - if (! empty($input['virtualPhone'])) { |
|
88 | - $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
|
89 | - } |
|
90 | - |
|
91 | - if (! empty($input['url'])) { |
|
92 | - $args['VNU_url'] = sanitize_text_field($input['url']); |
|
93 | - } |
|
94 | - |
|
95 | - if (! empty($input['virtualUrl'])) { |
|
96 | - $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
|
97 | - } |
|
98 | - |
|
99 | - if (! empty($input['googleMapLink'])) { |
|
100 | - $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
|
101 | - } |
|
102 | - |
|
103 | - if (! empty($input['enableForGmap'])) { |
|
104 | - $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
|
105 | - } |
|
106 | - |
|
107 | - return apply_filters( |
|
108 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
109 | - $args, |
|
110 | - $input |
|
111 | - ); |
|
112 | - } |
|
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 | + * @throws Exception |
|
22 | + */ |
|
23 | + public static function prepareFields(array $input): array |
|
24 | + { |
|
25 | + $args = []; |
|
26 | + |
|
27 | + if (! empty($input['name'])) { |
|
28 | + $args['VNU_name'] = sanitize_text_field($input['name']); |
|
29 | + } |
|
30 | + |
|
31 | + if (! empty($input['description'])) { |
|
32 | + $args['VNU_desc'] = wp_kses_post($input['description']); |
|
33 | + } |
|
34 | + |
|
35 | + if (! empty($input['shortDescription'])) { |
|
36 | + $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
|
37 | + } |
|
38 | + |
|
39 | + if (! empty($input['identifier'])) { |
|
40 | + $args['VNU_identifier'] = sanitize_title($input['identifier']); |
|
41 | + } |
|
42 | + |
|
43 | + if (! empty($input['created'])) { |
|
44 | + $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['order'])) { |
|
48 | + $args['VNU_order'] = absint($input['order']); |
|
49 | + } |
|
50 | + |
|
51 | + if (! empty($input['wpUser'])) { |
|
52 | + $args['VNU_wp_user'] = absint($input['wpUser']); |
|
53 | + } |
|
54 | + |
|
55 | + if (! empty($input['address'])) { |
|
56 | + $args['VNU_address'] = sanitize_text_field($input['address']); |
|
57 | + } |
|
58 | + |
|
59 | + if (! empty($input['address2'])) { |
|
60 | + $args['VNU_address2'] = sanitize_text_field($input['address2']); |
|
61 | + } |
|
62 | + |
|
63 | + if (! empty($input['city'])) { |
|
64 | + $args['VNU_city'] = sanitize_text_field($input['city']); |
|
65 | + } |
|
66 | + |
|
67 | + if (! empty($input['state'])) { |
|
68 | + $args['STA_ID'] = absint($input['state']); |
|
69 | + } |
|
70 | + |
|
71 | + if (! empty($input['country'])) { |
|
72 | + $args['CNT_ISO'] = sanitize_text_field($input['country']); |
|
73 | + } |
|
74 | + |
|
75 | + if (! empty($input['zip'])) { |
|
76 | + $args['VNU_zip'] = sanitize_text_field($input['zip']); |
|
77 | + } |
|
78 | + |
|
79 | + if (! empty($input['capacity'])) { |
|
80 | + $args['VNU_capacity'] = absint($input['capacity']); |
|
81 | + } |
|
82 | + |
|
83 | + if (! empty($input['phone'])) { |
|
84 | + $args['VNU_phone'] = sanitize_text_field($input['phone']); |
|
85 | + } |
|
86 | + |
|
87 | + if (! empty($input['virtualPhone'])) { |
|
88 | + $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
|
89 | + } |
|
90 | + |
|
91 | + if (! empty($input['url'])) { |
|
92 | + $args['VNU_url'] = sanitize_text_field($input['url']); |
|
93 | + } |
|
94 | + |
|
95 | + if (! empty($input['virtualUrl'])) { |
|
96 | + $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
|
97 | + } |
|
98 | + |
|
99 | + if (! empty($input['googleMapLink'])) { |
|
100 | + $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
|
101 | + } |
|
102 | + |
|
103 | + if (! empty($input['enableForGmap'])) { |
|
104 | + $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
|
105 | + } |
|
106 | + |
|
107 | + return apply_filters( |
|
108 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
109 | + $args, |
|
110 | + $input |
|
111 | + ); |
|
112 | + } |
|
113 | 113 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct(EEM_State $state_model) |
29 | 29 | { |
30 | - $this->setName($this->namespace . 'State'); |
|
30 | + $this->setName($this->namespace.'State'); |
|
31 | 31 | $this->setDescription(__('A state', 'event_espresso')); |
32 | 32 | $this->setIsCustomPostType(false); |
33 | 33 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ), |
80 | 80 | new GraphQLOutputField( |
81 | 81 | 'country', |
82 | - $this->namespace . 'Country', |
|
82 | + $this->namespace.'Country', |
|
83 | 83 | null, |
84 | 84 | esc_html__('Country for the state', 'event_espresso') |
85 | 85 | ), |
@@ -20,82 +20,82 @@ |
||
20 | 20 | */ |
21 | 21 | class State extends TypeBase |
22 | 22 | { |
23 | - /** |
|
24 | - * State constructor. |
|
25 | - * |
|
26 | - * @param EEM_State $state_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_State $state_model) |
|
29 | - { |
|
30 | - $this->setName($this->namespace . 'State'); |
|
31 | - $this->setDescription(__('A state', 'event_espresso')); |
|
32 | - $this->setIsCustomPostType(false); |
|
23 | + /** |
|
24 | + * State constructor. |
|
25 | + * |
|
26 | + * @param EEM_State $state_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_State $state_model) |
|
29 | + { |
|
30 | + $this->setName($this->namespace . 'State'); |
|
31 | + $this->setDescription(__('A state', 'event_espresso')); |
|
32 | + $this->setIsCustomPostType(false); |
|
33 | 33 | |
34 | - parent::__construct($state_model); |
|
35 | - } |
|
34 | + parent::__construct($state_model); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - */ |
|
41 | - public function getFields(): array |
|
42 | - { |
|
43 | - $fields = [ |
|
44 | - new GraphQLField( |
|
45 | - 'id', |
|
46 | - ['non_null' => 'ID'], |
|
47 | - null, |
|
48 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
49 | - ), |
|
50 | - new GraphQLOutputField( |
|
51 | - 'dbId', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('State ID', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'abbreviation', |
|
58 | - 'String', |
|
59 | - 'abbrev', |
|
60 | - esc_html__('State Abbreviation', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLOutputField( |
|
63 | - 'cacheId', |
|
64 | - ['non_null' => 'String'], |
|
65 | - null, |
|
66 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'name', |
|
70 | - 'String', |
|
71 | - 'name', |
|
72 | - esc_html__('State Name', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'isActive', |
|
76 | - 'Boolean', |
|
77 | - 'active', |
|
78 | - esc_html__('State Active Flag', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLOutputField( |
|
81 | - 'country', |
|
82 | - $this->namespace . 'Country', |
|
83 | - null, |
|
84 | - esc_html__('Country for the state', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLInputField( |
|
87 | - 'country', |
|
88 | - 'String', |
|
89 | - null, |
|
90 | - esc_html__('Country ISO Code', 'event_espresso') |
|
91 | - ), |
|
92 | - ]; |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + */ |
|
41 | + public function getFields(): array |
|
42 | + { |
|
43 | + $fields = [ |
|
44 | + new GraphQLField( |
|
45 | + 'id', |
|
46 | + ['non_null' => 'ID'], |
|
47 | + null, |
|
48 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
49 | + ), |
|
50 | + new GraphQLOutputField( |
|
51 | + 'dbId', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('State ID', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'abbreviation', |
|
58 | + 'String', |
|
59 | + 'abbrev', |
|
60 | + esc_html__('State Abbreviation', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLOutputField( |
|
63 | + 'cacheId', |
|
64 | + ['non_null' => 'String'], |
|
65 | + null, |
|
66 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'name', |
|
70 | + 'String', |
|
71 | + 'name', |
|
72 | + esc_html__('State Name', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'isActive', |
|
76 | + 'Boolean', |
|
77 | + 'active', |
|
78 | + esc_html__('State Active Flag', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLOutputField( |
|
81 | + 'country', |
|
82 | + $this->namespace . 'Country', |
|
83 | + null, |
|
84 | + esc_html__('Country for the state', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLInputField( |
|
87 | + 'country', |
|
88 | + 'String', |
|
89 | + null, |
|
90 | + esc_html__('Country ISO Code', 'event_espresso') |
|
91 | + ), |
|
92 | + ]; |
|
93 | 93 | |
94 | - return apply_filters( |
|
95 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__state_fields', |
|
96 | - $fields, |
|
97 | - $this->name, |
|
98 | - $this->model |
|
99 | - ); |
|
100 | - } |
|
94 | + return apply_filters( |
|
95 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__state_fields', |
|
96 | + $fields, |
|
97 | + $this->name, |
|
98 | + $this->model |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct(EEM_Ticket $ticket_model) |
43 | 43 | { |
44 | - $this->setName($this->namespace . 'Ticket'); |
|
44 | + $this->setName($this->namespace.'Ticket'); |
|
45 | 45 | $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
46 | 46 | $this->setIsCustomPostType(false); |
47 | 47 | parent::__construct($ticket_model); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ), |
98 | 98 | new GraphQLOutputField( |
99 | 99 | 'event', |
100 | - $this->namespace . 'Event', |
|
100 | + $this->namespace.'Event', |
|
101 | 101 | null, |
102 | 102 | esc_html__('Event of the ticket.', 'event_espresso') |
103 | 103 | ), |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ), |
265 | 265 | new GraphQLOutputField( |
266 | 266 | 'status', |
267 | - $this->namespace . 'TicketStatusEnum', |
|
267 | + $this->namespace.'TicketStatusEnum', |
|
268 | 268 | 'ticket_status', |
269 | 269 | esc_html__('Ticket status', 'event_espresso') |
270 | 270 | ), |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | ), |
285 | 285 | new GraphQLField( |
286 | 286 | 'visibility', |
287 | - $this->namespace . 'TicketVisibilityEnum', |
|
287 | + $this->namespace.'TicketVisibilityEnum', |
|
288 | 288 | 'visibility', |
289 | 289 | esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
290 | 290 | ), |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function registerMutations(array $inputFields) |
348 | 348 | { |
349 | 349 | register_graphql_input_type( |
350 | - 'Update' . $this->name() . 'BaseInput', |
|
350 | + 'Update'.$this->name().'BaseInput', |
|
351 | 351 | [ |
352 | 352 | 'fields' => $inputFields, |
353 | 353 | ] |
354 | 354 | ); |
355 | 355 | // Register mutation to update an entity. |
356 | 356 | register_graphql_mutation( |
357 | - 'update' . $this->name(), |
|
357 | + 'update'.$this->name(), |
|
358 | 358 | [ |
359 | 359 | 'inputFields' => $inputFields, |
360 | 360 | 'outputFields' => [ |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
367 | 367 | ] |
368 | 368 | ); |
369 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
369 | + $base_input = 'Update'.$this->name().'BaseInput'; |
|
370 | 370 | // Register mutation to update an entity. |
371 | 371 | register_graphql_mutation( |
372 | - 'bulkUpdate' . $this->name(), |
|
372 | + 'bulkUpdate'.$this->name(), |
|
373 | 373 | array_merge( |
374 | 374 | Datetime::bulkUpdateBaseConfig($base_input), |
375 | 375 | [ |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ); |
380 | 380 | // Register mutation to delete an entity. |
381 | 381 | register_graphql_mutation( |
382 | - 'delete' . $this->name(), |
|
382 | + 'delete'.$this->name(), |
|
383 | 383 | [ |
384 | 384 | 'inputFields' => [ |
385 | 385 | 'id' => $inputFields['id'], |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | lcfirst($this->name()) => [ |
393 | 393 | 'type' => $this->name(), |
394 | 394 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
395 | - 'resolve' => static function ($payload) { |
|
395 | + 'resolve' => static function($payload) { |
|
396 | 396 | $deleted = (object) $payload['deleted']; |
397 | 397 | |
398 | 398 | return ! empty($deleted) ? $deleted : null; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | unset($inputFields['id']); |
408 | 408 | // Register mutation to update an entity. |
409 | 409 | register_graphql_mutation( |
410 | - 'create' . $this->name(), |
|
410 | + 'create'.$this->name(), |
|
411 | 411 | [ |
412 | 412 | 'inputFields' => $inputFields, |
413 | 413 | 'outputFields' => [ |
@@ -35,421 +35,421 @@ |
||
35 | 35 | */ |
36 | 36 | class Ticket extends TypeBase |
37 | 37 | { |
38 | - /** |
|
39 | - * Ticket constructor. |
|
40 | - * |
|
41 | - * @param EEM_Ticket $ticket_model |
|
42 | - */ |
|
43 | - public function __construct(EEM_Ticket $ticket_model) |
|
44 | - { |
|
45 | - $this->setName($this->namespace . 'Ticket'); |
|
46 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
47 | - $this->setIsCustomPostType(false); |
|
48 | - parent::__construct($ticket_model); |
|
49 | - } |
|
38 | + /** |
|
39 | + * Ticket constructor. |
|
40 | + * |
|
41 | + * @param EEM_Ticket $ticket_model |
|
42 | + */ |
|
43 | + public function __construct(EEM_Ticket $ticket_model) |
|
44 | + { |
|
45 | + $this->setName($this->namespace . 'Ticket'); |
|
46 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
47 | + $this->setIsCustomPostType(false); |
|
48 | + parent::__construct($ticket_model); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return GraphQLFieldInterface[] |
|
54 | - */ |
|
55 | - public function getFields(): array |
|
56 | - { |
|
57 | - $fields = [ |
|
58 | - new GraphQLField( |
|
59 | - 'id', |
|
60 | - ['non_null' => 'ID'], |
|
61 | - null, |
|
62 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLOutputField( |
|
65 | - 'dbId', |
|
66 | - ['non_null' => 'Int'], |
|
67 | - 'ID', |
|
68 | - esc_html__('Ticket ID', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLOutputField( |
|
71 | - 'cacheId', |
|
72 | - ['non_null' => 'String'], |
|
73 | - null, |
|
74 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLInputField( |
|
77 | - 'datetimes', |
|
78 | - ['list_of' => 'ID'], |
|
79 | - null, |
|
80 | - sprintf( |
|
81 | - '%1$s %2$s', |
|
82 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
83 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
84 | - ) |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'description', |
|
88 | - 'String', |
|
89 | - 'description', |
|
90 | - esc_html__('Description of Ticket', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'endDate', |
|
94 | - 'String', |
|
95 | - 'end_date', |
|
96 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
97 | - [$this, 'formatDatetime'] |
|
98 | - ), |
|
99 | - new GraphQLOutputField( |
|
100 | - 'event', |
|
101 | - $this->namespace . 'Event', |
|
102 | - null, |
|
103 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'isDefault', |
|
107 | - 'Boolean', |
|
108 | - 'is_default', |
|
109 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLOutputField( |
|
112 | - 'isExpired', |
|
113 | - 'Boolean', |
|
114 | - 'is_expired', |
|
115 | - esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLOutputField( |
|
118 | - 'isFree', |
|
119 | - 'Boolean', |
|
120 | - 'is_free', |
|
121 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLOutputField( |
|
124 | - 'isOnSale', |
|
125 | - 'Boolean', |
|
126 | - 'is_on_sale', |
|
127 | - esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLOutputField( |
|
130 | - 'isPending', |
|
131 | - 'Boolean', |
|
132 | - 'is_pending', |
|
133 | - esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLField( |
|
136 | - 'isRequired', |
|
137 | - 'Boolean', |
|
138 | - 'required', |
|
139 | - esc_html__( |
|
140 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ), |
|
144 | - new GraphQLOutputField( |
|
145 | - 'isSoldOut', |
|
146 | - 'Boolean', |
|
147 | - null, |
|
148 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
149 | - null, |
|
150 | - [$this, 'getIsSoldOut'] |
|
151 | - ), |
|
152 | - new GraphQLField( |
|
153 | - 'isTaxable', |
|
154 | - 'Boolean', |
|
155 | - 'taxable', |
|
156 | - esc_html__( |
|
157 | - 'Flag indicating whether there is tax applied on this ticket', |
|
158 | - 'event_espresso' |
|
159 | - ) |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'isTrashed', |
|
163 | - 'Boolean', |
|
164 | - 'deleted', |
|
165 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLField( |
|
168 | - 'max', |
|
169 | - 'Int', |
|
170 | - 'max', |
|
171 | - esc_html__( |
|
172 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
173 | - 'event_espresso' |
|
174 | - ), |
|
175 | - [$this, 'parseInfiniteValue'] |
|
176 | - ), |
|
177 | - new GraphQLField( |
|
178 | - 'min', |
|
179 | - 'Int', |
|
180 | - 'min', |
|
181 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLField( |
|
184 | - 'name', |
|
185 | - 'String', |
|
186 | - 'name', |
|
187 | - esc_html__('Ticket Name', 'event_espresso') |
|
188 | - ), |
|
189 | - new GraphQLField( |
|
190 | - 'order', |
|
191 | - 'Int', |
|
192 | - 'order', |
|
193 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
194 | - ), |
|
195 | - new GraphQLOutputField( |
|
196 | - 'parent', |
|
197 | - $this->name(), |
|
198 | - null, |
|
199 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | - ), |
|
201 | - new GraphQLInputField( |
|
202 | - 'parent', |
|
203 | - 'ID', |
|
204 | - null, |
|
205 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLField( |
|
208 | - 'price', |
|
209 | - 'Float', |
|
210 | - 'price', |
|
211 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
212 | - ), |
|
213 | - new GraphQLInputField( |
|
214 | - 'prices', |
|
215 | - ['list_of' => 'ID'], |
|
216 | - null, |
|
217 | - sprintf( |
|
218 | - '%1$s %2$s', |
|
219 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
220 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | - ) |
|
222 | - ), |
|
223 | - new GraphQLField( |
|
224 | - 'quantity', |
|
225 | - 'Int', |
|
226 | - 'qty', |
|
227 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
228 | - [$this, 'parseInfiniteValue'] |
|
229 | - ), |
|
230 | - new GraphQLOutputField( |
|
231 | - 'registrationCount', |
|
232 | - 'Int', |
|
233 | - null, |
|
234 | - esc_html__('Number of registrations for the ticket', 'event_espresso'), |
|
235 | - null, |
|
236 | - [$this, 'getRegistrationCount'] |
|
237 | - ), |
|
238 | - new GraphQLField( |
|
239 | - 'reserved', |
|
240 | - 'Int', |
|
241 | - 'reserved', |
|
242 | - esc_html__( |
|
243 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
244 | - 'event_espresso' |
|
245 | - ) |
|
246 | - ), |
|
247 | - new GraphQLField( |
|
248 | - 'reverseCalculate', |
|
249 | - 'Boolean', |
|
250 | - 'reverse_calculate', |
|
251 | - esc_html__( |
|
252 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
253 | - 'event_espresso' |
|
254 | - ) |
|
255 | - ), |
|
256 | - new GraphQLField( |
|
257 | - 'row', |
|
258 | - 'Int', |
|
259 | - 'row', |
|
260 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
261 | - ), |
|
262 | - new GraphQLField( |
|
263 | - 'sold', |
|
264 | - 'Int', |
|
265 | - 'sold', |
|
266 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
267 | - ), |
|
268 | - new GraphQLOutputField( |
|
269 | - 'status', |
|
270 | - $this->namespace . 'TicketStatusEnum', |
|
271 | - 'ticket_status', |
|
272 | - esc_html__('Ticket status', 'event_espresso') |
|
273 | - ), |
|
274 | - new GraphQLField( |
|
275 | - 'startDate', |
|
276 | - 'String', |
|
277 | - 'start_date', |
|
278 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
279 | - [$this, 'formatDatetime'] |
|
280 | - ), |
|
281 | - new GraphQLField( |
|
282 | - 'uses', |
|
283 | - 'Int', |
|
284 | - 'uses', |
|
285 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
286 | - [$this, 'parseInfiniteValue'] |
|
287 | - ), |
|
288 | - new GraphQLField( |
|
289 | - 'visibility', |
|
290 | - $this->namespace . 'TicketVisibilityEnum', |
|
291 | - 'visibility', |
|
292 | - esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
293 | - ), |
|
294 | - new GraphQLOutputField( |
|
295 | - 'wpUser', |
|
296 | - 'User', |
|
297 | - null, |
|
298 | - esc_html__('Ticket Creator', 'event_espresso') |
|
299 | - ), |
|
300 | - new GraphQLOutputField( |
|
301 | - 'userId', |
|
302 | - 'ID', |
|
303 | - null, |
|
304 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
305 | - ), |
|
306 | - new GraphQLInputField( |
|
307 | - 'wpUser', |
|
308 | - 'Int', |
|
309 | - null, |
|
310 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
311 | - ), |
|
312 | - ]; |
|
52 | + /** |
|
53 | + * @return GraphQLFieldInterface[] |
|
54 | + */ |
|
55 | + public function getFields(): array |
|
56 | + { |
|
57 | + $fields = [ |
|
58 | + new GraphQLField( |
|
59 | + 'id', |
|
60 | + ['non_null' => 'ID'], |
|
61 | + null, |
|
62 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLOutputField( |
|
65 | + 'dbId', |
|
66 | + ['non_null' => 'Int'], |
|
67 | + 'ID', |
|
68 | + esc_html__('Ticket ID', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLOutputField( |
|
71 | + 'cacheId', |
|
72 | + ['non_null' => 'String'], |
|
73 | + null, |
|
74 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLInputField( |
|
77 | + 'datetimes', |
|
78 | + ['list_of' => 'ID'], |
|
79 | + null, |
|
80 | + sprintf( |
|
81 | + '%1$s %2$s', |
|
82 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
83 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
84 | + ) |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'description', |
|
88 | + 'String', |
|
89 | + 'description', |
|
90 | + esc_html__('Description of Ticket', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'endDate', |
|
94 | + 'String', |
|
95 | + 'end_date', |
|
96 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
97 | + [$this, 'formatDatetime'] |
|
98 | + ), |
|
99 | + new GraphQLOutputField( |
|
100 | + 'event', |
|
101 | + $this->namespace . 'Event', |
|
102 | + null, |
|
103 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'isDefault', |
|
107 | + 'Boolean', |
|
108 | + 'is_default', |
|
109 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLOutputField( |
|
112 | + 'isExpired', |
|
113 | + 'Boolean', |
|
114 | + 'is_expired', |
|
115 | + esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLOutputField( |
|
118 | + 'isFree', |
|
119 | + 'Boolean', |
|
120 | + 'is_free', |
|
121 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLOutputField( |
|
124 | + 'isOnSale', |
|
125 | + 'Boolean', |
|
126 | + 'is_on_sale', |
|
127 | + esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLOutputField( |
|
130 | + 'isPending', |
|
131 | + 'Boolean', |
|
132 | + 'is_pending', |
|
133 | + esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLField( |
|
136 | + 'isRequired', |
|
137 | + 'Boolean', |
|
138 | + 'required', |
|
139 | + esc_html__( |
|
140 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ), |
|
144 | + new GraphQLOutputField( |
|
145 | + 'isSoldOut', |
|
146 | + 'Boolean', |
|
147 | + null, |
|
148 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
149 | + null, |
|
150 | + [$this, 'getIsSoldOut'] |
|
151 | + ), |
|
152 | + new GraphQLField( |
|
153 | + 'isTaxable', |
|
154 | + 'Boolean', |
|
155 | + 'taxable', |
|
156 | + esc_html__( |
|
157 | + 'Flag indicating whether there is tax applied on this ticket', |
|
158 | + 'event_espresso' |
|
159 | + ) |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'isTrashed', |
|
163 | + 'Boolean', |
|
164 | + 'deleted', |
|
165 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLField( |
|
168 | + 'max', |
|
169 | + 'Int', |
|
170 | + 'max', |
|
171 | + esc_html__( |
|
172 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
173 | + 'event_espresso' |
|
174 | + ), |
|
175 | + [$this, 'parseInfiniteValue'] |
|
176 | + ), |
|
177 | + new GraphQLField( |
|
178 | + 'min', |
|
179 | + 'Int', |
|
180 | + 'min', |
|
181 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLField( |
|
184 | + 'name', |
|
185 | + 'String', |
|
186 | + 'name', |
|
187 | + esc_html__('Ticket Name', 'event_espresso') |
|
188 | + ), |
|
189 | + new GraphQLField( |
|
190 | + 'order', |
|
191 | + 'Int', |
|
192 | + 'order', |
|
193 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
194 | + ), |
|
195 | + new GraphQLOutputField( |
|
196 | + 'parent', |
|
197 | + $this->name(), |
|
198 | + null, |
|
199 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | + ), |
|
201 | + new GraphQLInputField( |
|
202 | + 'parent', |
|
203 | + 'ID', |
|
204 | + null, |
|
205 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLField( |
|
208 | + 'price', |
|
209 | + 'Float', |
|
210 | + 'price', |
|
211 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
212 | + ), |
|
213 | + new GraphQLInputField( |
|
214 | + 'prices', |
|
215 | + ['list_of' => 'ID'], |
|
216 | + null, |
|
217 | + sprintf( |
|
218 | + '%1$s %2$s', |
|
219 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
220 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | + ) |
|
222 | + ), |
|
223 | + new GraphQLField( |
|
224 | + 'quantity', |
|
225 | + 'Int', |
|
226 | + 'qty', |
|
227 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
228 | + [$this, 'parseInfiniteValue'] |
|
229 | + ), |
|
230 | + new GraphQLOutputField( |
|
231 | + 'registrationCount', |
|
232 | + 'Int', |
|
233 | + null, |
|
234 | + esc_html__('Number of registrations for the ticket', 'event_espresso'), |
|
235 | + null, |
|
236 | + [$this, 'getRegistrationCount'] |
|
237 | + ), |
|
238 | + new GraphQLField( |
|
239 | + 'reserved', |
|
240 | + 'Int', |
|
241 | + 'reserved', |
|
242 | + esc_html__( |
|
243 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
244 | + 'event_espresso' |
|
245 | + ) |
|
246 | + ), |
|
247 | + new GraphQLField( |
|
248 | + 'reverseCalculate', |
|
249 | + 'Boolean', |
|
250 | + 'reverse_calculate', |
|
251 | + esc_html__( |
|
252 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
253 | + 'event_espresso' |
|
254 | + ) |
|
255 | + ), |
|
256 | + new GraphQLField( |
|
257 | + 'row', |
|
258 | + 'Int', |
|
259 | + 'row', |
|
260 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
261 | + ), |
|
262 | + new GraphQLField( |
|
263 | + 'sold', |
|
264 | + 'Int', |
|
265 | + 'sold', |
|
266 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
267 | + ), |
|
268 | + new GraphQLOutputField( |
|
269 | + 'status', |
|
270 | + $this->namespace . 'TicketStatusEnum', |
|
271 | + 'ticket_status', |
|
272 | + esc_html__('Ticket status', 'event_espresso') |
|
273 | + ), |
|
274 | + new GraphQLField( |
|
275 | + 'startDate', |
|
276 | + 'String', |
|
277 | + 'start_date', |
|
278 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
279 | + [$this, 'formatDatetime'] |
|
280 | + ), |
|
281 | + new GraphQLField( |
|
282 | + 'uses', |
|
283 | + 'Int', |
|
284 | + 'uses', |
|
285 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
286 | + [$this, 'parseInfiniteValue'] |
|
287 | + ), |
|
288 | + new GraphQLField( |
|
289 | + 'visibility', |
|
290 | + $this->namespace . 'TicketVisibilityEnum', |
|
291 | + 'visibility', |
|
292 | + esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
293 | + ), |
|
294 | + new GraphQLOutputField( |
|
295 | + 'wpUser', |
|
296 | + 'User', |
|
297 | + null, |
|
298 | + esc_html__('Ticket Creator', 'event_espresso') |
|
299 | + ), |
|
300 | + new GraphQLOutputField( |
|
301 | + 'userId', |
|
302 | + 'ID', |
|
303 | + null, |
|
304 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
305 | + ), |
|
306 | + new GraphQLInputField( |
|
307 | + 'wpUser', |
|
308 | + 'Int', |
|
309 | + null, |
|
310 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
311 | + ), |
|
312 | + ]; |
|
313 | 313 | |
314 | - return apply_filters( |
|
315 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
316 | - $fields, |
|
317 | - $this->name, |
|
318 | - $this->model |
|
319 | - ); |
|
320 | - } |
|
314 | + return apply_filters( |
|
315 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
316 | + $fields, |
|
317 | + $this->name, |
|
318 | + $this->model |
|
319 | + ); |
|
320 | + } |
|
321 | 321 | |
322 | 322 | |
323 | - /** |
|
324 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
325 | - * @param array $args The inputArgs on the field |
|
326 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
327 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
328 | - * @return bool |
|
329 | - * @throws Exception |
|
330 | - * @throws InvalidArgumentException |
|
331 | - * @throws InvalidDataTypeException |
|
332 | - * @throws InvalidInterfaceException |
|
333 | - * @throws ReflectionException |
|
334 | - * @throws UserError |
|
335 | - * @throws UnexpectedEntityException |
|
336 | - * @since 5.0.0.p |
|
337 | - */ |
|
338 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
339 | - { |
|
340 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
341 | - } |
|
323 | + /** |
|
324 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
325 | + * @param array $args The inputArgs on the field |
|
326 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
327 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
328 | + * @return bool |
|
329 | + * @throws Exception |
|
330 | + * @throws InvalidArgumentException |
|
331 | + * @throws InvalidDataTypeException |
|
332 | + * @throws InvalidInterfaceException |
|
333 | + * @throws ReflectionException |
|
334 | + * @throws UserError |
|
335 | + * @throws UnexpectedEntityException |
|
336 | + * @since 5.0.0.p |
|
337 | + */ |
|
338 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
339 | + { |
|
340 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
341 | + } |
|
342 | 342 | |
343 | 343 | |
344 | - /** |
|
345 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
346 | - * @param array $args The inputArgs on the field |
|
347 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
348 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
349 | - * @return bool |
|
350 | - * @throws Exception |
|
351 | - * @throws InvalidArgumentException |
|
352 | - * @throws InvalidDataTypeException |
|
353 | - * @throws InvalidInterfaceException |
|
354 | - * @throws ReflectionException |
|
355 | - * @throws UserError |
|
356 | - * @throws UnexpectedEntityException |
|
357 | - * @since 5.0.0.p |
|
358 | - */ |
|
359 | - public function getRegistrationCount(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): int |
|
360 | - { |
|
361 | - $active_reg_statuses = EEM_Registration::active_reg_statuses(); |
|
362 | - return $source->count_registrations( |
|
363 | - [ |
|
364 | - [ |
|
365 | - 'STS_ID' => ['IN', $active_reg_statuses], |
|
366 | - 'REG_deleted' => 0, |
|
367 | - ] |
|
368 | - ] |
|
369 | - ); |
|
370 | - } |
|
344 | + /** |
|
345 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
346 | + * @param array $args The inputArgs on the field |
|
347 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
348 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
349 | + * @return bool |
|
350 | + * @throws Exception |
|
351 | + * @throws InvalidArgumentException |
|
352 | + * @throws InvalidDataTypeException |
|
353 | + * @throws InvalidInterfaceException |
|
354 | + * @throws ReflectionException |
|
355 | + * @throws UserError |
|
356 | + * @throws UnexpectedEntityException |
|
357 | + * @since 5.0.0.p |
|
358 | + */ |
|
359 | + public function getRegistrationCount(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): int |
|
360 | + { |
|
361 | + $active_reg_statuses = EEM_Registration::active_reg_statuses(); |
|
362 | + return $source->count_registrations( |
|
363 | + [ |
|
364 | + [ |
|
365 | + 'STS_ID' => ['IN', $active_reg_statuses], |
|
366 | + 'REG_deleted' => 0, |
|
367 | + ] |
|
368 | + ] |
|
369 | + ); |
|
370 | + } |
|
371 | 371 | |
372 | 372 | |
373 | - /** |
|
374 | - * @param array $inputFields The mutation input fields. |
|
375 | - * @throws InvalidArgumentException |
|
376 | - * @throws ReflectionException |
|
377 | - * @throws Exception |
|
378 | - */ |
|
379 | - public function registerMutations(array $inputFields) |
|
380 | - { |
|
381 | - register_graphql_input_type( |
|
382 | - 'Update' . $this->name() . 'BaseInput', |
|
383 | - [ |
|
384 | - 'fields' => $inputFields, |
|
385 | - ] |
|
386 | - ); |
|
387 | - // Register mutation to update an entity. |
|
388 | - register_graphql_mutation( |
|
389 | - 'update' . $this->name(), |
|
390 | - [ |
|
391 | - 'inputFields' => $inputFields, |
|
392 | - 'outputFields' => [ |
|
393 | - lcfirst($this->name()) => [ |
|
394 | - 'type' => $this->name(), |
|
395 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
396 | - ], |
|
397 | - ], |
|
398 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
399 | - ] |
|
400 | - ); |
|
401 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
402 | - // Register mutation to update an entity. |
|
403 | - register_graphql_mutation( |
|
404 | - 'bulkUpdate' . $this->name(), |
|
405 | - array_merge( |
|
406 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
407 | - [ |
|
408 | - 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
409 | - ] |
|
410 | - ) |
|
411 | - ); |
|
412 | - // Register mutation to delete an entity. |
|
413 | - register_graphql_mutation( |
|
414 | - 'delete' . $this->name(), |
|
415 | - [ |
|
416 | - 'inputFields' => [ |
|
417 | - 'id' => $inputFields['id'], |
|
418 | - 'deletePermanently' => [ |
|
419 | - 'type' => 'Boolean', |
|
420 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
421 | - ], |
|
422 | - ], |
|
423 | - 'outputFields' => [ |
|
424 | - lcfirst($this->name()) => [ |
|
425 | - 'type' => $this->name(), |
|
426 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
427 | - 'resolve' => static function ($payload) { |
|
428 | - $deleted = (object) $payload['deleted']; |
|
373 | + /** |
|
374 | + * @param array $inputFields The mutation input fields. |
|
375 | + * @throws InvalidArgumentException |
|
376 | + * @throws ReflectionException |
|
377 | + * @throws Exception |
|
378 | + */ |
|
379 | + public function registerMutations(array $inputFields) |
|
380 | + { |
|
381 | + register_graphql_input_type( |
|
382 | + 'Update' . $this->name() . 'BaseInput', |
|
383 | + [ |
|
384 | + 'fields' => $inputFields, |
|
385 | + ] |
|
386 | + ); |
|
387 | + // Register mutation to update an entity. |
|
388 | + register_graphql_mutation( |
|
389 | + 'update' . $this->name(), |
|
390 | + [ |
|
391 | + 'inputFields' => $inputFields, |
|
392 | + 'outputFields' => [ |
|
393 | + lcfirst($this->name()) => [ |
|
394 | + 'type' => $this->name(), |
|
395 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
396 | + ], |
|
397 | + ], |
|
398 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
399 | + ] |
|
400 | + ); |
|
401 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
402 | + // Register mutation to update an entity. |
|
403 | + register_graphql_mutation( |
|
404 | + 'bulkUpdate' . $this->name(), |
|
405 | + array_merge( |
|
406 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
407 | + [ |
|
408 | + 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
409 | + ] |
|
410 | + ) |
|
411 | + ); |
|
412 | + // Register mutation to delete an entity. |
|
413 | + register_graphql_mutation( |
|
414 | + 'delete' . $this->name(), |
|
415 | + [ |
|
416 | + 'inputFields' => [ |
|
417 | + 'id' => $inputFields['id'], |
|
418 | + 'deletePermanently' => [ |
|
419 | + 'type' => 'Boolean', |
|
420 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
421 | + ], |
|
422 | + ], |
|
423 | + 'outputFields' => [ |
|
424 | + lcfirst($this->name()) => [ |
|
425 | + 'type' => $this->name(), |
|
426 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
427 | + 'resolve' => static function ($payload) { |
|
428 | + $deleted = (object) $payload['deleted']; |
|
429 | 429 | |
430 | - return ! empty($deleted) ? $deleted : null; |
|
431 | - }, |
|
432 | - ], |
|
433 | - ], |
|
434 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
435 | - ] |
|
436 | - ); |
|
430 | + return ! empty($deleted) ? $deleted : null; |
|
431 | + }, |
|
432 | + ], |
|
433 | + ], |
|
434 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
435 | + ] |
|
436 | + ); |
|
437 | 437 | |
438 | - // remove primary key from input. |
|
439 | - unset($inputFields['id']); |
|
440 | - // Register mutation to update an entity. |
|
441 | - register_graphql_mutation( |
|
442 | - 'create' . $this->name(), |
|
443 | - [ |
|
444 | - 'inputFields' => $inputFields, |
|
445 | - 'outputFields' => [ |
|
446 | - lcfirst($this->name()) => [ |
|
447 | - 'type' => $this->name(), |
|
448 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
449 | - ], |
|
450 | - ], |
|
451 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
452 | - ] |
|
453 | - ); |
|
454 | - } |
|
438 | + // remove primary key from input. |
|
439 | + unset($inputFields['id']); |
|
440 | + // Register mutation to update an entity. |
|
441 | + register_graphql_mutation( |
|
442 | + 'create' . $this->name(), |
|
443 | + [ |
|
444 | + 'inputFields' => $inputFields, |
|
445 | + 'outputFields' => [ |
|
446 | + lcfirst($this->name()) => [ |
|
447 | + 'type' => $this->name(), |
|
448 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
449 | + ], |
|
450 | + ], |
|
451 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
452 | + ] |
|
453 | + ); |
|
454 | + } |
|
455 | 455 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(EEM_Price $price_model) |
35 | 35 | { |
36 | - $this->setName($this->namespace . 'Price'); |
|
36 | + $this->setName($this->namespace.'Price'); |
|
37 | 37 | $this->setDescription(__('A price.', 'event_espresso')); |
38 | 38 | $this->setIsCustomPostType(false); |
39 | 39 | parent::__construct($price_model); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | ), |
146 | 146 | new GraphQLOutputField( |
147 | 147 | 'priceType', |
148 | - $this->namespace . 'PriceType', |
|
148 | + $this->namespace.'PriceType', |
|
149 | 149 | 'type_obj', |
150 | 150 | esc_html__('The related price type object.', 'event_espresso') |
151 | 151 | ), |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | { |
196 | 196 | // Register mutation to update an entity. |
197 | 197 | register_graphql_mutation( |
198 | - 'update' . $this->name(), |
|
198 | + 'update'.$this->name(), |
|
199 | 199 | [ |
200 | 200 | 'inputFields' => $inputFields, |
201 | 201 | 'outputFields' => [ |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ); |
210 | 210 | // Register mutation to delete an entity. |
211 | 211 | register_graphql_mutation( |
212 | - 'delete' . $this->name(), |
|
212 | + 'delete'.$this->name(), |
|
213 | 213 | [ |
214 | 214 | 'inputFields' => [ |
215 | 215 | 'id' => $inputFields['id'], |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | lcfirst($this->name()) => [ |
223 | 223 | 'type' => $this->name(), |
224 | 224 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
225 | - 'resolve' => static function ($payload) { |
|
225 | + 'resolve' => static function($payload) { |
|
226 | 226 | $deleted = (object) $payload['deleted']; |
227 | 227 | |
228 | 228 | return ! empty($deleted) ? $deleted : null; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | unset($inputFields['id']); |
238 | 238 | // Register mutation to update an entity. |
239 | 239 | register_graphql_mutation( |
240 | - 'create' . $this->name(), |
|
240 | + 'create'.$this->name(), |
|
241 | 241 | [ |
242 | 242 | 'inputFields' => $inputFields, |
243 | 243 | 'outputFields' => [ |
@@ -26,228 +26,228 @@ |
||
26 | 26 | */ |
27 | 27 | class Price extends TypeBase |
28 | 28 | { |
29 | - /** |
|
30 | - * Price constructor. |
|
31 | - * |
|
32 | - * @param EEM_Price $price_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Price $price_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'Price'); |
|
37 | - $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct($price_model); |
|
40 | - } |
|
29 | + /** |
|
30 | + * Price constructor. |
|
31 | + * |
|
32 | + * @param EEM_Price $price_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Price $price_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'Price'); |
|
37 | + $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct($price_model); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since 5.0.0.p |
|
46 | - */ |
|
47 | - public function getFields(): array |
|
48 | - { |
|
49 | - $fields = [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'ID'], |
|
53 | - null, |
|
54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLOutputField( |
|
57 | - 'dbId', |
|
58 | - ['non_null' => 'Int'], |
|
59 | - 'ID', |
|
60 | - esc_html__('Price ID', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'amount', |
|
64 | - 'Float', |
|
65 | - 'amount', |
|
66 | - esc_html__('Price Amount', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLOutputField( |
|
69 | - 'cacheId', |
|
70 | - ['non_null' => 'String'], |
|
71 | - null, |
|
72 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'description', |
|
76 | - 'String', |
|
77 | - 'desc', |
|
78 | - esc_html__('Price description', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLOutputField( |
|
81 | - 'isBasePrice', |
|
82 | - 'Boolean', |
|
83 | - 'is_base_price', |
|
84 | - esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'isDefault', |
|
88 | - 'Boolean', |
|
89 | - 'is_default', |
|
90 | - esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLOutputField( |
|
93 | - 'isDiscount', |
|
94 | - 'Boolean', |
|
95 | - 'is_discount', |
|
96 | - esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLOutputField( |
|
99 | - 'isPercent', |
|
100 | - 'Boolean', |
|
101 | - 'is_percent', |
|
102 | - esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLOutputField( |
|
105 | - 'isTax', |
|
106 | - 'Boolean', |
|
107 | - 'is_tax', |
|
108 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
109 | - ), |
|
110 | - new GraphQLField( |
|
111 | - 'isTrashed', |
|
112 | - 'Boolean', |
|
113 | - 'deleted', |
|
114 | - esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLField( |
|
117 | - 'name', |
|
118 | - 'String', |
|
119 | - 'name', |
|
120 | - esc_html__('Price Name', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLField( |
|
123 | - 'order', |
|
124 | - 'Int', |
|
125 | - 'order', |
|
126 | - esc_html__('Order of Application of Price.', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLField( |
|
129 | - 'overrides', |
|
130 | - 'Int', |
|
131 | - 'overrides', |
|
132 | - esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLOutputField( |
|
135 | - 'parent', |
|
136 | - $this->name(), |
|
137 | - null, |
|
138 | - esc_html__('The parent price of the current price', 'event_espresso') |
|
139 | - ), |
|
140 | - new GraphQLInputField( |
|
141 | - 'parent', |
|
142 | - 'ID', |
|
143 | - null, |
|
144 | - esc_html__('The parent price ID', 'event_espresso') |
|
145 | - ), |
|
146 | - new GraphQLOutputField( |
|
147 | - 'priceType', |
|
148 | - $this->namespace . 'PriceType', |
|
149 | - 'type_obj', |
|
150 | - esc_html__('The related price type object.', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLInputField( |
|
153 | - 'priceType', |
|
154 | - 'ID', |
|
155 | - null, |
|
156 | - esc_html__('The price type ID', 'event_espresso') |
|
157 | - ), |
|
158 | - new GraphQLOutputField( |
|
159 | - 'wpUser', |
|
160 | - 'User', |
|
161 | - null, |
|
162 | - esc_html__('Price Creator', 'event_espresso') |
|
163 | - ), |
|
164 | - new GraphQLOutputField( |
|
165 | - 'userId', |
|
166 | - 'ID', |
|
167 | - null, |
|
168 | - esc_html__('Price Creator ID', 'event_espresso') |
|
169 | - ), |
|
170 | - new GraphQLInputField( |
|
171 | - 'wpUser', |
|
172 | - 'Int', |
|
173 | - null, |
|
174 | - esc_html__('Price Creator ID', 'event_espresso') |
|
175 | - ), |
|
176 | - ]; |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since 5.0.0.p |
|
46 | + */ |
|
47 | + public function getFields(): array |
|
48 | + { |
|
49 | + $fields = [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'ID'], |
|
53 | + null, |
|
54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLOutputField( |
|
57 | + 'dbId', |
|
58 | + ['non_null' => 'Int'], |
|
59 | + 'ID', |
|
60 | + esc_html__('Price ID', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'amount', |
|
64 | + 'Float', |
|
65 | + 'amount', |
|
66 | + esc_html__('Price Amount', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLOutputField( |
|
69 | + 'cacheId', |
|
70 | + ['non_null' => 'String'], |
|
71 | + null, |
|
72 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'description', |
|
76 | + 'String', |
|
77 | + 'desc', |
|
78 | + esc_html__('Price description', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLOutputField( |
|
81 | + 'isBasePrice', |
|
82 | + 'Boolean', |
|
83 | + 'is_base_price', |
|
84 | + esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'isDefault', |
|
88 | + 'Boolean', |
|
89 | + 'is_default', |
|
90 | + esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLOutputField( |
|
93 | + 'isDiscount', |
|
94 | + 'Boolean', |
|
95 | + 'is_discount', |
|
96 | + esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLOutputField( |
|
99 | + 'isPercent', |
|
100 | + 'Boolean', |
|
101 | + 'is_percent', |
|
102 | + esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLOutputField( |
|
105 | + 'isTax', |
|
106 | + 'Boolean', |
|
107 | + 'is_tax', |
|
108 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
109 | + ), |
|
110 | + new GraphQLField( |
|
111 | + 'isTrashed', |
|
112 | + 'Boolean', |
|
113 | + 'deleted', |
|
114 | + esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLField( |
|
117 | + 'name', |
|
118 | + 'String', |
|
119 | + 'name', |
|
120 | + esc_html__('Price Name', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLField( |
|
123 | + 'order', |
|
124 | + 'Int', |
|
125 | + 'order', |
|
126 | + esc_html__('Order of Application of Price.', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLField( |
|
129 | + 'overrides', |
|
130 | + 'Int', |
|
131 | + 'overrides', |
|
132 | + esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLOutputField( |
|
135 | + 'parent', |
|
136 | + $this->name(), |
|
137 | + null, |
|
138 | + esc_html__('The parent price of the current price', 'event_espresso') |
|
139 | + ), |
|
140 | + new GraphQLInputField( |
|
141 | + 'parent', |
|
142 | + 'ID', |
|
143 | + null, |
|
144 | + esc_html__('The parent price ID', 'event_espresso') |
|
145 | + ), |
|
146 | + new GraphQLOutputField( |
|
147 | + 'priceType', |
|
148 | + $this->namespace . 'PriceType', |
|
149 | + 'type_obj', |
|
150 | + esc_html__('The related price type object.', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLInputField( |
|
153 | + 'priceType', |
|
154 | + 'ID', |
|
155 | + null, |
|
156 | + esc_html__('The price type ID', 'event_espresso') |
|
157 | + ), |
|
158 | + new GraphQLOutputField( |
|
159 | + 'wpUser', |
|
160 | + 'User', |
|
161 | + null, |
|
162 | + esc_html__('Price Creator', 'event_espresso') |
|
163 | + ), |
|
164 | + new GraphQLOutputField( |
|
165 | + 'userId', |
|
166 | + 'ID', |
|
167 | + null, |
|
168 | + esc_html__('Price Creator ID', 'event_espresso') |
|
169 | + ), |
|
170 | + new GraphQLInputField( |
|
171 | + 'wpUser', |
|
172 | + 'Int', |
|
173 | + null, |
|
174 | + esc_html__('Price Creator ID', 'event_espresso') |
|
175 | + ), |
|
176 | + ]; |
|
177 | 177 | |
178 | - return apply_filters( |
|
179 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__price_fields', |
|
180 | - $fields, |
|
181 | - $this->name, |
|
182 | - $this->model |
|
183 | - ); |
|
184 | - } |
|
178 | + return apply_filters( |
|
179 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__price_fields', |
|
180 | + $fields, |
|
181 | + $this->name, |
|
182 | + $this->model |
|
183 | + ); |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * @param array $inputFields The mutation input fields. |
|
189 | - * @throws InvalidArgumentException |
|
190 | - * @throws ReflectionException |
|
191 | - * @throws Exception |
|
192 | - * @since 5.0.0.p |
|
193 | - */ |
|
194 | - public function registerMutations(array $inputFields) |
|
195 | - { |
|
196 | - // Register mutation to update an entity. |
|
197 | - register_graphql_mutation( |
|
198 | - 'update' . $this->name(), |
|
199 | - [ |
|
200 | - 'inputFields' => $inputFields, |
|
201 | - 'outputFields' => [ |
|
202 | - lcfirst($this->name()) => [ |
|
203 | - 'type' => $this->name(), |
|
204 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
205 | - ], |
|
206 | - ], |
|
207 | - 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
208 | - ] |
|
209 | - ); |
|
210 | - // Register mutation to delete an entity. |
|
211 | - register_graphql_mutation( |
|
212 | - 'delete' . $this->name(), |
|
213 | - [ |
|
214 | - 'inputFields' => [ |
|
215 | - 'id' => $inputFields['id'], |
|
216 | - 'deletePermanently' => [ |
|
217 | - 'type' => 'Boolean', |
|
218 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
219 | - ], |
|
220 | - ], |
|
221 | - 'outputFields' => [ |
|
222 | - lcfirst($this->name()) => [ |
|
223 | - 'type' => $this->name(), |
|
224 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
225 | - 'resolve' => static function ($payload) { |
|
226 | - $deleted = (object) $payload['deleted']; |
|
187 | + /** |
|
188 | + * @param array $inputFields The mutation input fields. |
|
189 | + * @throws InvalidArgumentException |
|
190 | + * @throws ReflectionException |
|
191 | + * @throws Exception |
|
192 | + * @since 5.0.0.p |
|
193 | + */ |
|
194 | + public function registerMutations(array $inputFields) |
|
195 | + { |
|
196 | + // Register mutation to update an entity. |
|
197 | + register_graphql_mutation( |
|
198 | + 'update' . $this->name(), |
|
199 | + [ |
|
200 | + 'inputFields' => $inputFields, |
|
201 | + 'outputFields' => [ |
|
202 | + lcfirst($this->name()) => [ |
|
203 | + 'type' => $this->name(), |
|
204 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
205 | + ], |
|
206 | + ], |
|
207 | + 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
208 | + ] |
|
209 | + ); |
|
210 | + // Register mutation to delete an entity. |
|
211 | + register_graphql_mutation( |
|
212 | + 'delete' . $this->name(), |
|
213 | + [ |
|
214 | + 'inputFields' => [ |
|
215 | + 'id' => $inputFields['id'], |
|
216 | + 'deletePermanently' => [ |
|
217 | + 'type' => 'Boolean', |
|
218 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
219 | + ], |
|
220 | + ], |
|
221 | + 'outputFields' => [ |
|
222 | + lcfirst($this->name()) => [ |
|
223 | + 'type' => $this->name(), |
|
224 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
225 | + 'resolve' => static function ($payload) { |
|
226 | + $deleted = (object) $payload['deleted']; |
|
227 | 227 | |
228 | - return ! empty($deleted) ? $deleted : null; |
|
229 | - }, |
|
230 | - ], |
|
231 | - ], |
|
232 | - 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
233 | - ] |
|
234 | - ); |
|
228 | + return ! empty($deleted) ? $deleted : null; |
|
229 | + }, |
|
230 | + ], |
|
231 | + ], |
|
232 | + 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
233 | + ] |
|
234 | + ); |
|
235 | 235 | |
236 | - // remove primary key from input. |
|
237 | - unset($inputFields['id']); |
|
238 | - // Register mutation to update an entity. |
|
239 | - register_graphql_mutation( |
|
240 | - 'create' . $this->name(), |
|
241 | - [ |
|
242 | - 'inputFields' => $inputFields, |
|
243 | - 'outputFields' => [ |
|
244 | - lcfirst($this->name()) => [ |
|
245 | - 'type' => $this->name(), |
|
246 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
247 | - ], |
|
248 | - ], |
|
249 | - 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
250 | - ] |
|
251 | - ); |
|
252 | - } |
|
236 | + // remove primary key from input. |
|
237 | + unset($inputFields['id']); |
|
238 | + // Register mutation to update an entity. |
|
239 | + register_graphql_mutation( |
|
240 | + 'create' . $this->name(), |
|
241 | + [ |
|
242 | + 'inputFields' => $inputFields, |
|
243 | + 'outputFields' => [ |
|
244 | + lcfirst($this->name()) => [ |
|
245 | + 'type' => $this->name(), |
|
246 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
247 | + ], |
|
248 | + ], |
|
249 | + 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
250 | + ] |
|
251 | + ); |
|
252 | + } |
|
253 | 253 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct(EEM_Venue $venue_model) |
30 | 30 | { |
31 | - $this->setName($this->namespace . 'Venue'); |
|
31 | + $this->setName($this->namespace.'Venue'); |
|
32 | 32 | $this->setIsCustomPostType(true); |
33 | 33 | parent::__construct($venue_model); |
34 | 34 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ), |
121 | 121 | new GraphQLOutputField( |
122 | 122 | 'state', |
123 | - $this->namespace . 'State', |
|
123 | + $this->namespace.'State', |
|
124 | 124 | null, |
125 | 125 | esc_html__('Venue state', 'event_espresso') |
126 | 126 | ), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ), |
133 | 133 | new GraphQLOutputField( |
134 | 134 | 'country', |
135 | - $this->namespace . 'Country', |
|
135 | + $this->namespace.'Country', |
|
136 | 136 | null, |
137 | 137 | esc_html__('Venue country', 'event_espresso') |
138 | 138 | ), |
@@ -26,246 +26,246 @@ |
||
26 | 26 | */ |
27 | 27 | class Venue extends TypeBase |
28 | 28 | { |
29 | - /** |
|
30 | - * Venue constructor. |
|
31 | - * |
|
32 | - * @param EEM_Venue $venue_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Venue $venue_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'Venue'); |
|
37 | - $this->setIsCustomPostType(true); |
|
38 | - parent::__construct($venue_model); |
|
39 | - } |
|
29 | + /** |
|
30 | + * Venue constructor. |
|
31 | + * |
|
32 | + * @param EEM_Venue $venue_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Venue $venue_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'Venue'); |
|
37 | + $this->setIsCustomPostType(true); |
|
38 | + parent::__construct($venue_model); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @return GraphQLFieldInterface[] |
|
44 | - */ |
|
45 | - public function getFields(): array |
|
46 | - { |
|
47 | - $fields = [ |
|
48 | - new GraphQLOutputField( |
|
49 | - 'dbId', |
|
50 | - ['non_null' => 'Int'], |
|
51 | - 'ID', |
|
52 | - esc_html__('The venue ID.', 'event_espresso') |
|
53 | - ), |
|
54 | - new GraphQLOutputField( |
|
55 | - 'cacheId', |
|
56 | - ['non_null' => 'String'], |
|
57 | - null, |
|
58 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
59 | - ), |
|
60 | - new GraphQLField( |
|
61 | - 'name', |
|
62 | - 'String', |
|
63 | - 'name', |
|
64 | - esc_html__('Venue Name', 'event_espresso') |
|
65 | - ), |
|
66 | - new GraphQLField( |
|
67 | - 'description', |
|
68 | - 'String', |
|
69 | - 'description', |
|
70 | - esc_html__('Venue Description', 'event_espresso') |
|
71 | - ), |
|
72 | - new GraphQLField( |
|
73 | - 'shortDescription', |
|
74 | - 'String', |
|
75 | - 'excerpt', |
|
76 | - esc_html__('Short Description of Venue', 'event_espresso') |
|
77 | - ), |
|
78 | - new GraphQLField( |
|
79 | - 'identifier', |
|
80 | - 'String', |
|
81 | - 'identifier', |
|
82 | - esc_html__('Venue Identifier', 'event_espresso') |
|
83 | - ), |
|
84 | - new GraphQLField( |
|
85 | - 'created', |
|
86 | - 'String', |
|
87 | - 'created', |
|
88 | - esc_html__('Date Venue Created', 'event_espresso') |
|
89 | - ), |
|
90 | - new GraphQLField( |
|
91 | - 'order', |
|
92 | - 'Int', |
|
93 | - 'order', |
|
94 | - esc_html__('Venue order', 'event_espresso') |
|
95 | - ), |
|
96 | - new GraphQLOutputField( |
|
97 | - 'wpUser', |
|
98 | - 'User', |
|
99 | - null, |
|
100 | - esc_html__('Venue Creator', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLInputField( |
|
103 | - 'wpUser', |
|
104 | - 'Int', |
|
105 | - null, |
|
106 | - esc_html__('Venue Creator ID', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'address', |
|
110 | - 'String', |
|
111 | - 'address', |
|
112 | - esc_html__('Venue Address line 1', 'event_espresso') |
|
113 | - ), |
|
114 | - new GraphQLField( |
|
115 | - 'address2', |
|
116 | - 'String', |
|
117 | - 'address2', |
|
118 | - esc_html__('Venue Address line 2', 'event_espresso') |
|
119 | - ), |
|
120 | - new GraphQLField( |
|
121 | - 'city', |
|
122 | - 'String', |
|
123 | - 'city', |
|
124 | - esc_html__('Venue City', 'event_espresso') |
|
125 | - ), |
|
126 | - new GraphQLOutputField( |
|
127 | - 'state', |
|
128 | - $this->namespace . 'State', |
|
129 | - null, |
|
130 | - esc_html__('Venue state', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLOutputField( |
|
133 | - 'stateName', |
|
134 | - 'String', |
|
135 | - 'state_name', |
|
136 | - esc_html__('Venue state name', 'event_espresso') |
|
137 | - ), |
|
138 | - new GraphQLOutputField( |
|
139 | - 'stateAbbrev', |
|
140 | - 'String', |
|
141 | - 'state_abbrev', |
|
142 | - esc_html__('Venue state abbreviation', 'event_espresso') |
|
143 | - ), |
|
144 | - new GraphQLInputField( |
|
145 | - 'state', |
|
146 | - 'Int', |
|
147 | - null, |
|
148 | - esc_html__('State ID', 'event_espresso') |
|
149 | - ), |
|
150 | - new GraphQLOutputField( |
|
151 | - 'country', |
|
152 | - $this->namespace . 'Country', |
|
153 | - null, |
|
154 | - esc_html__('Venue country', 'event_espresso') |
|
155 | - ), |
|
156 | - new GraphQLOutputField( |
|
157 | - 'countryName', |
|
158 | - 'String', |
|
159 | - 'country_name', |
|
160 | - esc_html__('Venue country name', 'event_espresso') |
|
161 | - ), |
|
162 | - new GraphQLOutputField( |
|
163 | - 'countryISO', |
|
164 | - 'String', |
|
165 | - 'country_ID', |
|
166 | - esc_html__('Venue Country ISO Code', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLInputField( |
|
169 | - 'country', |
|
170 | - 'String', |
|
171 | - null, |
|
172 | - esc_html__('Country ISO Code', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'zip', |
|
176 | - 'String', |
|
177 | - 'zip', |
|
178 | - esc_html__('Venue Zip/Postal Code', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLField( |
|
181 | - 'capacity', |
|
182 | - 'Int', |
|
183 | - 'capacity', |
|
184 | - esc_html__('Venue Capacity', 'event_espresso'), |
|
185 | - [$this, 'parseInfiniteValue'] |
|
186 | - ), |
|
187 | - new GraphQLField( |
|
188 | - 'phone', |
|
189 | - 'String', |
|
190 | - 'phone', |
|
191 | - esc_html__('Venue Phone', 'event_espresso') |
|
192 | - ), |
|
193 | - new GraphQLField( |
|
194 | - 'virtualPhone', |
|
195 | - 'String', |
|
196 | - 'virtual_phone', |
|
197 | - esc_html__('Call in Number', 'event_espresso') |
|
198 | - ), |
|
199 | - new GraphQLField( |
|
200 | - 'url', |
|
201 | - 'String', |
|
202 | - 'venue_url', |
|
203 | - esc_html__('Venue Website', 'event_espresso') |
|
204 | - ), |
|
205 | - new GraphQLField( |
|
206 | - 'virtualUrl', |
|
207 | - 'String', |
|
208 | - 'virtual_url', |
|
209 | - esc_html__('Virtual URL', 'event_espresso') |
|
210 | - ), |
|
211 | - new GraphQLField( |
|
212 | - 'googleMapLink', |
|
213 | - 'String', |
|
214 | - 'google_map_link', |
|
215 | - esc_html__('Google Map Link', 'event_espresso') |
|
216 | - ), |
|
217 | - new GraphQLField( |
|
218 | - 'enableForGmap', |
|
219 | - 'String', |
|
220 | - 'enable_for_gmap', |
|
221 | - esc_html__('Show Google Map?', 'event_espresso') |
|
222 | - ), |
|
223 | - new GraphQLOutputField( |
|
224 | - 'thumbnail', |
|
225 | - 'String', |
|
226 | - 'thumbnail', |
|
227 | - esc_html__('Venue Thumbnail', 'event_espresso'), |
|
228 | - null, |
|
229 | - [$this, 'getThumbnail'] |
|
230 | - ), |
|
231 | - ]; |
|
42 | + /** |
|
43 | + * @return GraphQLFieldInterface[] |
|
44 | + */ |
|
45 | + public function getFields(): array |
|
46 | + { |
|
47 | + $fields = [ |
|
48 | + new GraphQLOutputField( |
|
49 | + 'dbId', |
|
50 | + ['non_null' => 'Int'], |
|
51 | + 'ID', |
|
52 | + esc_html__('The venue ID.', 'event_espresso') |
|
53 | + ), |
|
54 | + new GraphQLOutputField( |
|
55 | + 'cacheId', |
|
56 | + ['non_null' => 'String'], |
|
57 | + null, |
|
58 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
59 | + ), |
|
60 | + new GraphQLField( |
|
61 | + 'name', |
|
62 | + 'String', |
|
63 | + 'name', |
|
64 | + esc_html__('Venue Name', 'event_espresso') |
|
65 | + ), |
|
66 | + new GraphQLField( |
|
67 | + 'description', |
|
68 | + 'String', |
|
69 | + 'description', |
|
70 | + esc_html__('Venue Description', 'event_espresso') |
|
71 | + ), |
|
72 | + new GraphQLField( |
|
73 | + 'shortDescription', |
|
74 | + 'String', |
|
75 | + 'excerpt', |
|
76 | + esc_html__('Short Description of Venue', 'event_espresso') |
|
77 | + ), |
|
78 | + new GraphQLField( |
|
79 | + 'identifier', |
|
80 | + 'String', |
|
81 | + 'identifier', |
|
82 | + esc_html__('Venue Identifier', 'event_espresso') |
|
83 | + ), |
|
84 | + new GraphQLField( |
|
85 | + 'created', |
|
86 | + 'String', |
|
87 | + 'created', |
|
88 | + esc_html__('Date Venue Created', 'event_espresso') |
|
89 | + ), |
|
90 | + new GraphQLField( |
|
91 | + 'order', |
|
92 | + 'Int', |
|
93 | + 'order', |
|
94 | + esc_html__('Venue order', 'event_espresso') |
|
95 | + ), |
|
96 | + new GraphQLOutputField( |
|
97 | + 'wpUser', |
|
98 | + 'User', |
|
99 | + null, |
|
100 | + esc_html__('Venue Creator', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLInputField( |
|
103 | + 'wpUser', |
|
104 | + 'Int', |
|
105 | + null, |
|
106 | + esc_html__('Venue Creator ID', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'address', |
|
110 | + 'String', |
|
111 | + 'address', |
|
112 | + esc_html__('Venue Address line 1', 'event_espresso') |
|
113 | + ), |
|
114 | + new GraphQLField( |
|
115 | + 'address2', |
|
116 | + 'String', |
|
117 | + 'address2', |
|
118 | + esc_html__('Venue Address line 2', 'event_espresso') |
|
119 | + ), |
|
120 | + new GraphQLField( |
|
121 | + 'city', |
|
122 | + 'String', |
|
123 | + 'city', |
|
124 | + esc_html__('Venue City', 'event_espresso') |
|
125 | + ), |
|
126 | + new GraphQLOutputField( |
|
127 | + 'state', |
|
128 | + $this->namespace . 'State', |
|
129 | + null, |
|
130 | + esc_html__('Venue state', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLOutputField( |
|
133 | + 'stateName', |
|
134 | + 'String', |
|
135 | + 'state_name', |
|
136 | + esc_html__('Venue state name', 'event_espresso') |
|
137 | + ), |
|
138 | + new GraphQLOutputField( |
|
139 | + 'stateAbbrev', |
|
140 | + 'String', |
|
141 | + 'state_abbrev', |
|
142 | + esc_html__('Venue state abbreviation', 'event_espresso') |
|
143 | + ), |
|
144 | + new GraphQLInputField( |
|
145 | + 'state', |
|
146 | + 'Int', |
|
147 | + null, |
|
148 | + esc_html__('State ID', 'event_espresso') |
|
149 | + ), |
|
150 | + new GraphQLOutputField( |
|
151 | + 'country', |
|
152 | + $this->namespace . 'Country', |
|
153 | + null, |
|
154 | + esc_html__('Venue country', 'event_espresso') |
|
155 | + ), |
|
156 | + new GraphQLOutputField( |
|
157 | + 'countryName', |
|
158 | + 'String', |
|
159 | + 'country_name', |
|
160 | + esc_html__('Venue country name', 'event_espresso') |
|
161 | + ), |
|
162 | + new GraphQLOutputField( |
|
163 | + 'countryISO', |
|
164 | + 'String', |
|
165 | + 'country_ID', |
|
166 | + esc_html__('Venue Country ISO Code', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLInputField( |
|
169 | + 'country', |
|
170 | + 'String', |
|
171 | + null, |
|
172 | + esc_html__('Country ISO Code', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'zip', |
|
176 | + 'String', |
|
177 | + 'zip', |
|
178 | + esc_html__('Venue Zip/Postal Code', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLField( |
|
181 | + 'capacity', |
|
182 | + 'Int', |
|
183 | + 'capacity', |
|
184 | + esc_html__('Venue Capacity', 'event_espresso'), |
|
185 | + [$this, 'parseInfiniteValue'] |
|
186 | + ), |
|
187 | + new GraphQLField( |
|
188 | + 'phone', |
|
189 | + 'String', |
|
190 | + 'phone', |
|
191 | + esc_html__('Venue Phone', 'event_espresso') |
|
192 | + ), |
|
193 | + new GraphQLField( |
|
194 | + 'virtualPhone', |
|
195 | + 'String', |
|
196 | + 'virtual_phone', |
|
197 | + esc_html__('Call in Number', 'event_espresso') |
|
198 | + ), |
|
199 | + new GraphQLField( |
|
200 | + 'url', |
|
201 | + 'String', |
|
202 | + 'venue_url', |
|
203 | + esc_html__('Venue Website', 'event_espresso') |
|
204 | + ), |
|
205 | + new GraphQLField( |
|
206 | + 'virtualUrl', |
|
207 | + 'String', |
|
208 | + 'virtual_url', |
|
209 | + esc_html__('Virtual URL', 'event_espresso') |
|
210 | + ), |
|
211 | + new GraphQLField( |
|
212 | + 'googleMapLink', |
|
213 | + 'String', |
|
214 | + 'google_map_link', |
|
215 | + esc_html__('Google Map Link', 'event_espresso') |
|
216 | + ), |
|
217 | + new GraphQLField( |
|
218 | + 'enableForGmap', |
|
219 | + 'String', |
|
220 | + 'enable_for_gmap', |
|
221 | + esc_html__('Show Google Map?', 'event_espresso') |
|
222 | + ), |
|
223 | + new GraphQLOutputField( |
|
224 | + 'thumbnail', |
|
225 | + 'String', |
|
226 | + 'thumbnail', |
|
227 | + esc_html__('Venue Thumbnail', 'event_espresso'), |
|
228 | + null, |
|
229 | + [$this, 'getThumbnail'] |
|
230 | + ), |
|
231 | + ]; |
|
232 | 232 | |
233 | - return apply_filters( |
|
234 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__venue_fields', |
|
235 | - $fields, |
|
236 | - $this->name, |
|
237 | - $this->model |
|
238 | - ); |
|
239 | - } |
|
233 | + return apply_filters( |
|
234 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__venue_fields', |
|
235 | + $fields, |
|
236 | + $this->name, |
|
237 | + $this->model |
|
238 | + ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * Extends the existing WP GraphQL mutations. |
|
244 | - * |
|
245 | - * @return void |
|
246 | - */ |
|
247 | - public function extendMutations() |
|
248 | - { |
|
249 | - add_action( |
|
250 | - 'graphql_post_object_mutation_update_additional_data', |
|
251 | - VenueUpdate::mutateFields($this->model, $this), |
|
252 | - 10, |
|
253 | - 6 |
|
254 | - ); |
|
255 | - } |
|
242 | + /** |
|
243 | + * Extends the existing WP GraphQL mutations. |
|
244 | + * |
|
245 | + * @return void |
|
246 | + */ |
|
247 | + public function extendMutations() |
|
248 | + { |
|
249 | + add_action( |
|
250 | + 'graphql_post_object_mutation_update_additional_data', |
|
251 | + VenueUpdate::mutateFields($this->model, $this), |
|
252 | + 10, |
|
253 | + 6 |
|
254 | + ); |
|
255 | + } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * @param EE_Venue $venue |
|
260 | - * @param array $args |
|
261 | - * @param AppContext $context |
|
262 | - * @param ResolveInfo $info |
|
263 | - * @return string |
|
264 | - * @throws EE_Error |
|
265 | - * @throws ReflectionException |
|
266 | - */ |
|
267 | - public function getThumbnail(EE_Venue $venue, array $args, AppContext $context, ResolveInfo $info): string |
|
268 | - { |
|
269 | - return wp_get_attachment_url(get_post_thumbnail_id($venue->ID())); |
|
270 | - } |
|
258 | + /** |
|
259 | + * @param EE_Venue $venue |
|
260 | + * @param array $args |
|
261 | + * @param AppContext $context |
|
262 | + * @param ResolveInfo $info |
|
263 | + * @return string |
|
264 | + * @throws EE_Error |
|
265 | + * @throws ReflectionException |
|
266 | + */ |
|
267 | + public function getThumbnail(EE_Venue $venue, array $args, AppContext $context, ResolveInfo $info): string |
|
268 | + { |
|
269 | + return wp_get_attachment_url(get_post_thumbnail_id($venue->ID())); |
|
270 | + } |
|
271 | 271 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct(EEM_Price_Type $price_type_model) |
29 | 29 | { |
30 | - $this->setName($this->namespace . 'PriceType'); |
|
30 | + $this->setName($this->namespace.'PriceType'); |
|
31 | 31 | $this->setDescription(__('A price type.', 'event_espresso')); |
32 | 32 | $this->setIsCustomPostType(false); |
33 | 33 | parent::__construct($price_type_model); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ), |
55 | 55 | new GraphQLField( |
56 | 56 | 'baseType', |
57 | - $this->namespace . 'PriceBaseTypeEnum', |
|
57 | + $this->namespace.'PriceBaseTypeEnum', |
|
58 | 58 | 'base_type', |
59 | 59 | esc_html__('Price Base type', 'event_espresso') |
60 | 60 | ), |
@@ -20,117 +20,117 @@ |
||
20 | 20 | */ |
21 | 21 | class PriceType extends TypeBase |
22 | 22 | { |
23 | - /** |
|
24 | - * PriceType constructor. |
|
25 | - * |
|
26 | - * @param EEM_Price_Type $price_type_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Price_Type $price_type_model) |
|
29 | - { |
|
30 | - $this->setName($this->namespace . 'PriceType'); |
|
31 | - $this->setDescription(__('A price type.', 'event_espresso')); |
|
32 | - $this->setIsCustomPostType(false); |
|
33 | - parent::__construct($price_type_model); |
|
34 | - } |
|
23 | + /** |
|
24 | + * PriceType constructor. |
|
25 | + * |
|
26 | + * @param EEM_Price_Type $price_type_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Price_Type $price_type_model) |
|
29 | + { |
|
30 | + $this->setName($this->namespace . 'PriceType'); |
|
31 | + $this->setDescription(__('A price type.', 'event_espresso')); |
|
32 | + $this->setIsCustomPostType(false); |
|
33 | + parent::__construct($price_type_model); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @return GraphQLFieldInterface[] |
|
39 | - */ |
|
40 | - public function getFields(): array |
|
41 | - { |
|
42 | - $fields = [ |
|
43 | - new GraphQLField( |
|
44 | - 'id', |
|
45 | - ['non_null' => 'ID'], |
|
46 | - null, |
|
47 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
48 | - ), |
|
49 | - new GraphQLOutputField( |
|
50 | - 'dbId', |
|
51 | - ['non_null' => 'Int'], |
|
52 | - 'ID', |
|
53 | - esc_html__('Price type ID', 'event_espresso') |
|
54 | - ), |
|
55 | - new GraphQLField( |
|
56 | - 'baseType', |
|
57 | - $this->namespace . 'PriceBaseTypeEnum', |
|
58 | - 'base_type', |
|
59 | - esc_html__('Price Base type', 'event_espresso') |
|
60 | - ), |
|
61 | - new GraphQLOutputField( |
|
62 | - 'cacheId', |
|
63 | - ['non_null' => 'String'], |
|
64 | - null, |
|
65 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
66 | - ), |
|
67 | - new GraphQLField( |
|
68 | - 'isBasePrice', |
|
69 | - 'Boolean', |
|
70 | - 'is_base_price', |
|
71 | - esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
72 | - ), |
|
73 | - new GraphQLField( |
|
74 | - 'isTrashed', |
|
75 | - 'Boolean', |
|
76 | - 'deleted', |
|
77 | - esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
78 | - ), |
|
79 | - new GraphQLOutputField( |
|
80 | - 'isDiscount', |
|
81 | - 'Boolean', |
|
82 | - 'is_discount', |
|
83 | - esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
84 | - ), |
|
85 | - new GraphQLField( |
|
86 | - 'isPercent', |
|
87 | - 'Boolean', |
|
88 | - 'is_percent', |
|
89 | - esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
90 | - ), |
|
91 | - new GraphQLOutputField( |
|
92 | - 'isTax', |
|
93 | - 'Boolean', |
|
94 | - 'is_tax', |
|
95 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
96 | - ), |
|
97 | - new GraphQLField( |
|
98 | - 'name', |
|
99 | - 'String', |
|
100 | - 'name', |
|
101 | - esc_html__('Price type Name', 'event_espresso') |
|
102 | - ), |
|
103 | - new GraphQLField( |
|
104 | - 'order', |
|
105 | - 'Int', |
|
106 | - 'order', |
|
107 | - esc_html__('Order in which price should be applied.', 'event_espresso') |
|
108 | - ), |
|
109 | - new GraphQLOutputField( |
|
110 | - 'wpUser', |
|
111 | - 'User', |
|
112 | - null, |
|
113 | - esc_html__('Price Type Creator', 'event_espresso') |
|
114 | - ), |
|
115 | - new GraphQLOutputField( |
|
116 | - 'userId', |
|
117 | - 'ID', |
|
118 | - null, |
|
119 | - esc_html__('Price Type Creator ID', 'event_espresso') |
|
120 | - ), |
|
121 | - new GraphQLInputField( |
|
122 | - 'wpUser', |
|
123 | - 'Int', |
|
124 | - null, |
|
125 | - esc_html__('Price Type Creator ID', 'event_espresso') |
|
126 | - ), |
|
127 | - ]; |
|
37 | + /** |
|
38 | + * @return GraphQLFieldInterface[] |
|
39 | + */ |
|
40 | + public function getFields(): array |
|
41 | + { |
|
42 | + $fields = [ |
|
43 | + new GraphQLField( |
|
44 | + 'id', |
|
45 | + ['non_null' => 'ID'], |
|
46 | + null, |
|
47 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
48 | + ), |
|
49 | + new GraphQLOutputField( |
|
50 | + 'dbId', |
|
51 | + ['non_null' => 'Int'], |
|
52 | + 'ID', |
|
53 | + esc_html__('Price type ID', 'event_espresso') |
|
54 | + ), |
|
55 | + new GraphQLField( |
|
56 | + 'baseType', |
|
57 | + $this->namespace . 'PriceBaseTypeEnum', |
|
58 | + 'base_type', |
|
59 | + esc_html__('Price Base type', 'event_espresso') |
|
60 | + ), |
|
61 | + new GraphQLOutputField( |
|
62 | + 'cacheId', |
|
63 | + ['non_null' => 'String'], |
|
64 | + null, |
|
65 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
66 | + ), |
|
67 | + new GraphQLField( |
|
68 | + 'isBasePrice', |
|
69 | + 'Boolean', |
|
70 | + 'is_base_price', |
|
71 | + esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
72 | + ), |
|
73 | + new GraphQLField( |
|
74 | + 'isTrashed', |
|
75 | + 'Boolean', |
|
76 | + 'deleted', |
|
77 | + esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
78 | + ), |
|
79 | + new GraphQLOutputField( |
|
80 | + 'isDiscount', |
|
81 | + 'Boolean', |
|
82 | + 'is_discount', |
|
83 | + esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
84 | + ), |
|
85 | + new GraphQLField( |
|
86 | + 'isPercent', |
|
87 | + 'Boolean', |
|
88 | + 'is_percent', |
|
89 | + esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
90 | + ), |
|
91 | + new GraphQLOutputField( |
|
92 | + 'isTax', |
|
93 | + 'Boolean', |
|
94 | + 'is_tax', |
|
95 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
96 | + ), |
|
97 | + new GraphQLField( |
|
98 | + 'name', |
|
99 | + 'String', |
|
100 | + 'name', |
|
101 | + esc_html__('Price type Name', 'event_espresso') |
|
102 | + ), |
|
103 | + new GraphQLField( |
|
104 | + 'order', |
|
105 | + 'Int', |
|
106 | + 'order', |
|
107 | + esc_html__('Order in which price should be applied.', 'event_espresso') |
|
108 | + ), |
|
109 | + new GraphQLOutputField( |
|
110 | + 'wpUser', |
|
111 | + 'User', |
|
112 | + null, |
|
113 | + esc_html__('Price Type Creator', 'event_espresso') |
|
114 | + ), |
|
115 | + new GraphQLOutputField( |
|
116 | + 'userId', |
|
117 | + 'ID', |
|
118 | + null, |
|
119 | + esc_html__('Price Type Creator ID', 'event_espresso') |
|
120 | + ), |
|
121 | + new GraphQLInputField( |
|
122 | + 'wpUser', |
|
123 | + 'Int', |
|
124 | + null, |
|
125 | + esc_html__('Price Type Creator ID', 'event_espresso') |
|
126 | + ), |
|
127 | + ]; |
|
128 | 128 | |
129 | - return apply_filters( |
|
130 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__priceType_fields', |
|
131 | - $fields, |
|
132 | - $this->name, |
|
133 | - $this->model |
|
134 | - ); |
|
135 | - } |
|
129 | + return apply_filters( |
|
130 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__priceType_fields', |
|
131 | + $fields, |
|
132 | + $this->name, |
|
133 | + $this->model |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function __construct(EEM_Country $country_model) |
28 | 28 | { |
29 | - $this->setName($this->namespace . 'Country'); |
|
29 | + $this->setName($this->namespace.'Country'); |
|
30 | 30 | $this->setDescription(__('A country', 'event_espresso')); |
31 | 31 | $this->setIsCustomPostType(false); |
32 | 32 | parent::__construct($country_model); |
@@ -19,120 +19,120 @@ |
||
19 | 19 | */ |
20 | 20 | class Country extends TypeBase |
21 | 21 | { |
22 | - /** |
|
23 | - * Country constructor. |
|
24 | - * |
|
25 | - * @param EEM_Country $country_model |
|
26 | - */ |
|
27 | - public function __construct(EEM_Country $country_model) |
|
28 | - { |
|
29 | - $this->setName($this->namespace . 'Country'); |
|
30 | - $this->setDescription(__('A country', 'event_espresso')); |
|
31 | - $this->setIsCustomPostType(false); |
|
32 | - parent::__construct($country_model); |
|
33 | - } |
|
22 | + /** |
|
23 | + * Country constructor. |
|
24 | + * |
|
25 | + * @param EEM_Country $country_model |
|
26 | + */ |
|
27 | + public function __construct(EEM_Country $country_model) |
|
28 | + { |
|
29 | + $this->setName($this->namespace . 'Country'); |
|
30 | + $this->setDescription(__('A country', 'event_espresso')); |
|
31 | + $this->setIsCustomPostType(false); |
|
32 | + parent::__construct($country_model); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @return GraphQLFieldInterface[] |
|
38 | - */ |
|
39 | - public function getFields(): array |
|
40 | - { |
|
41 | - $fields = [ |
|
42 | - new GraphQLField( |
|
43 | - 'id', |
|
44 | - ['non_null' => 'ID'], |
|
45 | - null, |
|
46 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
47 | - ), |
|
48 | - new GraphQLOutputField( |
|
49 | - 'cacheId', |
|
50 | - ['non_null' => 'String'], |
|
51 | - null, |
|
52 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
53 | - ), |
|
54 | - new GraphQLField( |
|
55 | - 'isActive', |
|
56 | - 'Boolean', |
|
57 | - 'is_active', |
|
58 | - esc_html__( |
|
59 | - 'Flag that indicates if the country should appear in dropdown select lists', |
|
60 | - 'event_espresso' |
|
61 | - ) |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'ISO', |
|
65 | - 'String', |
|
66 | - 'ID', |
|
67 | - esc_html__('Country ISO Code', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLField( |
|
70 | - 'ISO3', |
|
71 | - 'String', |
|
72 | - 'ISO3', |
|
73 | - esc_html__('Country ISO3 Code', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLField( |
|
76 | - 'name', |
|
77 | - 'String', |
|
78 | - 'name', |
|
79 | - esc_html__('Country Name', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLField( |
|
82 | - 'currencyCode', |
|
83 | - 'String', |
|
84 | - 'currency_code', |
|
85 | - esc_html__('Country Currency Code', 'event_espresso') |
|
86 | - ), |
|
87 | - new GraphQLField( |
|
88 | - 'currencySingular', |
|
89 | - 'String', |
|
90 | - 'currency_name_single', |
|
91 | - esc_html__('Currency Name Singular', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLField( |
|
94 | - 'currencyPlural', |
|
95 | - 'String', |
|
96 | - 'currency_name_plural', |
|
97 | - esc_html__('Currency Name Plural', 'event_espresso') |
|
98 | - ), |
|
99 | - new GraphQLField( |
|
100 | - 'currencySign', |
|
101 | - 'String', |
|
102 | - 'currency_sign', |
|
103 | - __('Currency Sign', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'currencySignBeforeNumber', |
|
107 | - 'String', |
|
108 | - 'currency_sign_before', |
|
109 | - esc_html__('Currency Sign Before Number', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'currencyDecimalPlaces', |
|
113 | - 'String', |
|
114 | - 'currency_decimal_places', |
|
115 | - esc_html__('Currency Decimal Places', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'currencyDecimalMark', |
|
119 | - 'String', |
|
120 | - 'currency_decimal_mark', |
|
121 | - esc_html__('Currency Decimal Mark', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'currencyThousandsSeparator', |
|
125 | - 'String', |
|
126 | - 'currency_thousands_separator', |
|
127 | - esc_html__('Currency Thousands Separator', 'event_espresso') |
|
128 | - ), |
|
129 | - ]; |
|
36 | + /** |
|
37 | + * @return GraphQLFieldInterface[] |
|
38 | + */ |
|
39 | + public function getFields(): array |
|
40 | + { |
|
41 | + $fields = [ |
|
42 | + new GraphQLField( |
|
43 | + 'id', |
|
44 | + ['non_null' => 'ID'], |
|
45 | + null, |
|
46 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
47 | + ), |
|
48 | + new GraphQLOutputField( |
|
49 | + 'cacheId', |
|
50 | + ['non_null' => 'String'], |
|
51 | + null, |
|
52 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
53 | + ), |
|
54 | + new GraphQLField( |
|
55 | + 'isActive', |
|
56 | + 'Boolean', |
|
57 | + 'is_active', |
|
58 | + esc_html__( |
|
59 | + 'Flag that indicates if the country should appear in dropdown select lists', |
|
60 | + 'event_espresso' |
|
61 | + ) |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'ISO', |
|
65 | + 'String', |
|
66 | + 'ID', |
|
67 | + esc_html__('Country ISO Code', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLField( |
|
70 | + 'ISO3', |
|
71 | + 'String', |
|
72 | + 'ISO3', |
|
73 | + esc_html__('Country ISO3 Code', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLField( |
|
76 | + 'name', |
|
77 | + 'String', |
|
78 | + 'name', |
|
79 | + esc_html__('Country Name', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLField( |
|
82 | + 'currencyCode', |
|
83 | + 'String', |
|
84 | + 'currency_code', |
|
85 | + esc_html__('Country Currency Code', 'event_espresso') |
|
86 | + ), |
|
87 | + new GraphQLField( |
|
88 | + 'currencySingular', |
|
89 | + 'String', |
|
90 | + 'currency_name_single', |
|
91 | + esc_html__('Currency Name Singular', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLField( |
|
94 | + 'currencyPlural', |
|
95 | + 'String', |
|
96 | + 'currency_name_plural', |
|
97 | + esc_html__('Currency Name Plural', 'event_espresso') |
|
98 | + ), |
|
99 | + new GraphQLField( |
|
100 | + 'currencySign', |
|
101 | + 'String', |
|
102 | + 'currency_sign', |
|
103 | + __('Currency Sign', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'currencySignBeforeNumber', |
|
107 | + 'String', |
|
108 | + 'currency_sign_before', |
|
109 | + esc_html__('Currency Sign Before Number', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'currencyDecimalPlaces', |
|
113 | + 'String', |
|
114 | + 'currency_decimal_places', |
|
115 | + esc_html__('Currency Decimal Places', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'currencyDecimalMark', |
|
119 | + 'String', |
|
120 | + 'currency_decimal_mark', |
|
121 | + esc_html__('Currency Decimal Mark', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'currencyThousandsSeparator', |
|
125 | + 'String', |
|
126 | + 'currency_thousands_separator', |
|
127 | + esc_html__('Currency Thousands Separator', 'event_espresso') |
|
128 | + ), |
|
129 | + ]; |
|
130 | 130 | |
131 | - return apply_filters( |
|
132 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__country_fields', |
|
133 | - $fields, |
|
134 | - $this->name, |
|
135 | - $this->model |
|
136 | - ); |
|
137 | - } |
|
131 | + return apply_filters( |
|
132 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__country_fields', |
|
133 | + $fields, |
|
134 | + $this->name, |
|
135 | + $this->model |
|
136 | + ); |
|
137 | + } |
|
138 | 138 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct(EEM_Attendee $attendee_model) |
32 | 32 | { |
33 | - $this->setName($this->namespace . 'Attendee'); |
|
33 | + $this->setName($this->namespace.'Attendee'); |
|
34 | 34 | $this->setIsCustomPostType(false); // Set to false to use our model queries |
35 | 35 | parent::__construct($attendee_model); |
36 | 36 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ), |
108 | 108 | new GraphQLOutputField( |
109 | 109 | 'country', |
110 | - $this->namespace . 'Country', |
|
110 | + $this->namespace.'Country', |
|
111 | 111 | null, |
112 | 112 | esc_html__('Country', 'event_espresso'), |
113 | 113 | null, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ), |
162 | 162 | new GraphQLOutputField( |
163 | 163 | 'state', |
164 | - $this->namespace . 'State', |
|
164 | + $this->namespace.'State', |
|
165 | 165 | null, |
166 | 166 | esc_html__('State', 'event_espresso'), |
167 | 167 | null, |
@@ -23,187 +23,187 @@ |
||
23 | 23 | */ |
24 | 24 | class Attendee extends TypeBase |
25 | 25 | { |
26 | - /** |
|
27 | - * Attendee constructor. |
|
28 | - * |
|
29 | - * @param EEM_Attendee $attendee_model |
|
30 | - */ |
|
31 | - public function __construct(EEM_Attendee $attendee_model) |
|
32 | - { |
|
33 | - $this->setName($this->namespace . 'Attendee'); |
|
34 | - $this->setIsCustomPostType(false); // Set to false to use our model queries |
|
35 | - parent::__construct($attendee_model); |
|
36 | - } |
|
26 | + /** |
|
27 | + * Attendee constructor. |
|
28 | + * |
|
29 | + * @param EEM_Attendee $attendee_model |
|
30 | + */ |
|
31 | + public function __construct(EEM_Attendee $attendee_model) |
|
32 | + { |
|
33 | + $this->setName($this->namespace . 'Attendee'); |
|
34 | + $this->setIsCustomPostType(false); // Set to false to use our model queries |
|
35 | + parent::__construct($attendee_model); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return GraphQLFieldInterface[] |
|
41 | - */ |
|
42 | - public function getFields(): array |
|
43 | - { |
|
44 | - $fields = [ |
|
45 | - new GraphQLField( |
|
46 | - 'id', |
|
47 | - ['non_null' => 'ID'], |
|
48 | - null, |
|
49 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLOutputField( |
|
52 | - 'dbId', |
|
53 | - ['non_null' => 'Int'], |
|
54 | - 'ID', |
|
55 | - esc_html__('The attendee ID.', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLOutputField( |
|
58 | - 'cacheId', |
|
59 | - ['non_null' => 'String'], |
|
60 | - null, |
|
61 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLOutputField( |
|
64 | - 'address', |
|
65 | - 'String', |
|
66 | - 'address', |
|
67 | - esc_html__('Address Part 1', 'event_espresso'), |
|
68 | - null, |
|
69 | - null, |
|
70 | - ['ee_edit_contacts'] |
|
71 | - ), |
|
72 | - new GraphQLOutputField( |
|
73 | - 'address2', |
|
74 | - 'String', |
|
75 | - 'address2', |
|
76 | - esc_html__('Address Part 2', 'event_espresso'), |
|
77 | - null, |
|
78 | - null, |
|
79 | - ['ee_edit_contacts'] |
|
80 | - ), |
|
81 | - new GraphQLOutputField( |
|
82 | - 'avatar', |
|
83 | - 'String', |
|
84 | - null, |
|
85 | - esc_html__('User avatar URL', 'event_espresso'), |
|
86 | - null, |
|
87 | - [$this, 'getAvatar'], |
|
88 | - ['ee_edit_contacts'] |
|
89 | - ), |
|
90 | - new GraphQLOutputField( |
|
91 | - 'bio', |
|
92 | - 'String', |
|
93 | - 'bio', |
|
94 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
95 | - null, |
|
96 | - null, |
|
97 | - ['ee_edit_contacts'] |
|
98 | - ), |
|
99 | - new GraphQLOutputField( |
|
100 | - 'city', |
|
101 | - 'String', |
|
102 | - 'city', |
|
103 | - esc_html__('City', 'event_espresso'), |
|
104 | - null, |
|
105 | - null, |
|
106 | - ['ee_edit_contacts'] |
|
107 | - ), |
|
108 | - new GraphQLOutputField( |
|
109 | - 'country', |
|
110 | - $this->namespace . 'Country', |
|
111 | - null, |
|
112 | - esc_html__('Country', 'event_espresso'), |
|
113 | - null, |
|
114 | - null, |
|
115 | - ['ee_edit_contacts'] |
|
116 | - ), |
|
117 | - new GraphQLOutputField( |
|
118 | - 'email', |
|
119 | - 'String', |
|
120 | - 'email', |
|
121 | - esc_html__('Email Address', 'event_espresso'), |
|
122 | - null, |
|
123 | - null, |
|
124 | - ['ee_edit_contacts'] |
|
125 | - ), |
|
126 | - new GraphQLOutputField( |
|
127 | - 'firstName', |
|
128 | - 'String', |
|
129 | - 'fname', |
|
130 | - esc_html__('Attendee First Name', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLOutputField( |
|
133 | - 'fullName', |
|
134 | - 'String', |
|
135 | - 'full_name', |
|
136 | - esc_html__('Attendee Name', 'event_espresso') |
|
137 | - ), |
|
138 | - new GraphQLOutputField( |
|
139 | - 'lastName', |
|
140 | - 'String', |
|
141 | - 'lname', |
|
142 | - esc_html__('Attendee Last Name', 'event_espresso') |
|
143 | - ), |
|
144 | - new GraphQLOutputField( |
|
145 | - 'phone', |
|
146 | - 'String', |
|
147 | - 'phone', |
|
148 | - esc_html__('Phone', 'event_espresso'), |
|
149 | - null, |
|
150 | - null, |
|
151 | - ['ee_edit_contacts'] |
|
152 | - ), |
|
153 | - new GraphQLOutputField( |
|
154 | - 'shortBio', |
|
155 | - 'String', |
|
156 | - 'short_bio', |
|
157 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
158 | - null, |
|
159 | - null, |
|
160 | - ['ee_edit_contacts'] |
|
161 | - ), |
|
162 | - new GraphQLOutputField( |
|
163 | - 'state', |
|
164 | - $this->namespace . 'State', |
|
165 | - null, |
|
166 | - esc_html__('State', 'event_espresso'), |
|
167 | - null, |
|
168 | - null, |
|
169 | - ['ee_edit_contacts'] |
|
170 | - ), |
|
171 | - new GraphQLOutputField( |
|
172 | - 'zip', |
|
173 | - 'String', |
|
174 | - 'zip', |
|
175 | - esc_html__('ZIP/Postal Code', 'event_espresso'), |
|
176 | - null, |
|
177 | - null, |
|
178 | - ['ee_edit_contacts'] |
|
179 | - ), |
|
180 | - ]; |
|
39 | + /** |
|
40 | + * @return GraphQLFieldInterface[] |
|
41 | + */ |
|
42 | + public function getFields(): array |
|
43 | + { |
|
44 | + $fields = [ |
|
45 | + new GraphQLField( |
|
46 | + 'id', |
|
47 | + ['non_null' => 'ID'], |
|
48 | + null, |
|
49 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLOutputField( |
|
52 | + 'dbId', |
|
53 | + ['non_null' => 'Int'], |
|
54 | + 'ID', |
|
55 | + esc_html__('The attendee ID.', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLOutputField( |
|
58 | + 'cacheId', |
|
59 | + ['non_null' => 'String'], |
|
60 | + null, |
|
61 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLOutputField( |
|
64 | + 'address', |
|
65 | + 'String', |
|
66 | + 'address', |
|
67 | + esc_html__('Address Part 1', 'event_espresso'), |
|
68 | + null, |
|
69 | + null, |
|
70 | + ['ee_edit_contacts'] |
|
71 | + ), |
|
72 | + new GraphQLOutputField( |
|
73 | + 'address2', |
|
74 | + 'String', |
|
75 | + 'address2', |
|
76 | + esc_html__('Address Part 2', 'event_espresso'), |
|
77 | + null, |
|
78 | + null, |
|
79 | + ['ee_edit_contacts'] |
|
80 | + ), |
|
81 | + new GraphQLOutputField( |
|
82 | + 'avatar', |
|
83 | + 'String', |
|
84 | + null, |
|
85 | + esc_html__('User avatar URL', 'event_espresso'), |
|
86 | + null, |
|
87 | + [$this, 'getAvatar'], |
|
88 | + ['ee_edit_contacts'] |
|
89 | + ), |
|
90 | + new GraphQLOutputField( |
|
91 | + 'bio', |
|
92 | + 'String', |
|
93 | + 'bio', |
|
94 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
95 | + null, |
|
96 | + null, |
|
97 | + ['ee_edit_contacts'] |
|
98 | + ), |
|
99 | + new GraphQLOutputField( |
|
100 | + 'city', |
|
101 | + 'String', |
|
102 | + 'city', |
|
103 | + esc_html__('City', 'event_espresso'), |
|
104 | + null, |
|
105 | + null, |
|
106 | + ['ee_edit_contacts'] |
|
107 | + ), |
|
108 | + new GraphQLOutputField( |
|
109 | + 'country', |
|
110 | + $this->namespace . 'Country', |
|
111 | + null, |
|
112 | + esc_html__('Country', 'event_espresso'), |
|
113 | + null, |
|
114 | + null, |
|
115 | + ['ee_edit_contacts'] |
|
116 | + ), |
|
117 | + new GraphQLOutputField( |
|
118 | + 'email', |
|
119 | + 'String', |
|
120 | + 'email', |
|
121 | + esc_html__('Email Address', 'event_espresso'), |
|
122 | + null, |
|
123 | + null, |
|
124 | + ['ee_edit_contacts'] |
|
125 | + ), |
|
126 | + new GraphQLOutputField( |
|
127 | + 'firstName', |
|
128 | + 'String', |
|
129 | + 'fname', |
|
130 | + esc_html__('Attendee First Name', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLOutputField( |
|
133 | + 'fullName', |
|
134 | + 'String', |
|
135 | + 'full_name', |
|
136 | + esc_html__('Attendee Name', 'event_espresso') |
|
137 | + ), |
|
138 | + new GraphQLOutputField( |
|
139 | + 'lastName', |
|
140 | + 'String', |
|
141 | + 'lname', |
|
142 | + esc_html__('Attendee Last Name', 'event_espresso') |
|
143 | + ), |
|
144 | + new GraphQLOutputField( |
|
145 | + 'phone', |
|
146 | + 'String', |
|
147 | + 'phone', |
|
148 | + esc_html__('Phone', 'event_espresso'), |
|
149 | + null, |
|
150 | + null, |
|
151 | + ['ee_edit_contacts'] |
|
152 | + ), |
|
153 | + new GraphQLOutputField( |
|
154 | + 'shortBio', |
|
155 | + 'String', |
|
156 | + 'short_bio', |
|
157 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
158 | + null, |
|
159 | + null, |
|
160 | + ['ee_edit_contacts'] |
|
161 | + ), |
|
162 | + new GraphQLOutputField( |
|
163 | + 'state', |
|
164 | + $this->namespace . 'State', |
|
165 | + null, |
|
166 | + esc_html__('State', 'event_espresso'), |
|
167 | + null, |
|
168 | + null, |
|
169 | + ['ee_edit_contacts'] |
|
170 | + ), |
|
171 | + new GraphQLOutputField( |
|
172 | + 'zip', |
|
173 | + 'String', |
|
174 | + 'zip', |
|
175 | + esc_html__('ZIP/Postal Code', 'event_espresso'), |
|
176 | + null, |
|
177 | + null, |
|
178 | + ['ee_edit_contacts'] |
|
179 | + ), |
|
180 | + ]; |
|
181 | 181 | |
182 | - return apply_filters( |
|
183 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields', |
|
184 | - $fields, |
|
185 | - $this->name, |
|
186 | - $this->model |
|
187 | - ); |
|
188 | - } |
|
182 | + return apply_filters( |
|
183 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields', |
|
184 | + $fields, |
|
185 | + $this->name, |
|
186 | + $this->model |
|
187 | + ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * @param EE_Attendee $source The source that's passed down the GraphQL queries |
|
193 | - * @param array $args The inputArgs on the field |
|
194 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
195 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
196 | - * @return string|null |
|
197 | - * @throws EE_Error |
|
198 | - */ |
|
199 | - public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string |
|
200 | - { |
|
201 | - $email = $source->email(); |
|
191 | + /** |
|
192 | + * @param EE_Attendee $source The source that's passed down the GraphQL queries |
|
193 | + * @param array $args The inputArgs on the field |
|
194 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
195 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
196 | + * @return string|null |
|
197 | + * @throws EE_Error |
|
198 | + */ |
|
199 | + public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string |
|
200 | + { |
|
201 | + $email = $source->email(); |
|
202 | 202 | |
203 | - if (empty($email)) { |
|
204 | - return get_avatar_url('', ['force_default' => true]); |
|
205 | - } |
|
206 | - $avatar = get_avatar_url($email); |
|
207 | - return $avatar ?: null; |
|
208 | - } |
|
203 | + if (empty($email)) { |
|
204 | + return get_avatar_url('', ['force_default' => true]); |
|
205 | + } |
|
206 | + $avatar = get_avatar_url($email); |
|
207 | + return $avatar ?: null; |
|
208 | + } |
|
209 | 209 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
81 | 81 | { |
82 | 82 | $fieldName = $info->fieldName; |
83 | - $field = $this->fields[ $fieldName ] ?? null; |
|
83 | + $field = $this->fields[$fieldName] ?? null; |
|
84 | 84 | // Field should exist in teh registered fields |
85 | 85 | if ($field instanceof GraphQLField) { |
86 | 86 | // check if the field should be resolved. |
87 | - if (! $field->shouldResolve()) { |
|
87 | + if ( ! $field->shouldResolve()) { |
|
88 | 88 | return null; |
89 | 89 | } |
90 | 90 | // Give priority to the internal resolver. |
91 | 91 | if ($field->hasInternalResolver()) { |
92 | 92 | return $field->resolve($source, $args, $context, $info); |
93 | 93 | } |
94 | - if (! ($source instanceof EE_Base_Class)) { |
|
94 | + if ( ! ($source instanceof EE_Base_Class)) { |
|
95 | 95 | return null; |
96 | 96 | } |
97 | 97 | // Check if the field has a key mapped to model. |
98 | - if (! empty($field->key())) { |
|
98 | + if ( ! empty($field->key())) { |
|
99 | 99 | $value = $source->{$field->key()}(); |
100 | 100 | return $field->mayBeFormatValue($value, $source); |
101 | 101 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function resolveId($source): ?string |
134 | 134 | { |
135 | - if (! $source instanceof EE_Base_Class) { |
|
135 | + if ( ! $source instanceof EE_Base_Class) { |
|
136 | 136 | return null; |
137 | 137 | } |
138 | 138 | // If the model has a UUID method |
@@ -37,260 +37,260 @@ |
||
37 | 37 | */ |
38 | 38 | class FieldResolver extends ResolverBase |
39 | 39 | { |
40 | - /** |
|
41 | - * @var EEM_Base $model |
|
42 | - */ |
|
43 | - protected $model; |
|
40 | + /** |
|
41 | + * @var EEM_Base $model |
|
42 | + */ |
|
43 | + protected $model; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var array $fields . |
|
47 | - */ |
|
48 | - protected $fields; |
|
45 | + /** |
|
46 | + * @var array $fields . |
|
47 | + */ |
|
48 | + protected $fields; |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * FieldResolver constructor. |
|
53 | - * |
|
54 | - * @param EEM_Base|null $model The model instance. |
|
55 | - * @param array $fields The fields registered for the type. |
|
56 | - */ |
|
57 | - public function __construct(EEM_Base $model = null, array $fields = []) |
|
58 | - { |
|
59 | - $this->model = $model; |
|
60 | - $this->fields = $fields; |
|
61 | - } |
|
51 | + /** |
|
52 | + * FieldResolver constructor. |
|
53 | + * |
|
54 | + * @param EEM_Base|null $model The model instance. |
|
55 | + * @param array $fields The fields registered for the type. |
|
56 | + */ |
|
57 | + public function __construct(EEM_Base $model = null, array $fields = []) |
|
58 | + { |
|
59 | + $this->model = $model; |
|
60 | + $this->fields = $fields; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
66 | - * @param array $args The inputArgs on the field |
|
67 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
68 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
69 | - * @return EE_Base_Class|Deferred|string |
|
70 | - * @throws EE_Error |
|
71 | - * @throws Exception |
|
72 | - * @throws InvalidArgumentException |
|
73 | - * @throws InvalidDataTypeException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - * @throws ReflectionException |
|
76 | - * @throws UserError |
|
77 | - * @throws UnexpectedEntityException |
|
78 | - */ |
|
79 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
80 | - { |
|
81 | - $fieldName = $info->fieldName; |
|
82 | - $field = $this->fields[ $fieldName ] ?? null; |
|
83 | - // Field should exist in teh registered fields |
|
84 | - if ($field instanceof GraphQLField) { |
|
85 | - // check if the field should be resolved. |
|
86 | - if (! $field->shouldResolve()) { |
|
87 | - return null; |
|
88 | - } |
|
89 | - // Give priority to the internal resolver. |
|
90 | - if ($field->hasInternalResolver()) { |
|
91 | - return $field->resolve($source, $args, $context, $info); |
|
92 | - } |
|
93 | - if (! ($source instanceof EE_Base_Class)) { |
|
94 | - return null; |
|
95 | - } |
|
96 | - // Check if the field has a key mapped to model. |
|
97 | - if (! empty($field->key())) { |
|
98 | - $value = $source->{$field->key()}(); |
|
99 | - return $field->mayBeFormatValue($value, $source); |
|
100 | - } |
|
101 | - switch ($fieldName) { |
|
102 | - case 'id': // the global ID |
|
103 | - return $this->resolveId($source); |
|
104 | - case 'cacheId': |
|
105 | - return $this->resolveCacheId($source); |
|
106 | - case 'parent': |
|
107 | - return $this->resolveParent($source); |
|
108 | - case 'event': |
|
109 | - return $this->resolveEvent($source, $args, $context); |
|
110 | - case 'wpUser': |
|
111 | - case 'manager': |
|
112 | - return $this->resolveWpUser($source, $args, $context); |
|
113 | - case 'userId': |
|
114 | - return $this->resolveUserId($source, $args, $context); |
|
115 | - case 'state': // Venue |
|
116 | - return $this->resolveState($source); |
|
117 | - case 'country': // State, Venue |
|
118 | - return $this->resolveCountry($source); |
|
119 | - } |
|
120 | - } |
|
121 | - return null; |
|
122 | - } |
|
64 | + /** |
|
65 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
66 | + * @param array $args The inputArgs on the field |
|
67 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
68 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
69 | + * @return EE_Base_Class|Deferred|string |
|
70 | + * @throws EE_Error |
|
71 | + * @throws Exception |
|
72 | + * @throws InvalidArgumentException |
|
73 | + * @throws InvalidDataTypeException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + * @throws ReflectionException |
|
76 | + * @throws UserError |
|
77 | + * @throws UnexpectedEntityException |
|
78 | + */ |
|
79 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
80 | + { |
|
81 | + $fieldName = $info->fieldName; |
|
82 | + $field = $this->fields[ $fieldName ] ?? null; |
|
83 | + // Field should exist in teh registered fields |
|
84 | + if ($field instanceof GraphQLField) { |
|
85 | + // check if the field should be resolved. |
|
86 | + if (! $field->shouldResolve()) { |
|
87 | + return null; |
|
88 | + } |
|
89 | + // Give priority to the internal resolver. |
|
90 | + if ($field->hasInternalResolver()) { |
|
91 | + return $field->resolve($source, $args, $context, $info); |
|
92 | + } |
|
93 | + if (! ($source instanceof EE_Base_Class)) { |
|
94 | + return null; |
|
95 | + } |
|
96 | + // Check if the field has a key mapped to model. |
|
97 | + if (! empty($field->key())) { |
|
98 | + $value = $source->{$field->key()}(); |
|
99 | + return $field->mayBeFormatValue($value, $source); |
|
100 | + } |
|
101 | + switch ($fieldName) { |
|
102 | + case 'id': // the global ID |
|
103 | + return $this->resolveId($source); |
|
104 | + case 'cacheId': |
|
105 | + return $this->resolveCacheId($source); |
|
106 | + case 'parent': |
|
107 | + return $this->resolveParent($source); |
|
108 | + case 'event': |
|
109 | + return $this->resolveEvent($source, $args, $context); |
|
110 | + case 'wpUser': |
|
111 | + case 'manager': |
|
112 | + return $this->resolveWpUser($source, $args, $context); |
|
113 | + case 'userId': |
|
114 | + return $this->resolveUserId($source, $args, $context); |
|
115 | + case 'state': // Venue |
|
116 | + return $this->resolveState($source); |
|
117 | + case 'country': // State, Venue |
|
118 | + return $this->resolveCountry($source); |
|
119 | + } |
|
120 | + } |
|
121 | + return null; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Resolve the global ID |
|
127 | - * |
|
128 | - * @param mixed $source |
|
129 | - * @return string|null |
|
130 | - * @throws Exception |
|
131 | - */ |
|
132 | - public function resolveId($source): ?string |
|
133 | - { |
|
134 | - if (! $source instanceof EE_Base_Class) { |
|
135 | - return null; |
|
136 | - } |
|
137 | - // If the model has a UUID method |
|
138 | - if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) { |
|
139 | - return $source->UUID(); |
|
140 | - } |
|
125 | + /** |
|
126 | + * Resolve the global ID |
|
127 | + * |
|
128 | + * @param mixed $source |
|
129 | + * @return string|null |
|
130 | + * @throws Exception |
|
131 | + */ |
|
132 | + public function resolveId($source): ?string |
|
133 | + { |
|
134 | + if (! $source instanceof EE_Base_Class) { |
|
135 | + return null; |
|
136 | + } |
|
137 | + // If the model has a UUID method |
|
138 | + if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) { |
|
139 | + return $source->UUID(); |
|
140 | + } |
|
141 | 141 | |
142 | - return Relay::toGlobalId($this->model->item_name(), $source->ID()); |
|
143 | - } |
|
142 | + return Relay::toGlobalId($this->model->item_name(), $source->ID()); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * Resolve the cache ID |
|
148 | - * |
|
149 | - * @param mixed $source |
|
150 | - * @return string |
|
151 | - */ |
|
152 | - public function resolveCacheId($source): string |
|
153 | - { |
|
154 | - $model_name = $this->model->item_name(); |
|
155 | - $ID = $source->ID(); |
|
156 | - // Since cacheId does not need to be globally unique |
|
157 | - // $uniqid is sufficient, still adding the model name and ID |
|
158 | - // may be we need/use them in future. |
|
159 | - return uniqid("{$model_name}:{$ID}:", true); |
|
160 | - } |
|
146 | + /** |
|
147 | + * Resolve the cache ID |
|
148 | + * |
|
149 | + * @param mixed $source |
|
150 | + * @return string |
|
151 | + */ |
|
152 | + public function resolveCacheId($source): string |
|
153 | + { |
|
154 | + $model_name = $this->model->item_name(); |
|
155 | + $ID = $source->ID(); |
|
156 | + // Since cacheId does not need to be globally unique |
|
157 | + // $uniqid is sufficient, still adding the model name and ID |
|
158 | + // may be we need/use them in future. |
|
159 | + return uniqid("{$model_name}:{$ID}:", true); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * @param mixed $source |
|
165 | - * @param $args |
|
166 | - * @param $context |
|
167 | - * @return Deferred|null |
|
168 | - * @throws Exception |
|
169 | - */ |
|
170 | - public function resolveWpUser($source, $args, $context): ?Deferred |
|
171 | - { |
|
172 | - $user_id = $source->wp_user(); |
|
173 | - return $user_id |
|
174 | - ? $context->get_loader('user')->load_deferred($user_id) |
|
175 | - : null; |
|
176 | - } |
|
163 | + /** |
|
164 | + * @param mixed $source |
|
165 | + * @param $args |
|
166 | + * @param $context |
|
167 | + * @return Deferred|null |
|
168 | + * @throws Exception |
|
169 | + */ |
|
170 | + public function resolveWpUser($source, $args, $context): ?Deferred |
|
171 | + { |
|
172 | + $user_id = $source->wp_user(); |
|
173 | + return $user_id |
|
174 | + ? $context->get_loader('user')->load_deferred($user_id) |
|
175 | + : null; |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | - /** |
|
180 | - * @param mixed $source |
|
181 | - * @param $args |
|
182 | - * @param $context |
|
183 | - * @return string|null |
|
184 | - * @throws Exception |
|
185 | - */ |
|
186 | - public function resolveUserId($source, $args, $context): ?string |
|
187 | - { |
|
188 | - $user_id = $source->wp_user(); |
|
189 | - return $user_id |
|
190 | - ? Relay::toGlobalId('user', $user_id) |
|
191 | - : null; |
|
192 | - } |
|
179 | + /** |
|
180 | + * @param mixed $source |
|
181 | + * @param $args |
|
182 | + * @param $context |
|
183 | + * @return string|null |
|
184 | + * @throws Exception |
|
185 | + */ |
|
186 | + public function resolveUserId($source, $args, $context): ?string |
|
187 | + { |
|
188 | + $user_id = $source->wp_user(); |
|
189 | + return $user_id |
|
190 | + ? Relay::toGlobalId('user', $user_id) |
|
191 | + : null; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | - /** |
|
196 | - * @param mixed $source |
|
197 | - * @return EE_Base_Class|null |
|
198 | - * @throws InvalidArgumentException |
|
199 | - * @throws InvalidDataTypeException |
|
200 | - * @throws InvalidInterfaceException |
|
201 | - * @throws EE_Error |
|
202 | - */ |
|
203 | - public function resolveParent($source): ?EE_Base_Class |
|
204 | - { |
|
205 | - return $this->model->get_one_by_ID($source->parent()); |
|
206 | - } |
|
195 | + /** |
|
196 | + * @param mixed $source |
|
197 | + * @return EE_Base_Class|null |
|
198 | + * @throws InvalidArgumentException |
|
199 | + * @throws InvalidDataTypeException |
|
200 | + * @throws InvalidInterfaceException |
|
201 | + * @throws EE_Error |
|
202 | + */ |
|
203 | + public function resolveParent($source): ?EE_Base_Class |
|
204 | + { |
|
205 | + return $this->model->get_one_by_ID($source->parent()); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | - /** |
|
210 | - * @param mixed $source |
|
211 | - * @param $args |
|
212 | - * @param $context |
|
213 | - * @return Deferred|null |
|
214 | - * @throws EE_Error |
|
215 | - * @throws InvalidArgumentException |
|
216 | - * @throws InvalidDataTypeException |
|
217 | - * @throws InvalidInterfaceException |
|
218 | - * @throws ReflectionException |
|
219 | - * @throws UserError |
|
220 | - * @throws UnexpectedEntityException |
|
221 | - */ |
|
222 | - public function resolveEvent($source, $args, $context): ?Deferred |
|
223 | - { |
|
224 | - switch (true) { |
|
225 | - case $source instanceof EE_Datetime: |
|
226 | - $event = $source->event(); |
|
227 | - break; |
|
228 | - case $source instanceof EE_Venue: |
|
229 | - case $source instanceof EE_Ticket: |
|
230 | - $event = $source->get_related_event(); |
|
231 | - break; |
|
232 | - default: |
|
233 | - $event = null; |
|
234 | - break; |
|
235 | - } |
|
236 | - return $event instanceof EE_Event |
|
237 | - ? $context->get_loader('post')->load_deferred($event->ID()) |
|
238 | - : null; |
|
239 | - } |
|
209 | + /** |
|
210 | + * @param mixed $source |
|
211 | + * @param $args |
|
212 | + * @param $context |
|
213 | + * @return Deferred|null |
|
214 | + * @throws EE_Error |
|
215 | + * @throws InvalidArgumentException |
|
216 | + * @throws InvalidDataTypeException |
|
217 | + * @throws InvalidInterfaceException |
|
218 | + * @throws ReflectionException |
|
219 | + * @throws UserError |
|
220 | + * @throws UnexpectedEntityException |
|
221 | + */ |
|
222 | + public function resolveEvent($source, $args, $context): ?Deferred |
|
223 | + { |
|
224 | + switch (true) { |
|
225 | + case $source instanceof EE_Datetime: |
|
226 | + $event = $source->event(); |
|
227 | + break; |
|
228 | + case $source instanceof EE_Venue: |
|
229 | + case $source instanceof EE_Ticket: |
|
230 | + $event = $source->get_related_event(); |
|
231 | + break; |
|
232 | + default: |
|
233 | + $event = null; |
|
234 | + break; |
|
235 | + } |
|
236 | + return $event instanceof EE_Event |
|
237 | + ? $context->get_loader('post')->load_deferred($event->ID()) |
|
238 | + : null; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * @param mixed $source The source instance. |
|
244 | - * @return EE_Base_Class|null |
|
245 | - * @throws EE_Error |
|
246 | - * @throws InvalidArgumentException |
|
247 | - * @throws InvalidDataTypeException |
|
248 | - * @throws InvalidInterfaceException |
|
249 | - * @throws ReflectionException |
|
250 | - */ |
|
251 | - public function resolveState($source): ?EE_Base_Class |
|
252 | - { |
|
253 | - switch (true) { |
|
254 | - case $source instanceof EE_Attendee: |
|
255 | - case $source instanceof EE_Venue: |
|
256 | - $state_id = $source->state_ID(); |
|
257 | - break; |
|
258 | - default: |
|
259 | - $state_id = null; |
|
260 | - break; |
|
261 | - } |
|
262 | - return $state_id |
|
263 | - ? EEM_State::instance()->get_one_by_ID($state_id) |
|
264 | - : null; |
|
265 | - } |
|
242 | + /** |
|
243 | + * @param mixed $source The source instance. |
|
244 | + * @return EE_Base_Class|null |
|
245 | + * @throws EE_Error |
|
246 | + * @throws InvalidArgumentException |
|
247 | + * @throws InvalidDataTypeException |
|
248 | + * @throws InvalidInterfaceException |
|
249 | + * @throws ReflectionException |
|
250 | + */ |
|
251 | + public function resolveState($source): ?EE_Base_Class |
|
252 | + { |
|
253 | + switch (true) { |
|
254 | + case $source instanceof EE_Attendee: |
|
255 | + case $source instanceof EE_Venue: |
|
256 | + $state_id = $source->state_ID(); |
|
257 | + break; |
|
258 | + default: |
|
259 | + $state_id = null; |
|
260 | + break; |
|
261 | + } |
|
262 | + return $state_id |
|
263 | + ? EEM_State::instance()->get_one_by_ID($state_id) |
|
264 | + : null; |
|
265 | + } |
|
266 | 266 | |
267 | 267 | |
268 | - /** |
|
269 | - * @param mixed $source The source instance. |
|
270 | - * @return EE_Base_Class|null |
|
271 | - * @throws EE_Error |
|
272 | - * @throws InvalidArgumentException |
|
273 | - * @throws InvalidDataTypeException |
|
274 | - * @throws InvalidInterfaceException |
|
275 | - * @throws ReflectionException |
|
276 | - */ |
|
277 | - public function resolveCountry($source): ?EE_Base_Class |
|
278 | - { |
|
279 | - switch (true) { |
|
280 | - case $source instanceof EE_State: |
|
281 | - $country_iso = $source->country_iso(); |
|
282 | - break; |
|
283 | - case $source instanceof EE_Attendee: |
|
284 | - case $source instanceof EE_Venue: |
|
285 | - $country_iso = $source->country_ID(); |
|
286 | - break; |
|
287 | - default: |
|
288 | - $country_iso = null; |
|
289 | - break; |
|
290 | - } |
|
268 | + /** |
|
269 | + * @param mixed $source The source instance. |
|
270 | + * @return EE_Base_Class|null |
|
271 | + * @throws EE_Error |
|
272 | + * @throws InvalidArgumentException |
|
273 | + * @throws InvalidDataTypeException |
|
274 | + * @throws InvalidInterfaceException |
|
275 | + * @throws ReflectionException |
|
276 | + */ |
|
277 | + public function resolveCountry($source): ?EE_Base_Class |
|
278 | + { |
|
279 | + switch (true) { |
|
280 | + case $source instanceof EE_State: |
|
281 | + $country_iso = $source->country_iso(); |
|
282 | + break; |
|
283 | + case $source instanceof EE_Attendee: |
|
284 | + case $source instanceof EE_Venue: |
|
285 | + $country_iso = $source->country_ID(); |
|
286 | + break; |
|
287 | + default: |
|
288 | + $country_iso = null; |
|
289 | + break; |
|
290 | + } |
|
291 | 291 | |
292 | - return $country_iso |
|
293 | - ? EEM_Country::instance()->get_one_by_ID($country_iso) |
|
294 | - : null; |
|
295 | - } |
|
292 | + return $country_iso |
|
293 | + ? EEM_Country::instance()->get_one_by_ID($country_iso) |
|
294 | + : null; |
|
295 | + } |
|
296 | 296 | } |