@@ -16,66 +16,66 @@ |
||
16 | 16 | */ |
17 | 17 | class ExitModal |
18 | 18 | { |
19 | - const TYPE_FORM_URL = 'https://eventespresso.typeform.com/to/O1DDym'; |
|
19 | + const TYPE_FORM_URL = 'https://eventespresso.typeform.com/to/O1DDym'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * ExitModal constructor. |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - } |
|
21 | + /** |
|
22 | + * ExitModal constructor. |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - * @since $VID:$ |
|
32 | - */ |
|
33 | - public function getExitSurveyInfo() |
|
34 | - { |
|
35 | - $current_user = new WP_User(get_current_user_id()); |
|
36 | - $query_args = [ |
|
37 | - 'emailAddress' => htmlspecialchars($current_user->user_email), |
|
38 | - 'website' => htmlspecialchars(site_url()), |
|
39 | - ]; |
|
40 | - // add user's first name if one exists |
|
41 | - $first_name = $current_user->user_firstname; |
|
42 | - if ($first_name) { |
|
43 | - $query_args['firstName'] = htmlspecialchars($first_name); |
|
44 | - } |
|
45 | - return [ |
|
46 | - 'isModalActive' => $this->isModalActive(), |
|
47 | - 'typeFormUrl' => add_query_arg($query_args, ExitModal::TYPE_FORM_URL) |
|
48 | - ]; |
|
49 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + * @since $VID:$ |
|
32 | + */ |
|
33 | + public function getExitSurveyInfo() |
|
34 | + { |
|
35 | + $current_user = new WP_User(get_current_user_id()); |
|
36 | + $query_args = [ |
|
37 | + 'emailAddress' => htmlspecialchars($current_user->user_email), |
|
38 | + 'website' => htmlspecialchars(site_url()), |
|
39 | + ]; |
|
40 | + // add user's first name if one exists |
|
41 | + $first_name = $current_user->user_firstname; |
|
42 | + if ($first_name) { |
|
43 | + $query_args['firstName'] = htmlspecialchars($first_name); |
|
44 | + } |
|
45 | + return [ |
|
46 | + 'isModalActive' => $this->isModalActive(), |
|
47 | + 'typeFormUrl' => add_query_arg($query_args, ExitModal::TYPE_FORM_URL) |
|
48 | + ]; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
54 | - * @return bool |
|
55 | - */ |
|
56 | - private function isModalActive() |
|
57 | - { |
|
58 | - return filter_var( |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
61 | - true |
|
62 | - ), |
|
63 | - FILTER_VALIDATE_BOOLEAN |
|
64 | - ); |
|
65 | - } |
|
52 | + /** |
|
53 | + * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | + private function isModalActive() |
|
57 | + { |
|
58 | + return filter_var( |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
61 | + true |
|
62 | + ), |
|
63 | + FILTER_VALIDATE_BOOLEAN |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @deprecated $VID:$ |
|
70 | - */ |
|
71 | - public function modalContainer() |
|
72 | - { |
|
73 | - } |
|
68 | + /** |
|
69 | + * @deprecated $VID:$ |
|
70 | + */ |
|
71 | + public function modalContainer() |
|
72 | + { |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @deprecated $VID:$ |
|
77 | - */ |
|
78 | - public function enqueues() |
|
79 | - { |
|
80 | - } |
|
75 | + /** |
|
76 | + * @deprecated $VID:$ |
|
77 | + */ |
|
78 | + public function enqueues() |
|
79 | + { |
|
80 | + } |
|
81 | 81 | } |
@@ -21,150 +21,150 @@ |
||
21 | 21 | */ |
22 | 22 | class EventEditorGraphQLData |
23 | 23 | { |
24 | - /** |
|
25 | - * @var Event |
|
26 | - */ |
|
27 | - protected $event; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var Datetimes |
|
31 | - */ |
|
32 | - protected $datetimes; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var Prices |
|
36 | - */ |
|
37 | - protected $prices; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var PriceTypes |
|
41 | - */ |
|
42 | - protected $price_types; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var Tickets |
|
46 | - */ |
|
47 | - protected $tickets; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var EventEntityRelations |
|
51 | - */ |
|
52 | - protected $relations; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var EventManagerData |
|
56 | - */ |
|
57 | - protected $managers; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var NewEventDefaultEntities |
|
61 | - */ |
|
62 | - protected $default_entities; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var TicketMeta |
|
66 | - */ |
|
67 | - protected $ticket_meta; |
|
68 | - |
|
69 | - /** |
|
70 | - * @var FormBuilder |
|
71 | - */ |
|
72 | - protected $form_builder; |
|
73 | - |
|
74 | - /** |
|
75 | - * @var Venues |
|
76 | - */ |
|
77 | - protected $venues; |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * EventEditorGraphQLData constructor. |
|
82 | - * |
|
83 | - * @param Datetimes $datetimes |
|
84 | - * @param Event $event |
|
85 | - * @param Prices $prices |
|
86 | - * @param PriceTypes $price_types |
|
87 | - * @param Tickets $tickets |
|
88 | - * @param EventEntityRelations $relations |
|
89 | - * @param EventManagerData $managers |
|
90 | - * @param NewEventDefaultEntities $default_entities |
|
91 | - * @param TicketMeta $ticket_meta |
|
92 | - * @param FormBuilder $form_builder |
|
93 | - * @param Venues $venues |
|
94 | - */ |
|
95 | - public function __construct( |
|
96 | - Datetimes $datetimes, |
|
97 | - Event $event, |
|
98 | - Prices $prices, |
|
99 | - PriceTypes $price_types, |
|
100 | - Tickets $tickets, |
|
101 | - EventEntityRelations $relations, |
|
102 | - EventManagerData $managers, |
|
103 | - NewEventDefaultEntities $default_entities, |
|
104 | - TicketMeta $ticket_meta, |
|
105 | - FormBuilder $form_builder, |
|
106 | - Venues $venues |
|
107 | - ) { |
|
108 | - $this->datetimes = $datetimes; |
|
109 | - $this->event = $event; |
|
110 | - $this->default_entities = $default_entities; |
|
111 | - $this->prices = $prices; |
|
112 | - $this->price_types = $price_types; |
|
113 | - $this->managers = $managers; |
|
114 | - $this->relations = $relations; |
|
115 | - $this->tickets = $tickets; |
|
116 | - $this->ticket_meta = $ticket_meta; |
|
117 | - $this->form_builder = $form_builder; |
|
118 | - $this->venues = $venues; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @param int $eventId |
|
124 | - * @return array |
|
125 | - * @throws EE_Error |
|
126 | - * @throws ReflectionException |
|
127 | - * @since $VID:$ |
|
128 | - */ |
|
129 | - public function getData(int $eventId) |
|
130 | - { |
|
131 | - $this->default_entities->getData($eventId); |
|
132 | - $event = $this->event->getData(['id' => $eventId]); |
|
133 | - $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
134 | - $eventManagers = $this->managers ->getData($eventId); |
|
135 | - |
|
136 | - $tickets = $this->tickets->getData([ |
|
137 | - 'eventId' => $eventId, |
|
138 | - 'includeDefaultTickets' => true, |
|
139 | - ]); |
|
140 | - |
|
141 | - $prices = $this->prices->getData([ |
|
142 | - 'eventId' => $eventId, |
|
143 | - 'includeDefaultTicketsPrices' => true, |
|
144 | - 'includeDefaultPrices' => true, |
|
145 | - ]); |
|
146 | - |
|
147 | - $priceTypes = $this->price_types->getData(); |
|
148 | - |
|
149 | - $relations = $this->relations->getData($eventId); |
|
150 | - |
|
151 | - $ticketMeta = $this->ticket_meta->getData($eventId); |
|
152 | - |
|
153 | - $formBuilder = $this->form_builder->getData($eventId); |
|
154 | - |
|
155 | - $venues = $this->venues->getData(); |
|
156 | - |
|
157 | - return compact( |
|
158 | - 'datetimes', |
|
159 | - 'event', |
|
160 | - 'eventManagers', |
|
161 | - 'formBuilder', |
|
162 | - 'prices', |
|
163 | - 'priceTypes', |
|
164 | - 'relations', |
|
165 | - 'tickets', |
|
166 | - 'ticketMeta', |
|
167 | - 'venues' |
|
168 | - ); |
|
169 | - } |
|
24 | + /** |
|
25 | + * @var Event |
|
26 | + */ |
|
27 | + protected $event; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var Datetimes |
|
31 | + */ |
|
32 | + protected $datetimes; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var Prices |
|
36 | + */ |
|
37 | + protected $prices; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var PriceTypes |
|
41 | + */ |
|
42 | + protected $price_types; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var Tickets |
|
46 | + */ |
|
47 | + protected $tickets; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var EventEntityRelations |
|
51 | + */ |
|
52 | + protected $relations; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var EventManagerData |
|
56 | + */ |
|
57 | + protected $managers; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var NewEventDefaultEntities |
|
61 | + */ |
|
62 | + protected $default_entities; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var TicketMeta |
|
66 | + */ |
|
67 | + protected $ticket_meta; |
|
68 | + |
|
69 | + /** |
|
70 | + * @var FormBuilder |
|
71 | + */ |
|
72 | + protected $form_builder; |
|
73 | + |
|
74 | + /** |
|
75 | + * @var Venues |
|
76 | + */ |
|
77 | + protected $venues; |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * EventEditorGraphQLData constructor. |
|
82 | + * |
|
83 | + * @param Datetimes $datetimes |
|
84 | + * @param Event $event |
|
85 | + * @param Prices $prices |
|
86 | + * @param PriceTypes $price_types |
|
87 | + * @param Tickets $tickets |
|
88 | + * @param EventEntityRelations $relations |
|
89 | + * @param EventManagerData $managers |
|
90 | + * @param NewEventDefaultEntities $default_entities |
|
91 | + * @param TicketMeta $ticket_meta |
|
92 | + * @param FormBuilder $form_builder |
|
93 | + * @param Venues $venues |
|
94 | + */ |
|
95 | + public function __construct( |
|
96 | + Datetimes $datetimes, |
|
97 | + Event $event, |
|
98 | + Prices $prices, |
|
99 | + PriceTypes $price_types, |
|
100 | + Tickets $tickets, |
|
101 | + EventEntityRelations $relations, |
|
102 | + EventManagerData $managers, |
|
103 | + NewEventDefaultEntities $default_entities, |
|
104 | + TicketMeta $ticket_meta, |
|
105 | + FormBuilder $form_builder, |
|
106 | + Venues $venues |
|
107 | + ) { |
|
108 | + $this->datetimes = $datetimes; |
|
109 | + $this->event = $event; |
|
110 | + $this->default_entities = $default_entities; |
|
111 | + $this->prices = $prices; |
|
112 | + $this->price_types = $price_types; |
|
113 | + $this->managers = $managers; |
|
114 | + $this->relations = $relations; |
|
115 | + $this->tickets = $tickets; |
|
116 | + $this->ticket_meta = $ticket_meta; |
|
117 | + $this->form_builder = $form_builder; |
|
118 | + $this->venues = $venues; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @param int $eventId |
|
124 | + * @return array |
|
125 | + * @throws EE_Error |
|
126 | + * @throws ReflectionException |
|
127 | + * @since $VID:$ |
|
128 | + */ |
|
129 | + public function getData(int $eventId) |
|
130 | + { |
|
131 | + $this->default_entities->getData($eventId); |
|
132 | + $event = $this->event->getData(['id' => $eventId]); |
|
133 | + $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
134 | + $eventManagers = $this->managers ->getData($eventId); |
|
135 | + |
|
136 | + $tickets = $this->tickets->getData([ |
|
137 | + 'eventId' => $eventId, |
|
138 | + 'includeDefaultTickets' => true, |
|
139 | + ]); |
|
140 | + |
|
141 | + $prices = $this->prices->getData([ |
|
142 | + 'eventId' => $eventId, |
|
143 | + 'includeDefaultTicketsPrices' => true, |
|
144 | + 'includeDefaultPrices' => true, |
|
145 | + ]); |
|
146 | + |
|
147 | + $priceTypes = $this->price_types->getData(); |
|
148 | + |
|
149 | + $relations = $this->relations->getData($eventId); |
|
150 | + |
|
151 | + $ticketMeta = $this->ticket_meta->getData($eventId); |
|
152 | + |
|
153 | + $formBuilder = $this->form_builder->getData($eventId); |
|
154 | + |
|
155 | + $venues = $this->venues->getData(); |
|
156 | + |
|
157 | + return compact( |
|
158 | + 'datetimes', |
|
159 | + 'event', |
|
160 | + 'eventManagers', |
|
161 | + 'formBuilder', |
|
162 | + 'prices', |
|
163 | + 'priceTypes', |
|
164 | + 'relations', |
|
165 | + 'tickets', |
|
166 | + 'ticketMeta', |
|
167 | + 'venues' |
|
168 | + ); |
|
169 | + } |
|
170 | 170 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | interface EventEditorDataInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * @param int $eventId |
|
17 | - * @return array |
|
18 | - * @since $VID:$ |
|
19 | - */ |
|
20 | - public function getData(int $eventId); |
|
15 | + /** |
|
16 | + * @param int $eventId |
|
17 | + * @return array |
|
18 | + * @since $VID:$ |
|
19 | + */ |
|
20 | + public function getData(int $eventId); |
|
21 | 21 | } |
@@ -37,86 +37,86 @@ |
||
37 | 37 | */ |
38 | 38 | class AdvancedEditorAdminFormSection |
39 | 39 | { |
40 | - /** |
|
41 | - * @var EE_Admin_Config |
|
42 | - */ |
|
43 | - protected $admin_config; |
|
40 | + /** |
|
41 | + * @var EE_Admin_Config |
|
42 | + */ |
|
43 | + protected $admin_config; |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * AdvancedEditorAdminForm constructor. |
|
48 | - * |
|
49 | - * @param EE_Admin_Config $admin_config |
|
50 | - */ |
|
51 | - public function __construct(EE_Admin_Config $admin_config) |
|
52 | - { |
|
53 | - $this->admin_config = $admin_config; |
|
54 | - add_filter( |
|
55 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
56 | - [$this, 'mergeFormSubsections'] |
|
57 | - ); |
|
58 | - add_action( |
|
59 | - 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
60 | - [$this, 'updateAdminFormSettings'], |
|
61 | - 10, |
|
62 | - 2 |
|
63 | - ); |
|
64 | - } |
|
46 | + /** |
|
47 | + * AdvancedEditorAdminForm constructor. |
|
48 | + * |
|
49 | + * @param EE_Admin_Config $admin_config |
|
50 | + */ |
|
51 | + public function __construct(EE_Admin_Config $admin_config) |
|
52 | + { |
|
53 | + $this->admin_config = $admin_config; |
|
54 | + add_filter( |
|
55 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
56 | + [$this, 'mergeFormSubsections'] |
|
57 | + ); |
|
58 | + add_action( |
|
59 | + 'AHEE__Events_Admin_Page___update_default_event_settings', |
|
60 | + [$this, 'updateAdminFormSettings'], |
|
61 | + 10, |
|
62 | + 2 |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * @param array $default_event_settings_form_subsections |
|
69 | - * @return array |
|
70 | - * @since $VID:$ |
|
71 | - */ |
|
72 | - public function mergeFormSubsections(array $default_event_settings_form_subsections) |
|
73 | - { |
|
74 | - return [ |
|
75 | - 'new_features_section_header' => new EE_Form_Section_HTML( |
|
76 | - EEH_HTML::h2( |
|
77 | - esc_html__('New Feature', 'event_espresso'), |
|
78 | - '', |
|
79 | - 'ee-admin-settings-hdr ee-admin-settings-hdr--new-feature' |
|
80 | - ) |
|
81 | - ), |
|
82 | - 'use_advanced_editor' => new EE_Select_Input( |
|
83 | - apply_filters( |
|
84 | - 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options', |
|
85 | - [ |
|
86 | - esc_html__('Legacy Editor', 'event_espresso'), |
|
87 | - esc_html__('Advanced Editor', 'event_espresso'), |
|
88 | - ] |
|
89 | - ), |
|
90 | - apply_filters( |
|
91 | - 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings', |
|
92 | - [ |
|
93 | - 'default' => $this->admin_config->useAdvancedEditor(), |
|
94 | - 'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'), |
|
95 | - 'html_help_text' => sprintf( |
|
96 | - esc_html__( |
|
97 | - 'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.', |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - '<br />' |
|
101 | - ), |
|
102 | - ] |
|
103 | - ) |
|
104 | - ), |
|
105 | - ] + $default_event_settings_form_subsections; |
|
106 | - } |
|
67 | + /** |
|
68 | + * @param array $default_event_settings_form_subsections |
|
69 | + * @return array |
|
70 | + * @since $VID:$ |
|
71 | + */ |
|
72 | + public function mergeFormSubsections(array $default_event_settings_form_subsections) |
|
73 | + { |
|
74 | + return [ |
|
75 | + 'new_features_section_header' => new EE_Form_Section_HTML( |
|
76 | + EEH_HTML::h2( |
|
77 | + esc_html__('New Feature', 'event_espresso'), |
|
78 | + '', |
|
79 | + 'ee-admin-settings-hdr ee-admin-settings-hdr--new-feature' |
|
80 | + ) |
|
81 | + ), |
|
82 | + 'use_advanced_editor' => new EE_Select_Input( |
|
83 | + apply_filters( |
|
84 | + 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_answer_options', |
|
85 | + [ |
|
86 | + esc_html__('Legacy Editor', 'event_espresso'), |
|
87 | + esc_html__('Advanced Editor', 'event_espresso'), |
|
88 | + ] |
|
89 | + ), |
|
90 | + apply_filters( |
|
91 | + 'FHEE__Events_Admin_Page___default_event_settings_form__advanced_editor_input_settings', |
|
92 | + [ |
|
93 | + 'default' => $this->admin_config->useAdvancedEditor(), |
|
94 | + 'html_label_text' => esc_html__('Activate Advanced Editor?', 'event_espresso'), |
|
95 | + 'html_help_text' => sprintf( |
|
96 | + esc_html__( |
|
97 | + 'Controls whether the Event Espresso Event Editor continues to use the existing legacy editor that functions like the typical older WordPress admin you are used to,%1$sor uses the new Advanced Editor with a more powerful and easier to use interface. This may be automatically turned on in order to utilize advanced features from new addons.', |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + '<br />' |
|
101 | + ), |
|
102 | + ] |
|
103 | + ) |
|
104 | + ), |
|
105 | + ] + $default_event_settings_form_subsections; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * @param array $valid_data |
|
111 | - * @param EE_Config $config |
|
112 | - * @since $VID:$ |
|
113 | - */ |
|
114 | - public function updateAdminFormSettings(array $valid_data, EE_Config $config) |
|
115 | - { |
|
116 | - $config->admin->setUseAdvancedEditor( |
|
117 | - isset($valid_data['use_advanced_editor']) |
|
118 | - ? $valid_data['use_advanced_editor'] |
|
119 | - : false |
|
120 | - ); |
|
121 | - } |
|
109 | + /** |
|
110 | + * @param array $valid_data |
|
111 | + * @param EE_Config $config |
|
112 | + * @since $VID:$ |
|
113 | + */ |
|
114 | + public function updateAdminFormSettings(array $valid_data, EE_Config $config) |
|
115 | + { |
|
116 | + $config->admin->setUseAdvancedEditor( |
|
117 | + isset($valid_data['use_advanced_editor']) |
|
118 | + ? $valid_data['use_advanced_editor'] |
|
119 | + : false |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | } |
@@ -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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 | } |
@@ -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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 | } |
@@ -31,171 +31,171 @@ |
||
31 | 31 | */ |
32 | 32 | class RootQuery extends TypeBase |
33 | 33 | { |
34 | - /** |
|
35 | - * RootQuery constructor. |
|
36 | - */ |
|
37 | - public function __construct() |
|
38 | - { |
|
39 | - $this->setName('RootQuery'); |
|
40 | - $this->setIsCustomPostType(true); |
|
41 | - parent::__construct(); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @return GraphQLFieldInterface[] |
|
47 | - */ |
|
48 | - public function getFields(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - new GraphQLOutputField( |
|
52 | - lcfirst($this->namespace) . 'EventRelations', |
|
53 | - 'String', |
|
54 | - null, |
|
55 | - esc_html__('JSON encoded relational data of the models', 'event_espresso'), |
|
56 | - null, |
|
57 | - [$this, 'getEventRelationalData'], |
|
58 | - [], |
|
59 | - [ |
|
60 | - 'eventId' => [ |
|
61 | - 'type' => ['non_null' => 'Int'], |
|
62 | - 'description' => esc_html__('The event ID to get the relational data for.', 'event_espresso'), |
|
63 | - ], |
|
64 | - ] |
|
65 | - ), |
|
66 | - new GraphQLOutputField( |
|
67 | - lcfirst($this->namespace) . 'Datetime', |
|
68 | - $this->namespace . 'Datetime', |
|
69 | - null, |
|
70 | - esc_html__('A datetime', 'event_espresso'), |
|
71 | - null, |
|
72 | - [$this, 'getDatetime'], |
|
73 | - [], |
|
74 | - [ |
|
75 | - 'id' => [ |
|
76 | - 'type' => [ |
|
77 | - 'non_null' => 'ID', |
|
78 | - ], |
|
79 | - 'description' => esc_html__('The globally unique identifier of the datetime.', 'event_espresso'), |
|
80 | - ], |
|
81 | - ] |
|
82 | - ), |
|
83 | - new GraphQLOutputField( |
|
84 | - lcfirst($this->namespace) . 'Ticket', |
|
85 | - $this->namespace . 'Ticket', |
|
86 | - null, |
|
87 | - esc_html__('A ticket', 'event_espresso'), |
|
88 | - null, |
|
89 | - [$this, 'getTicket'], |
|
90 | - [], |
|
91 | - [ |
|
92 | - 'id' => [ |
|
93 | - 'type' => [ |
|
94 | - 'non_null' => 'ID', |
|
95 | - ], |
|
96 | - 'description' => esc_html__('The globally unique identifier of the ticket.', 'event_espresso'), |
|
97 | - ], |
|
98 | - ] |
|
99 | - ), |
|
100 | - ]; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
106 | - * @param array $args The inputArgs on the field |
|
107 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
108 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
109 | - * @return string |
|
110 | - * @throws Exception |
|
111 | - * @throws InvalidArgumentException |
|
112 | - * @throws InvalidDataTypeException |
|
113 | - * @throws InvalidInterfaceException |
|
114 | - * @throws UserError |
|
115 | - * @throws UnexpectedEntityException |
|
116 | - * @since $VID:$ |
|
117 | - */ |
|
118 | - public function getEventRelationalData($source, array $args, AppContext $context, ResolveInfo $info): string |
|
119 | - { |
|
120 | - /** |
|
121 | - * Throw an exception if there's no event ID |
|
122 | - */ |
|
123 | - if (empty($args['eventId']) || ! absint($args['eventId'])) { |
|
124 | - throw new UserError(esc_html__( |
|
125 | - 'No event ID was provided to get the relational data for', |
|
126 | - 'event_espresso' |
|
127 | - )); |
|
128 | - } |
|
129 | - |
|
130 | - $eventId = absint($args['eventId']); |
|
131 | - /** @var EventEntityRelations $event_entity_relations */ |
|
132 | - $event_entity_relations = LoaderFactory::getLoader()->getShared( |
|
133 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' |
|
134 | - ); |
|
135 | - return json_encode($event_entity_relations->getData($eventId)); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
141 | - * @param array $args The inputArgs on the field |
|
142 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
143 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
144 | - * @return string |
|
145 | - * @throws Exception |
|
146 | - * @throws InvalidArgumentException |
|
147 | - * @throws InvalidDataTypeException |
|
148 | - * @throws InvalidInterfaceException |
|
149 | - * @throws UserError |
|
150 | - * @throws UnexpectedEntityException |
|
151 | - * @since $VID:$ |
|
152 | - */ |
|
153 | - public function getDatetime($source, array $args, AppContext $context, ResolveInfo $info): EE_Datetime |
|
154 | - { |
|
155 | - $parts = Relay::fromGlobalId(sanitize_text_field($args['id'])); |
|
156 | - |
|
157 | - /** |
|
158 | - * Throw an exception if there's no ID |
|
159 | - */ |
|
160 | - if (empty($parts['id'])) { |
|
161 | - throw new UserError(esc_html__( |
|
162 | - 'A missing or invalid ID was received.', |
|
163 | - 'event_espresso' |
|
164 | - )); |
|
165 | - } |
|
166 | - |
|
167 | - return EEM_Datetime::instance()->get_one_by_ID(absint($parts['id'])); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
173 | - * @param array $args The inputArgs on the field |
|
174 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
175 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
176 | - * @return string |
|
177 | - * @throws Exception |
|
178 | - * @throws InvalidArgumentException |
|
179 | - * @throws InvalidDataTypeException |
|
180 | - * @throws InvalidInterfaceException |
|
181 | - * @throws UserError |
|
182 | - * @throws UnexpectedEntityException |
|
183 | - * @since $VID:$ |
|
184 | - */ |
|
185 | - public function getTicket($source, array $args, AppContext $context, ResolveInfo $info): EE_Ticket |
|
186 | - { |
|
187 | - $parts = Relay::fromGlobalId(sanitize_text_field($args['id'])); |
|
188 | - |
|
189 | - /** |
|
190 | - * Throw an exception if there's no ID |
|
191 | - */ |
|
192 | - if (empty($parts['id'])) { |
|
193 | - throw new UserError(esc_html__( |
|
194 | - 'A missing or invalid ID was received.', |
|
195 | - 'event_espresso' |
|
196 | - )); |
|
197 | - } |
|
198 | - |
|
199 | - return EEM_Ticket::instance()->get_one_by_ID(absint($parts['id'])); |
|
200 | - } |
|
34 | + /** |
|
35 | + * RootQuery constructor. |
|
36 | + */ |
|
37 | + public function __construct() |
|
38 | + { |
|
39 | + $this->setName('RootQuery'); |
|
40 | + $this->setIsCustomPostType(true); |
|
41 | + parent::__construct(); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @return GraphQLFieldInterface[] |
|
47 | + */ |
|
48 | + public function getFields(): array |
|
49 | + { |
|
50 | + return [ |
|
51 | + new GraphQLOutputField( |
|
52 | + lcfirst($this->namespace) . 'EventRelations', |
|
53 | + 'String', |
|
54 | + null, |
|
55 | + esc_html__('JSON encoded relational data of the models', 'event_espresso'), |
|
56 | + null, |
|
57 | + [$this, 'getEventRelationalData'], |
|
58 | + [], |
|
59 | + [ |
|
60 | + 'eventId' => [ |
|
61 | + 'type' => ['non_null' => 'Int'], |
|
62 | + 'description' => esc_html__('The event ID to get the relational data for.', 'event_espresso'), |
|
63 | + ], |
|
64 | + ] |
|
65 | + ), |
|
66 | + new GraphQLOutputField( |
|
67 | + lcfirst($this->namespace) . 'Datetime', |
|
68 | + $this->namespace . 'Datetime', |
|
69 | + null, |
|
70 | + esc_html__('A datetime', 'event_espresso'), |
|
71 | + null, |
|
72 | + [$this, 'getDatetime'], |
|
73 | + [], |
|
74 | + [ |
|
75 | + 'id' => [ |
|
76 | + 'type' => [ |
|
77 | + 'non_null' => 'ID', |
|
78 | + ], |
|
79 | + 'description' => esc_html__('The globally unique identifier of the datetime.', 'event_espresso'), |
|
80 | + ], |
|
81 | + ] |
|
82 | + ), |
|
83 | + new GraphQLOutputField( |
|
84 | + lcfirst($this->namespace) . 'Ticket', |
|
85 | + $this->namespace . 'Ticket', |
|
86 | + null, |
|
87 | + esc_html__('A ticket', 'event_espresso'), |
|
88 | + null, |
|
89 | + [$this, 'getTicket'], |
|
90 | + [], |
|
91 | + [ |
|
92 | + 'id' => [ |
|
93 | + 'type' => [ |
|
94 | + 'non_null' => 'ID', |
|
95 | + ], |
|
96 | + 'description' => esc_html__('The globally unique identifier of the ticket.', 'event_espresso'), |
|
97 | + ], |
|
98 | + ] |
|
99 | + ), |
|
100 | + ]; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
106 | + * @param array $args The inputArgs on the field |
|
107 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
108 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
109 | + * @return string |
|
110 | + * @throws Exception |
|
111 | + * @throws InvalidArgumentException |
|
112 | + * @throws InvalidDataTypeException |
|
113 | + * @throws InvalidInterfaceException |
|
114 | + * @throws UserError |
|
115 | + * @throws UnexpectedEntityException |
|
116 | + * @since $VID:$ |
|
117 | + */ |
|
118 | + public function getEventRelationalData($source, array $args, AppContext $context, ResolveInfo $info): string |
|
119 | + { |
|
120 | + /** |
|
121 | + * Throw an exception if there's no event ID |
|
122 | + */ |
|
123 | + if (empty($args['eventId']) || ! absint($args['eventId'])) { |
|
124 | + throw new UserError(esc_html__( |
|
125 | + 'No event ID was provided to get the relational data for', |
|
126 | + 'event_espresso' |
|
127 | + )); |
|
128 | + } |
|
129 | + |
|
130 | + $eventId = absint($args['eventId']); |
|
131 | + /** @var EventEntityRelations $event_entity_relations */ |
|
132 | + $event_entity_relations = LoaderFactory::getLoader()->getShared( |
|
133 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' |
|
134 | + ); |
|
135 | + return json_encode($event_entity_relations->getData($eventId)); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
141 | + * @param array $args The inputArgs on the field |
|
142 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
143 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
144 | + * @return string |
|
145 | + * @throws Exception |
|
146 | + * @throws InvalidArgumentException |
|
147 | + * @throws InvalidDataTypeException |
|
148 | + * @throws InvalidInterfaceException |
|
149 | + * @throws UserError |
|
150 | + * @throws UnexpectedEntityException |
|
151 | + * @since $VID:$ |
|
152 | + */ |
|
153 | + public function getDatetime($source, array $args, AppContext $context, ResolveInfo $info): EE_Datetime |
|
154 | + { |
|
155 | + $parts = Relay::fromGlobalId(sanitize_text_field($args['id'])); |
|
156 | + |
|
157 | + /** |
|
158 | + * Throw an exception if there's no ID |
|
159 | + */ |
|
160 | + if (empty($parts['id'])) { |
|
161 | + throw new UserError(esc_html__( |
|
162 | + 'A missing or invalid ID was received.', |
|
163 | + 'event_espresso' |
|
164 | + )); |
|
165 | + } |
|
166 | + |
|
167 | + return EEM_Datetime::instance()->get_one_by_ID(absint($parts['id'])); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
173 | + * @param array $args The inputArgs on the field |
|
174 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
175 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
176 | + * @return string |
|
177 | + * @throws Exception |
|
178 | + * @throws InvalidArgumentException |
|
179 | + * @throws InvalidDataTypeException |
|
180 | + * @throws InvalidInterfaceException |
|
181 | + * @throws UserError |
|
182 | + * @throws UnexpectedEntityException |
|
183 | + * @since $VID:$ |
|
184 | + */ |
|
185 | + public function getTicket($source, array $args, AppContext $context, ResolveInfo $info): EE_Ticket |
|
186 | + { |
|
187 | + $parts = Relay::fromGlobalId(sanitize_text_field($args['id'])); |
|
188 | + |
|
189 | + /** |
|
190 | + * Throw an exception if there's no ID |
|
191 | + */ |
|
192 | + if (empty($parts['id'])) { |
|
193 | + throw new UserError(esc_html__( |
|
194 | + 'A missing or invalid ID was received.', |
|
195 | + 'event_espresso' |
|
196 | + )); |
|
197 | + } |
|
198 | + |
|
199 | + return EEM_Ticket::instance()->get_one_by_ID(absint($parts['id'])); |
|
200 | + } |
|
201 | 201 | } |
@@ -26,191 +26,191 @@ |
||
26 | 26 | */ |
27 | 27 | class FormSection extends TypeBase |
28 | 28 | { |
29 | - /** |
|
30 | - * FormSection constructor. |
|
31 | - * |
|
32 | - * @param EEM_Form_Section $form_section_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Form_Section $form_section_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'FormSection'); |
|
37 | - $this->setDescription(__('A form section', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
29 | + /** |
|
30 | + * FormSection constructor. |
|
31 | + * |
|
32 | + * @param EEM_Form_Section $form_section_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Form_Section $form_section_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'FormSection'); |
|
37 | + $this->setDescription(__('A form section', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | 39 | |
40 | - parent::__construct($form_section_model); |
|
41 | - } |
|
40 | + parent::__construct($form_section_model); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @return GraphQLFieldInterface[] |
|
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 GraphQLField( |
|
57 | - 'appliesTo', |
|
58 | - $this->namespace . 'FormSectionAppliesToEnum', |
|
59 | - 'appliesTo', |
|
60 | - esc_html__('Form user type that this form section should be presented to.', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'attributes', |
|
64 | - 'String', |
|
65 | - 'attributes', |
|
66 | - esc_html__( |
|
67 | - 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
68 | - 'event_espresso' |
|
69 | - ), |
|
70 | - [$this, 'toJson'] |
|
71 | - ), |
|
72 | - new GraphQLField( |
|
73 | - 'belongsTo', |
|
74 | - 'String', |
|
75 | - 'belongsTo', |
|
76 | - esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso') |
|
77 | - ), |
|
78 | - new GraphQLOutputField( |
|
79 | - 'isActive', |
|
80 | - 'Boolean', |
|
81 | - 'isActive', |
|
82 | - esc_html__('Flag indicating whether the section is active.', 'event_espresso') |
|
83 | - ), |
|
84 | - new GraphQLOutputField( |
|
85 | - 'isArchived', |
|
86 | - 'Boolean', |
|
87 | - 'isArchived', |
|
88 | - esc_html__('Flag indicating whether the section is archived.', 'event_espresso') |
|
89 | - ), |
|
90 | - new GraphQLOutputField( |
|
91 | - 'isDefault', |
|
92 | - 'Boolean', |
|
93 | - 'isDefault', |
|
94 | - esc_html__('Flag indicating whether the section is a default one.', 'event_espresso') |
|
95 | - ), |
|
96 | - new GraphQLOutputField( |
|
97 | - 'isShared', |
|
98 | - 'Boolean', |
|
99 | - 'isShared', |
|
100 | - esc_html__('Flag indicating whether the section is a shared one.', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLOutputField( |
|
103 | - 'isTrashed', |
|
104 | - 'Boolean', |
|
105 | - 'isTrashed', |
|
106 | - esc_html__('Flag indicating whether the section is trashed.', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'label', |
|
110 | - 'String', |
|
111 | - 'label', |
|
112 | - esc_html__( |
|
113 | - 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - [$this, 'toJson'] |
|
117 | - ), |
|
118 | - new GraphQLField( |
|
119 | - 'order', |
|
120 | - 'Int', |
|
121 | - 'order', |
|
122 | - esc_html__('Order in which form section appears in a form.', 'event_espresso') |
|
123 | - ), |
|
124 | - new GraphQLField( |
|
125 | - 'status', |
|
126 | - $this->namespace . 'FormStatusEnum', |
|
127 | - 'status', |
|
128 | - esc_html__( |
|
129 | - 'Whether form section is active, archived, shared, trashed, or used as a default on new forms.', |
|
130 | - 'event_espresso' |
|
131 | - ) |
|
132 | - ), |
|
133 | - new GraphQLOutputField( |
|
134 | - 'wpUser', |
|
135 | - 'User', |
|
136 | - null, |
|
137 | - esc_html__('WP User that created this form section.', 'event_espresso') |
|
138 | - ), |
|
139 | - new GraphQLInputField( |
|
140 | - 'wpUser', |
|
141 | - 'ID', |
|
142 | - null, |
|
143 | - esc_html__('ID of the WP User that created the form section.', 'event_espresso') |
|
144 | - ), |
|
145 | - ]; |
|
44 | + /** |
|
45 | + * @return GraphQLFieldInterface[] |
|
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 GraphQLField( |
|
57 | + 'appliesTo', |
|
58 | + $this->namespace . 'FormSectionAppliesToEnum', |
|
59 | + 'appliesTo', |
|
60 | + esc_html__('Form user type that this form section should be presented to.', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'attributes', |
|
64 | + 'String', |
|
65 | + 'attributes', |
|
66 | + esc_html__( |
|
67 | + 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
68 | + 'event_espresso' |
|
69 | + ), |
|
70 | + [$this, 'toJson'] |
|
71 | + ), |
|
72 | + new GraphQLField( |
|
73 | + 'belongsTo', |
|
74 | + 'String', |
|
75 | + 'belongsTo', |
|
76 | + esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso') |
|
77 | + ), |
|
78 | + new GraphQLOutputField( |
|
79 | + 'isActive', |
|
80 | + 'Boolean', |
|
81 | + 'isActive', |
|
82 | + esc_html__('Flag indicating whether the section is active.', 'event_espresso') |
|
83 | + ), |
|
84 | + new GraphQLOutputField( |
|
85 | + 'isArchived', |
|
86 | + 'Boolean', |
|
87 | + 'isArchived', |
|
88 | + esc_html__('Flag indicating whether the section is archived.', 'event_espresso') |
|
89 | + ), |
|
90 | + new GraphQLOutputField( |
|
91 | + 'isDefault', |
|
92 | + 'Boolean', |
|
93 | + 'isDefault', |
|
94 | + esc_html__('Flag indicating whether the section is a default one.', 'event_espresso') |
|
95 | + ), |
|
96 | + new GraphQLOutputField( |
|
97 | + 'isShared', |
|
98 | + 'Boolean', |
|
99 | + 'isShared', |
|
100 | + esc_html__('Flag indicating whether the section is a shared one.', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLOutputField( |
|
103 | + 'isTrashed', |
|
104 | + 'Boolean', |
|
105 | + 'isTrashed', |
|
106 | + esc_html__('Flag indicating whether the section is trashed.', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'label', |
|
110 | + 'String', |
|
111 | + 'label', |
|
112 | + esc_html__( |
|
113 | + 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + [$this, 'toJson'] |
|
117 | + ), |
|
118 | + new GraphQLField( |
|
119 | + 'order', |
|
120 | + 'Int', |
|
121 | + 'order', |
|
122 | + esc_html__('Order in which form section appears in a form.', 'event_espresso') |
|
123 | + ), |
|
124 | + new GraphQLField( |
|
125 | + 'status', |
|
126 | + $this->namespace . 'FormStatusEnum', |
|
127 | + 'status', |
|
128 | + esc_html__( |
|
129 | + 'Whether form section is active, archived, shared, trashed, or used as a default on new forms.', |
|
130 | + 'event_espresso' |
|
131 | + ) |
|
132 | + ), |
|
133 | + new GraphQLOutputField( |
|
134 | + 'wpUser', |
|
135 | + 'User', |
|
136 | + null, |
|
137 | + esc_html__('WP User that created this form section.', 'event_espresso') |
|
138 | + ), |
|
139 | + new GraphQLInputField( |
|
140 | + 'wpUser', |
|
141 | + 'ID', |
|
142 | + null, |
|
143 | + esc_html__('ID of the WP User that created the form section.', 'event_espresso') |
|
144 | + ), |
|
145 | + ]; |
|
146 | 146 | |
147 | - return apply_filters( |
|
148 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__form_section_fields', |
|
149 | - $fields, |
|
150 | - $this->name, |
|
151 | - $this->model |
|
152 | - ); |
|
153 | - } |
|
147 | + return apply_filters( |
|
148 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__form_section_fields', |
|
149 | + $fields, |
|
150 | + $this->name, |
|
151 | + $this->model |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | |
156 | - /** |
|
157 | - * @param array $inputFields The mutation input fields. |
|
158 | - * @throws InvalidArgumentException |
|
159 | - * @throws ReflectionException |
|
160 | - * @throws Exception |
|
161 | - * @since $VID:$ |
|
162 | - */ |
|
163 | - public function registerMutations(array $inputFields) |
|
164 | - { |
|
165 | - // Register mutation to update an entity. |
|
166 | - register_graphql_mutation( |
|
167 | - 'update' . $this->name(), |
|
168 | - [ |
|
169 | - 'inputFields' => $inputFields, |
|
170 | - 'outputFields' => [ |
|
171 | - lcfirst($this->name()) => [ |
|
172 | - 'type' => $this->name(), |
|
173 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
174 | - ], |
|
175 | - ], |
|
176 | - 'mutateAndGetPayload' => FormSectionUpdate::mutateAndGetPayload($this->model), |
|
177 | - ] |
|
178 | - ); |
|
179 | - // Register mutation to delete an entity. |
|
180 | - register_graphql_mutation( |
|
181 | - 'delete' . $this->name(), |
|
182 | - [ |
|
183 | - 'inputFields' => [ |
|
184 | - 'id' => $inputFields['id'], |
|
185 | - ], |
|
186 | - 'outputFields' => [ |
|
187 | - lcfirst($this->name()) => [ |
|
188 | - 'type' => $this->name(), |
|
189 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
190 | - 'resolve' => static function ($payload) { |
|
191 | - $deleted = (object) $payload['deleted']; |
|
156 | + /** |
|
157 | + * @param array $inputFields The mutation input fields. |
|
158 | + * @throws InvalidArgumentException |
|
159 | + * @throws ReflectionException |
|
160 | + * @throws Exception |
|
161 | + * @since $VID:$ |
|
162 | + */ |
|
163 | + public function registerMutations(array $inputFields) |
|
164 | + { |
|
165 | + // Register mutation to update an entity. |
|
166 | + register_graphql_mutation( |
|
167 | + 'update' . $this->name(), |
|
168 | + [ |
|
169 | + 'inputFields' => $inputFields, |
|
170 | + 'outputFields' => [ |
|
171 | + lcfirst($this->name()) => [ |
|
172 | + 'type' => $this->name(), |
|
173 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
174 | + ], |
|
175 | + ], |
|
176 | + 'mutateAndGetPayload' => FormSectionUpdate::mutateAndGetPayload($this->model), |
|
177 | + ] |
|
178 | + ); |
|
179 | + // Register mutation to delete an entity. |
|
180 | + register_graphql_mutation( |
|
181 | + 'delete' . $this->name(), |
|
182 | + [ |
|
183 | + 'inputFields' => [ |
|
184 | + 'id' => $inputFields['id'], |
|
185 | + ], |
|
186 | + 'outputFields' => [ |
|
187 | + lcfirst($this->name()) => [ |
|
188 | + 'type' => $this->name(), |
|
189 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
190 | + 'resolve' => static function ($payload) { |
|
191 | + $deleted = (object) $payload['deleted']; |
|
192 | 192 | |
193 | - return ! empty($deleted) ? $deleted : null; |
|
194 | - }, |
|
195 | - ], |
|
196 | - ], |
|
197 | - 'mutateAndGetPayload' => FormSectionDelete::mutateAndGetPayload($this->model), |
|
198 | - ] |
|
199 | - ); |
|
193 | + return ! empty($deleted) ? $deleted : null; |
|
194 | + }, |
|
195 | + ], |
|
196 | + ], |
|
197 | + 'mutateAndGetPayload' => FormSectionDelete::mutateAndGetPayload($this->model), |
|
198 | + ] |
|
199 | + ); |
|
200 | 200 | |
201 | - // Register mutation to update an entity. |
|
202 | - register_graphql_mutation( |
|
203 | - 'create' . $this->name(), |
|
204 | - [ |
|
205 | - 'inputFields' => $inputFields, |
|
206 | - 'outputFields' => [ |
|
207 | - lcfirst($this->name()) => [ |
|
208 | - 'type' => $this->name(), |
|
209 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
210 | - ], |
|
211 | - ], |
|
212 | - 'mutateAndGetPayload' => FormSectionCreate::mutateAndGetPayload($this->model), |
|
213 | - ] |
|
214 | - ); |
|
215 | - } |
|
201 | + // Register mutation to update an entity. |
|
202 | + register_graphql_mutation( |
|
203 | + 'create' . $this->name(), |
|
204 | + [ |
|
205 | + 'inputFields' => $inputFields, |
|
206 | + 'outputFields' => [ |
|
207 | + lcfirst($this->name()) => [ |
|
208 | + 'type' => $this->name(), |
|
209 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
210 | + ], |
|
211 | + ], |
|
212 | + 'mutateAndGetPayload' => FormSectionCreate::mutateAndGetPayload($this->model), |
|
213 | + ] |
|
214 | + ); |
|
215 | + } |
|
216 | 216 | } |
@@ -21,125 +21,125 @@ |
||
21 | 21 | */ |
22 | 22 | class DatetimeToJson implements ModelObjectToJsonConverterInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * @param EE_Datetime[] $datetimes |
|
26 | - * @return array |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | - { |
|
36 | - $jsonDates = []; |
|
37 | - foreach ($datetimes as $datetime) { |
|
38 | - if ($datetime instanceof EE_Datetime) { |
|
39 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | - } |
|
41 | - } |
|
42 | - return $jsonDates; |
|
43 | - } |
|
24 | + /** |
|
25 | + * @param EE_Datetime[] $datetimes |
|
26 | + * @return array |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | + { |
|
36 | + $jsonDates = []; |
|
37 | + foreach ($datetimes as $datetime) { |
|
38 | + if ($datetime instanceof EE_Datetime) { |
|
39 | + $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | + } |
|
41 | + } |
|
42 | + return $jsonDates; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param EE_Datetime $datetime |
|
48 | - * @return false|string |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws InvalidDataTypeException |
|
52 | - * @throws InvalidInterfaceException |
|
53 | - * @throws ReflectionException |
|
54 | - * @since $VID:$ |
|
55 | - */ |
|
56 | - public function convertAndEncode($datetime) |
|
57 | - { |
|
58 | - return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | - } |
|
46 | + /** |
|
47 | + * @param EE_Datetime $datetime |
|
48 | + * @return false|string |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws InvalidDataTypeException |
|
52 | + * @throws InvalidInterfaceException |
|
53 | + * @throws ReflectionException |
|
54 | + * @since $VID:$ |
|
55 | + */ |
|
56 | + public function convertAndEncode($datetime) |
|
57 | + { |
|
58 | + return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param EE_Datetime[] $datetimes |
|
64 | - * @return array |
|
65 | - * @throws EE_Error |
|
66 | - * @throws InvalidArgumentException |
|
67 | - * @throws InvalidDataTypeException |
|
68 | - * @throws InvalidInterfaceException |
|
69 | - * @throws ReflectionException |
|
70 | - * @since $VID:$ |
|
71 | - */ |
|
72 | - public function convertArrayOf(array $datetimes) |
|
73 | - { |
|
74 | - $arrayOfDates = []; |
|
75 | - foreach ($datetimes as $datetime) { |
|
76 | - if ($datetime instanceof EE_Datetime) { |
|
77 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | - } |
|
79 | - } |
|
80 | - return $arrayOfDates; |
|
81 | - } |
|
62 | + /** |
|
63 | + * @param EE_Datetime[] $datetimes |
|
64 | + * @return array |
|
65 | + * @throws EE_Error |
|
66 | + * @throws InvalidArgumentException |
|
67 | + * @throws InvalidDataTypeException |
|
68 | + * @throws InvalidInterfaceException |
|
69 | + * @throws ReflectionException |
|
70 | + * @since $VID:$ |
|
71 | + */ |
|
72 | + public function convertArrayOf(array $datetimes) |
|
73 | + { |
|
74 | + $arrayOfDates = []; |
|
75 | + foreach ($datetimes as $datetime) { |
|
76 | + if ($datetime instanceof EE_Datetime) { |
|
77 | + $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | + } |
|
79 | + } |
|
80 | + return $arrayOfDates; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param EE_Datetime $datetime |
|
86 | - * @return array |
|
87 | - * @throws EE_Error |
|
88 | - * @throws InvalidDataTypeException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @throws InvalidArgumentException |
|
91 | - * @throws ReflectionException |
|
92 | - * @since $VID:$ |
|
93 | - */ |
|
94 | - public function convert($datetime) |
|
95 | - { |
|
96 | - return $datetime instanceof EE_Datetime ? [ |
|
97 | - 'DTT_ID' => $datetime->ID(), |
|
98 | - 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | - 'DTT_name' => $datetime->name(), |
|
100 | - 'DTT_description' => $datetime->description(), |
|
101 | - 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | - 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | - 'DTT_sold' => $datetime->sold(), |
|
104 | - 'DTT_reserved' => $datetime->reserved(), |
|
105 | - 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | - 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | - 'DTT_order' => $datetime->order(), |
|
108 | - 'DTT_parent' => $datetime->parent(), |
|
109 | - 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | - ] : []; |
|
111 | - } |
|
84 | + /** |
|
85 | + * @param EE_Datetime $datetime |
|
86 | + * @return array |
|
87 | + * @throws EE_Error |
|
88 | + * @throws InvalidDataTypeException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @throws InvalidArgumentException |
|
91 | + * @throws ReflectionException |
|
92 | + * @since $VID:$ |
|
93 | + */ |
|
94 | + public function convert($datetime) |
|
95 | + { |
|
96 | + return $datetime instanceof EE_Datetime ? [ |
|
97 | + 'DTT_ID' => $datetime->ID(), |
|
98 | + 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | + 'DTT_name' => $datetime->name(), |
|
100 | + 'DTT_description' => $datetime->description(), |
|
101 | + 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | + 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | + 'DTT_sold' => $datetime->sold(), |
|
104 | + 'DTT_reserved' => $datetime->reserved(), |
|
105 | + 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | + 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | + 'DTT_order' => $datetime->order(), |
|
108 | + 'DTT_parent' => $datetime->parent(), |
|
109 | + 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | + ] : []; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @param EE_Datetime[] $datetimes |
|
116 | - * @return array |
|
117 | - * @throws EE_Error |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - * @throws ReflectionException |
|
122 | - * @since $VID:$ |
|
123 | - */ |
|
124 | - public function encodeArrayOf(array $datetimes) |
|
125 | - { |
|
126 | - $jsonDates = []; |
|
127 | - foreach ($datetimes as $datetime) { |
|
128 | - if ($datetime instanceof EE_Datetime) { |
|
129 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | - } |
|
131 | - } |
|
132 | - return $jsonDates; |
|
133 | - } |
|
114 | + /** |
|
115 | + * @param EE_Datetime[] $datetimes |
|
116 | + * @return array |
|
117 | + * @throws EE_Error |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + * @throws ReflectionException |
|
122 | + * @since $VID:$ |
|
123 | + */ |
|
124 | + public function encodeArrayOf(array $datetimes) |
|
125 | + { |
|
126 | + $jsonDates = []; |
|
127 | + foreach ($datetimes as $datetime) { |
|
128 | + if ($datetime instanceof EE_Datetime) { |
|
129 | + $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | + } |
|
131 | + } |
|
132 | + return $jsonDates; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | - /** |
|
137 | - * @param array $datetime_array |
|
138 | - * @return false|string |
|
139 | - * @since $VID:$ |
|
140 | - */ |
|
141 | - public function encode(array $datetime_array) |
|
142 | - { |
|
143 | - return wp_json_encode($datetime_array); |
|
144 | - } |
|
136 | + /** |
|
137 | + * @param array $datetime_array |
|
138 | + * @return false|string |
|
139 | + * @since $VID:$ |
|
140 | + */ |
|
141 | + public function encode(array $datetime_array) |
|
142 | + { |
|
143 | + return wp_json_encode($datetime_array); |
|
144 | + } |
|
145 | 145 | } |