@@ -14,55 +14,55 @@ |
||
14 | 14 | class PriceCreate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Price $model |
|
21 | - * @param Price $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
25 | - { |
|
26 | - /** |
|
27 | - * Creates an entity. |
|
28 | - * |
|
29 | - * @param array $input The input for the mutation |
|
30 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
31 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
35 | - $id = null; |
|
36 | - try { |
|
37 | - EntityMutator::checkPermissions($model); |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Price $model |
|
21 | + * @param Price $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
25 | + { |
|
26 | + /** |
|
27 | + * Creates an entity. |
|
28 | + * |
|
29 | + * @param array $input The input for the mutation |
|
30 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
31 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
35 | + $id = null; |
|
36 | + try { |
|
37 | + EntityMutator::checkPermissions($model); |
|
38 | 38 | |
39 | - $args = PriceMutation::prepareFields($input); |
|
39 | + $args = PriceMutation::prepareFields($input); |
|
40 | 40 | |
41 | - if (empty($args['PRT_ID'])) { |
|
42 | - // translators: the placeholder is the name of the field. |
|
43 | - throw new UserError( |
|
44 | - sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
45 | - ); |
|
46 | - } |
|
41 | + if (empty($args['PRT_ID'])) { |
|
42 | + // translators: the placeholder is the name of the field. |
|
43 | + throw new UserError( |
|
44 | + sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | |
48 | - $entity = EE_Price::new_instance($args); |
|
49 | - $id = $entity->save(); |
|
50 | - EntityMutator::validateResults($id); |
|
48 | + $entity = EE_Price::new_instance($args); |
|
49 | + $id = $entity->save(); |
|
50 | + EntityMutator::validateResults($id); |
|
51 | 51 | |
52 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_create', $entity, $input); |
|
53 | - } catch (Exception $exception) { |
|
54 | - EntityMutator::handleExceptions( |
|
55 | - $exception, |
|
56 | - esc_html__( |
|
57 | - 'The price could not be created because of the following error(s)', |
|
58 | - 'event_espresso' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
52 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_create', $entity, $input); |
|
53 | + } catch (Exception $exception) { |
|
54 | + EntityMutator::handleExceptions( |
|
55 | + $exception, |
|
56 | + esc_html__( |
|
57 | + 'The price could not be created because of the following error(s)', |
|
58 | + 'event_espresso' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - return [ |
|
64 | - 'id' => $id, |
|
65 | - ]; |
|
66 | - }; |
|
67 | - } |
|
63 | + return [ |
|
64 | + 'id' => $id, |
|
65 | + ]; |
|
66 | + }; |
|
67 | + } |
|
68 | 68 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
35 | 35 | $id = null; |
36 | 36 | try { |
37 | 37 | EntityMutator::checkPermissions($model); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $primaryKey = $model->get_primary_key_field()->get_name(); |
61 | 61 | // e.g. "FSC_UUID" will give us "FSC" |
62 | 62 | [$keyPrefix] = explode('_', $primaryKey); |
63 | - $uuid_field = $keyPrefix . '_UUID'; // e.g. "FSC_UUID" |
|
63 | + $uuid_field = $keyPrefix.'_UUID'; // e.g. "FSC_UUID" |
|
64 | 64 | |
65 | 65 | // If the model has UUID field, then we will use that in place of ID. |
66 | 66 | $ID = $model->has_field($uuid_field) ? $input['id'] : EntityMutator::getEntityIDFromGlobalId($model, $input); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Stop now if a user isn't allowed to execute mutation |
80 | 80 | */ |
81 | - if (! current_user_can($capability)) { |
|
81 | + if ( ! current_user_can($capability)) { |
|
82 | 82 | $model_name = $model->get_this_model_name(); |
83 | 83 | $message = sprintf( |
84 | 84 | esc_html_x( |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $entity = $model->get_one_by_ID($ID); |
134 | 134 | $model_name = $model->get_this_model_name(); |
135 | - $class_name = 'EE_' . $model_name; |
|
135 | + $class_name = 'EE_'.$model_name; |
|
136 | 136 | if ($entity instanceof $class_name) { |
137 | 137 | return $entity; |
138 | 138 | } |
@@ -22,168 +22,168 @@ |
||
22 | 22 | abstract class EntityMutator |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @param EEM_Base $model |
|
27 | - * @param integer $ID |
|
28 | - * @param string $capability |
|
29 | - * @return EE_Base_Class |
|
30 | - * @throws OutOfBoundsException |
|
31 | - * @throws UserError |
|
32 | - * @throws EE_Error |
|
33 | - */ |
|
34 | - protected static function getEntityFromID( |
|
35 | - EEM_Base $model, |
|
36 | - int $ID, |
|
37 | - string $capability = 'ee_edit_events' |
|
38 | - ): EE_Base_Class { |
|
39 | - EntityMutator::checkPermissions($model, $capability); |
|
40 | - return EntityMutator::getEntity($model, $ID); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @param EEM_Base $model |
|
46 | - * @param array $input |
|
47 | - * @param string $capability |
|
48 | - * @return EE_Base_Class |
|
49 | - * @throws OutOfBoundsException |
|
50 | - * @throws UserError |
|
51 | - * @throws EE_Error |
|
52 | - */ |
|
53 | - protected static function getEntityFromInputData( |
|
54 | - EEM_Base $model, |
|
55 | - array $input, |
|
56 | - string $capability = 'ee_edit_events' |
|
57 | - ): EE_Base_Class { |
|
58 | - EntityMutator::checkPermissions($model, $capability); |
|
59 | - |
|
60 | - $primaryKey = $model->get_primary_key_field()->get_name(); |
|
61 | - // e.g. "FSC_UUID" will give us "FSC" |
|
62 | - [$keyPrefix] = explode('_', $primaryKey); |
|
63 | - $uuid_field = $keyPrefix . '_UUID'; // e.g. "FSC_UUID" |
|
64 | - |
|
65 | - // If the model has UUID field, then we will use that in place of ID. |
|
66 | - $ID = $model->has_field($uuid_field) ? $input['id'] : EntityMutator::getEntityIDFromGlobalId($model, $input); |
|
67 | - return EntityMutator::getEntity($model, $ID); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param EEM_Base $model |
|
73 | - * @param string $capability |
|
74 | - * @throws UserError |
|
75 | - */ |
|
76 | - protected static function checkPermissions(EEM_Base $model, string $capability = 'ee_edit_events') |
|
77 | - { |
|
78 | - /** |
|
79 | - * Stop now if a user isn't allowed to execute mutation |
|
80 | - */ |
|
81 | - if (! current_user_can($capability)) { |
|
82 | - $model_name = $model->get_this_model_name(); |
|
83 | - $message = sprintf( |
|
84 | - esc_html_x( |
|
85 | - 'We\'re sorry but you do not have the required permissions to execute %1$s mutations!', |
|
86 | - 'We\'re sorry but you do not have the required permissions to execute entity(datetime/ticket/etc) mutations!', |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - strtolower($model_name) |
|
90 | - ); |
|
91 | - throw new UserError($message); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param EEM_Base $model |
|
98 | - * @param array $input |
|
99 | - * @return int |
|
100 | - * @throws OutOfBoundsException |
|
101 | - */ |
|
102 | - protected static function getEntityIDFromGlobalId(EEM_Base $model, array $input): int |
|
103 | - { |
|
104 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
105 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
106 | - if ($id > 0) { |
|
107 | - return $id; |
|
108 | - } |
|
109 | - // no ID? throw an exception |
|
110 | - $model_name = $model->get_this_model_name(); |
|
111 | - throw new OutOfBoundsException( |
|
112 | - sprintf( |
|
113 | - esc_html_x( |
|
114 | - 'A missing or invalid %1$s ID was received.', |
|
115 | - 'A missing or invalid entity(datetime/ticket/etc) ID was received.', |
|
116 | - 'event_espresso' |
|
117 | - ), |
|
118 | - strtolower($model_name) |
|
119 | - ) |
|
120 | - ); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param EEM_Base $model |
|
126 | - * @param int|string $ID |
|
127 | - * @return EE_Base_Class |
|
128 | - * @throws OutOfBoundsException |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - protected static function getEntity(EEM_Base $model, $ID = 0): EE_Base_Class |
|
132 | - { |
|
133 | - $entity = $model->get_one_by_ID($ID); |
|
134 | - $model_name = $model->get_this_model_name(); |
|
135 | - $class_name = 'EE_' . $model_name; |
|
136 | - if ($entity instanceof $class_name) { |
|
137 | - return $entity; |
|
138 | - } |
|
139 | - // OOPS!!! invalid entity |
|
140 | - throw new OutOfBoundsException( |
|
141 | - sprintf( |
|
142 | - esc_html_x( |
|
143 | - 'A valid %1$s could not be retrieved from the database.', |
|
144 | - 'A valid entity(datetime/ticket/etc) could not be found in the database.', |
|
145 | - 'event_espresso' |
|
146 | - ), |
|
147 | - strtolower($model_name) |
|
148 | - ) |
|
149 | - ); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @param $results |
|
155 | - * @param string $message |
|
156 | - * @throws RuntimeException |
|
157 | - */ |
|
158 | - protected static function validateResults($results, string $message = '') |
|
159 | - { |
|
160 | - if (empty($results)) { |
|
161 | - $message = $message !== '' |
|
162 | - ? $message |
|
163 | - : esc_html__( |
|
164 | - 'An unknown error occurred. Please check your server\'s error logs for more information', |
|
165 | - 'event_espresso' |
|
166 | - ); |
|
167 | - throw new RuntimeException($message); |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param Exception $exception |
|
174 | - * @param string $message_prefix |
|
175 | - * @throws RuntimeException |
|
176 | - */ |
|
177 | - protected static function handleExceptions(Exception $exception, string $message_prefix = '') |
|
178 | - { |
|
179 | - $message_prefix = $message_prefix !== '' |
|
180 | - ? $message_prefix |
|
181 | - : esc_html__( |
|
182 | - 'The mutation could not be executed because of the following error(s)', |
|
183 | - 'event_espresso' |
|
184 | - ); |
|
185 | - throw new RuntimeException( |
|
186 | - sprintf('%1$s: %2$s', $message_prefix, $exception->getMessage()) |
|
187 | - ); |
|
188 | - } |
|
25 | + /** |
|
26 | + * @param EEM_Base $model |
|
27 | + * @param integer $ID |
|
28 | + * @param string $capability |
|
29 | + * @return EE_Base_Class |
|
30 | + * @throws OutOfBoundsException |
|
31 | + * @throws UserError |
|
32 | + * @throws EE_Error |
|
33 | + */ |
|
34 | + protected static function getEntityFromID( |
|
35 | + EEM_Base $model, |
|
36 | + int $ID, |
|
37 | + string $capability = 'ee_edit_events' |
|
38 | + ): EE_Base_Class { |
|
39 | + EntityMutator::checkPermissions($model, $capability); |
|
40 | + return EntityMutator::getEntity($model, $ID); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @param EEM_Base $model |
|
46 | + * @param array $input |
|
47 | + * @param string $capability |
|
48 | + * @return EE_Base_Class |
|
49 | + * @throws OutOfBoundsException |
|
50 | + * @throws UserError |
|
51 | + * @throws EE_Error |
|
52 | + */ |
|
53 | + protected static function getEntityFromInputData( |
|
54 | + EEM_Base $model, |
|
55 | + array $input, |
|
56 | + string $capability = 'ee_edit_events' |
|
57 | + ): EE_Base_Class { |
|
58 | + EntityMutator::checkPermissions($model, $capability); |
|
59 | + |
|
60 | + $primaryKey = $model->get_primary_key_field()->get_name(); |
|
61 | + // e.g. "FSC_UUID" will give us "FSC" |
|
62 | + [$keyPrefix] = explode('_', $primaryKey); |
|
63 | + $uuid_field = $keyPrefix . '_UUID'; // e.g. "FSC_UUID" |
|
64 | + |
|
65 | + // If the model has UUID field, then we will use that in place of ID. |
|
66 | + $ID = $model->has_field($uuid_field) ? $input['id'] : EntityMutator::getEntityIDFromGlobalId($model, $input); |
|
67 | + return EntityMutator::getEntity($model, $ID); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param EEM_Base $model |
|
73 | + * @param string $capability |
|
74 | + * @throws UserError |
|
75 | + */ |
|
76 | + protected static function checkPermissions(EEM_Base $model, string $capability = 'ee_edit_events') |
|
77 | + { |
|
78 | + /** |
|
79 | + * Stop now if a user isn't allowed to execute mutation |
|
80 | + */ |
|
81 | + if (! current_user_can($capability)) { |
|
82 | + $model_name = $model->get_this_model_name(); |
|
83 | + $message = sprintf( |
|
84 | + esc_html_x( |
|
85 | + 'We\'re sorry but you do not have the required permissions to execute %1$s mutations!', |
|
86 | + 'We\'re sorry but you do not have the required permissions to execute entity(datetime/ticket/etc) mutations!', |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + strtolower($model_name) |
|
90 | + ); |
|
91 | + throw new UserError($message); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param EEM_Base $model |
|
98 | + * @param array $input |
|
99 | + * @return int |
|
100 | + * @throws OutOfBoundsException |
|
101 | + */ |
|
102 | + protected static function getEntityIDFromGlobalId(EEM_Base $model, array $input): int |
|
103 | + { |
|
104 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
105 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
106 | + if ($id > 0) { |
|
107 | + return $id; |
|
108 | + } |
|
109 | + // no ID? throw an exception |
|
110 | + $model_name = $model->get_this_model_name(); |
|
111 | + throw new OutOfBoundsException( |
|
112 | + sprintf( |
|
113 | + esc_html_x( |
|
114 | + 'A missing or invalid %1$s ID was received.', |
|
115 | + 'A missing or invalid entity(datetime/ticket/etc) ID was received.', |
|
116 | + 'event_espresso' |
|
117 | + ), |
|
118 | + strtolower($model_name) |
|
119 | + ) |
|
120 | + ); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param EEM_Base $model |
|
126 | + * @param int|string $ID |
|
127 | + * @return EE_Base_Class |
|
128 | + * @throws OutOfBoundsException |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + protected static function getEntity(EEM_Base $model, $ID = 0): EE_Base_Class |
|
132 | + { |
|
133 | + $entity = $model->get_one_by_ID($ID); |
|
134 | + $model_name = $model->get_this_model_name(); |
|
135 | + $class_name = 'EE_' . $model_name; |
|
136 | + if ($entity instanceof $class_name) { |
|
137 | + return $entity; |
|
138 | + } |
|
139 | + // OOPS!!! invalid entity |
|
140 | + throw new OutOfBoundsException( |
|
141 | + sprintf( |
|
142 | + esc_html_x( |
|
143 | + 'A valid %1$s could not be retrieved from the database.', |
|
144 | + 'A valid entity(datetime/ticket/etc) could not be found in the database.', |
|
145 | + 'event_espresso' |
|
146 | + ), |
|
147 | + strtolower($model_name) |
|
148 | + ) |
|
149 | + ); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @param $results |
|
155 | + * @param string $message |
|
156 | + * @throws RuntimeException |
|
157 | + */ |
|
158 | + protected static function validateResults($results, string $message = '') |
|
159 | + { |
|
160 | + if (empty($results)) { |
|
161 | + $message = $message !== '' |
|
162 | + ? $message |
|
163 | + : esc_html__( |
|
164 | + 'An unknown error occurred. Please check your server\'s error logs for more information', |
|
165 | + 'event_espresso' |
|
166 | + ); |
|
167 | + throw new RuntimeException($message); |
|
168 | + } |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param Exception $exception |
|
174 | + * @param string $message_prefix |
|
175 | + * @throws RuntimeException |
|
176 | + */ |
|
177 | + protected static function handleExceptions(Exception $exception, string $message_prefix = '') |
|
178 | + { |
|
179 | + $message_prefix = $message_prefix !== '' |
|
180 | + ? $message_prefix |
|
181 | + : esc_html__( |
|
182 | + 'The mutation could not be executed because of the following error(s)', |
|
183 | + 'event_espresso' |
|
184 | + ); |
|
185 | + throw new RuntimeException( |
|
186 | + sprintf('%1$s: %2$s', $message_prefix, $exception->getMessage()) |
|
187 | + ); |
|
188 | + } |
|
189 | 189 | } |
@@ -18,24 +18,24 @@ |
||
18 | 18 | class TicketVisibilityEnum extends EnumBase |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * TicketVisibilityEnum constructor. |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - $this->setName($this->namespace . 'TicketVisibilityEnum'); |
|
27 | - $this->setDescription(esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso')); |
|
28 | - parent::__construct(); |
|
29 | - } |
|
21 | + /** |
|
22 | + * TicketVisibilityEnum constructor. |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + $this->setName($this->namespace . 'TicketVisibilityEnum'); |
|
27 | + $this->setDescription(esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso')); |
|
28 | + parent::__construct(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - protected function getValues(): array |
|
38 | - { |
|
39 | - return EEM_Ticket::instance()->getTicketVisibilityValues(); |
|
40 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + protected function getValues(): array |
|
38 | + { |
|
39 | + return EEM_Ticket::instance()->getTicketVisibilityValues(); |
|
40 | + } |
|
41 | 41 | } |
@@ -20,34 +20,34 @@ |
||
20 | 20 | class ModelNameEnum extends EnumBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * ModelNameEnum constructor. |
|
25 | - */ |
|
26 | - public function __construct() |
|
27 | - { |
|
28 | - $this->setName($this->namespace . 'ModelNameEnum'); |
|
29 | - $this->setDescription(esc_html__('Entity model name', 'event_espresso')); |
|
30 | - parent::__construct(); |
|
31 | - } |
|
23 | + /** |
|
24 | + * ModelNameEnum constructor. |
|
25 | + */ |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + $this->setName($this->namespace . 'ModelNameEnum'); |
|
29 | + $this->setDescription(esc_html__('Entity model name', 'event_espresso')); |
|
30 | + parent::__construct(); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return array |
|
36 | - * @throws EE_Error |
|
37 | - * @throws ReflectionException |
|
38 | - */ |
|
39 | - protected function getValues(): array |
|
40 | - { |
|
41 | - return [ |
|
42 | - 'DATETIME' => [ |
|
43 | - 'value' => EEM_Datetime::instance()->item_name(), |
|
44 | - ], |
|
45 | - 'TICKET' => [ |
|
46 | - 'value' => EEM_Ticket::instance()->item_name(), |
|
47 | - ], |
|
48 | - 'PRICE' => [ |
|
49 | - 'value' => EEM_Price::instance()->item_name(), |
|
50 | - ], |
|
51 | - ]; |
|
52 | - } |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + * @throws EE_Error |
|
37 | + * @throws ReflectionException |
|
38 | + */ |
|
39 | + protected function getValues(): array |
|
40 | + { |
|
41 | + return [ |
|
42 | + 'DATETIME' => [ |
|
43 | + 'value' => EEM_Datetime::instance()->item_name(), |
|
44 | + ], |
|
45 | + 'TICKET' => [ |
|
46 | + 'value' => EEM_Ticket::instance()->item_name(), |
|
47 | + ], |
|
48 | + 'PRICE' => [ |
|
49 | + 'value' => EEM_Price::instance()->item_name(), |
|
50 | + ], |
|
51 | + ]; |
|
52 | + } |
|
53 | 53 | } |
@@ -16,38 +16,38 @@ |
||
16 | 16 | class FormSectionAppliesToEnum extends EnumBase |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * FormSectionAppliesToEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'FormSectionAppliesToEnum'); |
|
25 | - $this->setDescription(esc_html__( |
|
26 | - 'Form user type that this form section should be presented to.', |
|
27 | - 'event_espresso' |
|
28 | - )); |
|
29 | - parent::__construct(); |
|
30 | - } |
|
19 | + /** |
|
20 | + * FormSectionAppliesToEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'FormSectionAppliesToEnum'); |
|
25 | + $this->setDescription(esc_html__( |
|
26 | + 'Form user type that this form section should be presented to.', |
|
27 | + 'event_espresso' |
|
28 | + )); |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - protected function getValues(): array |
|
37 | - { |
|
38 | - return [ |
|
39 | - 'ALL' => [ |
|
40 | - 'value' => EEM_Form_Section::APPLIES_TO_ALL, |
|
41 | - ], |
|
42 | - 'PRIMARY' => [ |
|
43 | - 'value' => EEM_Form_Section::APPLIES_TO_PRIMARY, |
|
44 | - ], |
|
45 | - 'PURCHASER' => [ |
|
46 | - 'value' => EEM_Form_Section::APPLIES_TO_PURCHASER, |
|
47 | - ], |
|
48 | - 'REGISTRANTS' => [ |
|
49 | - 'value' => EEM_Form_Section::APPLIES_TO_REGISTRANTS, |
|
50 | - ], |
|
51 | - ]; |
|
52 | - } |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + protected function getValues(): array |
|
37 | + { |
|
38 | + return [ |
|
39 | + 'ALL' => [ |
|
40 | + 'value' => EEM_Form_Section::APPLIES_TO_ALL, |
|
41 | + ], |
|
42 | + 'PRIMARY' => [ |
|
43 | + 'value' => EEM_Form_Section::APPLIES_TO_PRIMARY, |
|
44 | + ], |
|
45 | + 'PURCHASER' => [ |
|
46 | + 'value' => EEM_Form_Section::APPLIES_TO_PURCHASER, |
|
47 | + ], |
|
48 | + 'REGISTRANTS' => [ |
|
49 | + 'value' => EEM_Form_Section::APPLIES_TO_REGISTRANTS, |
|
50 | + ], |
|
51 | + ]; |
|
52 | + } |
|
53 | 53 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->setName($this->namespace . 'FormSectionAppliesToEnum'); |
|
24 | + $this->setName($this->namespace.'FormSectionAppliesToEnum'); |
|
25 | 25 | $this->setDescription(esc_html__( |
26 | 26 | 'Form user type that this form section should be presented to.', |
27 | 27 | 'event_espresso' |
@@ -12,99 +12,99 @@ |
||
12 | 12 | */ |
13 | 13 | class Utilities |
14 | 14 | { |
15 | - /** |
|
16 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
17 | - * friendly keys. |
|
18 | - * |
|
19 | - * @param array $where_args |
|
20 | - * @param array $arg_mapping array where keys are GQL field names and values are EE modal field names |
|
21 | - * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
22 | - * @param array $options Additional parameters for modifying args: [ |
|
23 | - * 'include_all_args' => bool, // will return ALL args in $where_args if true |
|
24 | - * 'use_IN_operator' => bool, // arrays of IDs will use SQL IN clause if true |
|
25 | - * ] |
|
26 | - * @return array |
|
27 | - */ |
|
28 | - public function sanitizeWhereArgs( |
|
29 | - array $where_args, |
|
30 | - array $arg_mapping, |
|
31 | - array $id_fields, |
|
32 | - array $options = [] |
|
33 | - ): array { |
|
34 | - // if "include_all_args" is true, then the incoming $where_args array |
|
35 | - // will be copied to the outgoing $where_params prior to sanitizing the fields. |
|
36 | - // so ALL elements in the $where_args array will be present in the $where_params array |
|
37 | - $include_all_args = isset($options['include_all_args']) |
|
38 | - ? filter_var($options['include_all_args'], FILTER_VALIDATE_BOOLEAN) |
|
39 | - : false; |
|
40 | - // if "use_IN_operator" is true, then any ID args found in the $id_fields array |
|
41 | - // will have their values converted to use an SQL "IN" clause format |
|
42 | - // if the value returned from Relay::fromGlobalId() is an array of IDs |
|
43 | - $use_IN_operator = isset($options['use_IN_operator']) |
|
44 | - && filter_var($options['use_IN_operator'], FILTER_VALIDATE_BOOLEAN); |
|
45 | - $where_params = $include_all_args ? $where_args : []; |
|
46 | - foreach ($where_args as $arg => $value) { |
|
47 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
48 | - continue; |
|
49 | - } |
|
50 | - if (is_array($value) && ! empty($value)) { |
|
51 | - $value = array_map( |
|
52 | - static function ($value) { |
|
53 | - if (is_string($value)) { |
|
54 | - $value = sanitize_text_field($value); |
|
55 | - } |
|
56 | - return $value; |
|
57 | - }, |
|
58 | - $value |
|
59 | - ); |
|
60 | - } elseif (is_string($value)) { |
|
61 | - $value = sanitize_text_field($value); |
|
62 | - } |
|
63 | - if (in_array($arg, $id_fields, true)) { |
|
64 | - $ID = $this->convertFromGlobalId($value); |
|
65 | - // Use the proper operator. |
|
66 | - $value = $use_IN_operator && is_array($ID) ? ['IN', $ID] : $ID; |
|
67 | - } |
|
68 | - $where_params[ $arg_mapping[ $arg ] ] = $value; |
|
69 | - } |
|
70 | - return $where_params; |
|
71 | - } |
|
15 | + /** |
|
16 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
17 | + * friendly keys. |
|
18 | + * |
|
19 | + * @param array $where_args |
|
20 | + * @param array $arg_mapping array where keys are GQL field names and values are EE modal field names |
|
21 | + * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
22 | + * @param array $options Additional parameters for modifying args: [ |
|
23 | + * 'include_all_args' => bool, // will return ALL args in $where_args if true |
|
24 | + * 'use_IN_operator' => bool, // arrays of IDs will use SQL IN clause if true |
|
25 | + * ] |
|
26 | + * @return array |
|
27 | + */ |
|
28 | + public function sanitizeWhereArgs( |
|
29 | + array $where_args, |
|
30 | + array $arg_mapping, |
|
31 | + array $id_fields, |
|
32 | + array $options = [] |
|
33 | + ): array { |
|
34 | + // if "include_all_args" is true, then the incoming $where_args array |
|
35 | + // will be copied to the outgoing $where_params prior to sanitizing the fields. |
|
36 | + // so ALL elements in the $where_args array will be present in the $where_params array |
|
37 | + $include_all_args = isset($options['include_all_args']) |
|
38 | + ? filter_var($options['include_all_args'], FILTER_VALIDATE_BOOLEAN) |
|
39 | + : false; |
|
40 | + // if "use_IN_operator" is true, then any ID args found in the $id_fields array |
|
41 | + // will have their values converted to use an SQL "IN" clause format |
|
42 | + // if the value returned from Relay::fromGlobalId() is an array of IDs |
|
43 | + $use_IN_operator = isset($options['use_IN_operator']) |
|
44 | + && filter_var($options['use_IN_operator'], FILTER_VALIDATE_BOOLEAN); |
|
45 | + $where_params = $include_all_args ? $where_args : []; |
|
46 | + foreach ($where_args as $arg => $value) { |
|
47 | + if (! array_key_exists($arg, $arg_mapping)) { |
|
48 | + continue; |
|
49 | + } |
|
50 | + if (is_array($value) && ! empty($value)) { |
|
51 | + $value = array_map( |
|
52 | + static function ($value) { |
|
53 | + if (is_string($value)) { |
|
54 | + $value = sanitize_text_field($value); |
|
55 | + } |
|
56 | + return $value; |
|
57 | + }, |
|
58 | + $value |
|
59 | + ); |
|
60 | + } elseif (is_string($value)) { |
|
61 | + $value = sanitize_text_field($value); |
|
62 | + } |
|
63 | + if (in_array($arg, $id_fields, true)) { |
|
64 | + $ID = $this->convertFromGlobalId($value); |
|
65 | + // Use the proper operator. |
|
66 | + $value = $use_IN_operator && is_array($ID) ? ['IN', $ID] : $ID; |
|
67 | + } |
|
68 | + $where_params[ $arg_mapping[ $arg ] ] = $value; |
|
69 | + } |
|
70 | + return $where_params; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * Converts global ID to DB ID. |
|
76 | - * |
|
77 | - * @param string|string[] $ID |
|
78 | - * @return mixed |
|
79 | - */ |
|
80 | - public function convertFromGlobalId($ID) |
|
81 | - { |
|
82 | - if (is_array($ID)) { |
|
83 | - return array_map([$this, 'convertFromGlobalId'], $ID); |
|
84 | - } |
|
85 | - $parts = Relay::fromGlobalId($ID); |
|
86 | - return ! empty($parts['id']) ? $parts['id'] : null; |
|
87 | - } |
|
74 | + /** |
|
75 | + * Converts global ID to DB ID. |
|
76 | + * |
|
77 | + * @param string|string[] $ID |
|
78 | + * @return mixed |
|
79 | + */ |
|
80 | + public function convertFromGlobalId($ID) |
|
81 | + { |
|
82 | + if (is_array($ID)) { |
|
83 | + return array_map([$this, 'convertFromGlobalId'], $ID); |
|
84 | + } |
|
85 | + $parts = Relay::fromGlobalId($ID); |
|
86 | + return ! empty($parts['id']) ? $parts['id'] : null; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Convert the DB ID into GID |
|
92 | - * |
|
93 | - * @param string $type |
|
94 | - * @param int|int[] $ID |
|
95 | - * @return mixed |
|
96 | - */ |
|
97 | - public function convertToGlobalId(string $type, $ID) |
|
98 | - { |
|
99 | - $convertToGlobalId = [$this, 'convertToGlobalId']; |
|
100 | - if (is_array($ID)) { |
|
101 | - return array_map( |
|
102 | - static function ($id) use ($convertToGlobalId, $type) { |
|
103 | - return $convertToGlobalId($type, $id); |
|
104 | - }, |
|
105 | - $ID |
|
106 | - ); |
|
107 | - } |
|
108 | - return Relay::toGlobalId($type, $ID); |
|
109 | - } |
|
90 | + /** |
|
91 | + * Convert the DB ID into GID |
|
92 | + * |
|
93 | + * @param string $type |
|
94 | + * @param int|int[] $ID |
|
95 | + * @return mixed |
|
96 | + */ |
|
97 | + public function convertToGlobalId(string $type, $ID) |
|
98 | + { |
|
99 | + $convertToGlobalId = [$this, 'convertToGlobalId']; |
|
100 | + if (is_array($ID)) { |
|
101 | + return array_map( |
|
102 | + static function ($id) use ($convertToGlobalId, $type) { |
|
103 | + return $convertToGlobalId($type, $id); |
|
104 | + }, |
|
105 | + $ID |
|
106 | + ); |
|
107 | + } |
|
108 | + return Relay::toGlobalId($type, $ID); |
|
109 | + } |
|
110 | 110 | } |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | && filter_var($options['use_IN_operator'], FILTER_VALIDATE_BOOLEAN); |
45 | 45 | $where_params = $include_all_args ? $where_args : []; |
46 | 46 | foreach ($where_args as $arg => $value) { |
47 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
47 | + if ( ! array_key_exists($arg, $arg_mapping)) { |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | if (is_array($value) && ! empty($value)) { |
51 | 51 | $value = array_map( |
52 | - static function ($value) { |
|
52 | + static function($value) { |
|
53 | 53 | if (is_string($value)) { |
54 | 54 | $value = sanitize_text_field($value); |
55 | 55 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | // Use the proper operator. |
66 | 66 | $value = $use_IN_operator && is_array($ID) ? ['IN', $ID] : $ID; |
67 | 67 | } |
68 | - $where_params[ $arg_mapping[ $arg ] ] = $value; |
|
68 | + $where_params[$arg_mapping[$arg]] = $value; |
|
69 | 69 | } |
70 | 70 | return $where_params; |
71 | 71 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $convertToGlobalId = [$this, 'convertToGlobalId']; |
100 | 100 | if (is_array($ID)) { |
101 | 101 | return array_map( |
102 | - static function ($id) use ($convertToGlobalId, $type) { |
|
102 | + static function($id) use ($convertToGlobalId, $type) { |
|
103 | 103 | return $convertToGlobalId($type, $id); |
104 | 104 | }, |
105 | 105 | $ID |
@@ -20,43 +20,43 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * TicketConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Ticket $model) |
|
29 | - { |
|
30 | - parent::__construct($model); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function config(): array |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => 'RootQuery', |
|
41 | - 'toType' => $this->namespace . 'Ticket', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Tickets', |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryTicketsConnection", |
|
44 | - 'connectionArgs' => DatetimeTicketsConnection::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return TicketConnectionResolver |
|
56 | - * @throws Exception |
|
57 | - */ |
|
58 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | - { |
|
60 | - return new TicketConnectionResolver($entity, $args, $context, $info); |
|
61 | - } |
|
23 | + /** |
|
24 | + * TicketConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Ticket $model) |
|
29 | + { |
|
30 | + parent::__construct($model); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function config(): array |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'Ticket', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace) . 'Tickets', |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryTicketsConnection", |
|
44 | + 'connectionArgs' => DatetimeTicketsConnection::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return TicketConnectionResolver |
|
56 | + * @throws Exception |
|
57 | + */ |
|
58 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | + { |
|
60 | + return new TicketConnectionResolver($entity, $args, $context, $info); |
|
61 | + } |
|
62 | 62 | } |
@@ -20,43 +20,43 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * PriceConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_Price $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Price $model) |
|
29 | - { |
|
30 | - parent::__construct($model); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function config(): array |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => 'RootQuery', |
|
41 | - 'toType' => $this->namespace . 'Price', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Prices', |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryPricesConnection", |
|
44 | - 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return PriceConnectionResolver |
|
56 | - * @throws Exception |
|
57 | - */ |
|
58 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | - { |
|
60 | - return new PriceConnectionResolver($entity, $args, $context, $info); |
|
61 | - } |
|
23 | + /** |
|
24 | + * PriceConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_Price $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Price $model) |
|
29 | + { |
|
30 | + parent::__construct($model); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function config(): array |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'Price', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace) . 'Prices', |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryPricesConnection", |
|
44 | + 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return PriceConnectionResolver |
|
56 | + * @throws Exception |
|
57 | + */ |
|
58 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | + { |
|
60 | + return new PriceConnectionResolver($entity, $args, $context, $info); |
|
61 | + } |
|
62 | 62 | } |
@@ -20,127 +20,127 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * DatetimeConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Ticket $model) |
|
29 | - { |
|
30 | - parent::__construct($model); |
|
31 | - } |
|
23 | + /** |
|
24 | + * DatetimeConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Ticket $model) |
|
29 | + { |
|
30 | + parent::__construct($model); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function config(): array |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => $this->namespace . 'Datetime', |
|
41 | - 'toType' => $this->namespace . 'Ticket', |
|
42 | - 'fromFieldName' => 'tickets', |
|
43 | - 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
44 | - 'connectionArgs' => self::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function config(): array |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => $this->namespace . 'Datetime', |
|
41 | + 'toType' => $this->namespace . 'Ticket', |
|
42 | + 'fromFieldName' => 'tickets', |
|
43 | + 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
44 | + 'connectionArgs' => self::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return array|Deferred|mixed |
|
56 | - * @throws Exception |
|
57 | - */ |
|
58 | - public function resolveConnection($entity, $args, $context, $info) |
|
59 | - { |
|
60 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
61 | - return $resolver->get_connection(); |
|
62 | - } |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return array|Deferred|mixed |
|
56 | + * @throws Exception |
|
57 | + */ |
|
58 | + public function resolveConnection($entity, $args, $context, $info) |
|
59 | + { |
|
60 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
61 | + return $resolver->get_connection(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Given an optional array of args, this returns the args to be used in the connection |
|
66 | - * |
|
67 | - * @param array $args The args to modify the defaults |
|
68 | - * @return array |
|
69 | - */ |
|
70 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
71 | - public static function get_connection_args(array $args = []): array |
|
72 | - { |
|
73 | - $newArgs = [ |
|
74 | - 'orderby' => [ |
|
75 | - 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], |
|
76 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
77 | - ], |
|
78 | - 'datetime' => [ |
|
79 | - 'type' => 'ID', |
|
80 | - 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
81 | - ], |
|
82 | - 'datetimeIn' => [ |
|
83 | - 'type' => ['list_of' => 'ID'], |
|
84 | - 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
85 | - ], |
|
86 | - 'datetimeId' => [ |
|
87 | - 'type' => 'Int', |
|
88 | - 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
89 | - ], |
|
90 | - 'datetimeIdIn' => [ |
|
91 | - 'type' => ['list_of' => 'Int'], |
|
92 | - 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
93 | - ], |
|
94 | - 'event' => [ |
|
95 | - 'type' => 'ID', |
|
96 | - 'description' => esc_html__('Globally unique event ID to get the tickets for.', 'event_espresso'), |
|
97 | - ], |
|
98 | - 'eventIn' => [ |
|
99 | - 'type' => ['list_of' => 'ID'], |
|
100 | - 'description' => esc_html__('Globally unique event IDs to get the tickets for.', 'event_espresso'), |
|
101 | - ], |
|
102 | - 'eventId' => [ |
|
103 | - 'type' => 'Int', |
|
104 | - 'description' => esc_html__('Event ID to get the tickets for.', 'event_espresso'), |
|
105 | - ], |
|
106 | - 'eventIdIn' => [ |
|
107 | - 'type' => ['list_of' => 'Int'], |
|
108 | - 'description' => esc_html__('Event IDs to get the tickets for.', 'event_espresso'), |
|
109 | - ], |
|
110 | - 'includeDefaultTickets' => [ |
|
111 | - 'type' => 'Boolean', |
|
112 | - 'description' => esc_html__('Whether to add default tickets to the list.', 'event_espresso'), |
|
113 | - ], |
|
114 | - 'search' => [ |
|
115 | - 'type' => 'String', |
|
116 | - 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
117 | - ], |
|
118 | - 'isDefault' => [ |
|
119 | - 'type' => 'Boolean', |
|
120 | - 'description' => esc_html__('Filter the default tickets', 'event_espresso'), |
|
121 | - ], |
|
122 | - 'isRequired' => [ |
|
123 | - 'type' => 'Boolean', |
|
124 | - 'description' => esc_html__('Filter the required tickets', 'event_espresso'), |
|
125 | - ], |
|
126 | - 'isTaxable' => [ |
|
127 | - 'type' => 'Boolean', |
|
128 | - 'description' => esc_html__('Filter the taxable tickets', 'event_espresso'), |
|
129 | - ], |
|
130 | - 'isTrashed' => [ |
|
131 | - 'type' => 'Boolean', |
|
132 | - 'description' => esc_html__('Filter the trashed tickets', 'event_espresso'), |
|
133 | - ], |
|
134 | - ]; |
|
64 | + /** |
|
65 | + * Given an optional array of args, this returns the args to be used in the connection |
|
66 | + * |
|
67 | + * @param array $args The args to modify the defaults |
|
68 | + * @return array |
|
69 | + */ |
|
70 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
71 | + public static function get_connection_args(array $args = []): array |
|
72 | + { |
|
73 | + $newArgs = [ |
|
74 | + 'orderby' => [ |
|
75 | + 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], |
|
76 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
77 | + ], |
|
78 | + 'datetime' => [ |
|
79 | + 'type' => 'ID', |
|
80 | + 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
81 | + ], |
|
82 | + 'datetimeIn' => [ |
|
83 | + 'type' => ['list_of' => 'ID'], |
|
84 | + 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
85 | + ], |
|
86 | + 'datetimeId' => [ |
|
87 | + 'type' => 'Int', |
|
88 | + 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
89 | + ], |
|
90 | + 'datetimeIdIn' => [ |
|
91 | + 'type' => ['list_of' => 'Int'], |
|
92 | + 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
93 | + ], |
|
94 | + 'event' => [ |
|
95 | + 'type' => 'ID', |
|
96 | + 'description' => esc_html__('Globally unique event ID to get the tickets for.', 'event_espresso'), |
|
97 | + ], |
|
98 | + 'eventIn' => [ |
|
99 | + 'type' => ['list_of' => 'ID'], |
|
100 | + 'description' => esc_html__('Globally unique event IDs to get the tickets for.', 'event_espresso'), |
|
101 | + ], |
|
102 | + 'eventId' => [ |
|
103 | + 'type' => 'Int', |
|
104 | + 'description' => esc_html__('Event ID to get the tickets for.', 'event_espresso'), |
|
105 | + ], |
|
106 | + 'eventIdIn' => [ |
|
107 | + 'type' => ['list_of' => 'Int'], |
|
108 | + 'description' => esc_html__('Event IDs to get the tickets for.', 'event_espresso'), |
|
109 | + ], |
|
110 | + 'includeDefaultTickets' => [ |
|
111 | + 'type' => 'Boolean', |
|
112 | + 'description' => esc_html__('Whether to add default tickets to the list.', 'event_espresso'), |
|
113 | + ], |
|
114 | + 'search' => [ |
|
115 | + 'type' => 'String', |
|
116 | + 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
117 | + ], |
|
118 | + 'isDefault' => [ |
|
119 | + 'type' => 'Boolean', |
|
120 | + 'description' => esc_html__('Filter the default tickets', 'event_espresso'), |
|
121 | + ], |
|
122 | + 'isRequired' => [ |
|
123 | + 'type' => 'Boolean', |
|
124 | + 'description' => esc_html__('Filter the required tickets', 'event_espresso'), |
|
125 | + ], |
|
126 | + 'isTaxable' => [ |
|
127 | + 'type' => 'Boolean', |
|
128 | + 'description' => esc_html__('Filter the taxable tickets', 'event_espresso'), |
|
129 | + ], |
|
130 | + 'isTrashed' => [ |
|
131 | + 'type' => 'Boolean', |
|
132 | + 'description' => esc_html__('Filter the trashed tickets', 'event_espresso'), |
|
133 | + ], |
|
134 | + ]; |
|
135 | 135 | |
136 | - $newArgs = apply_filters( |
|
137 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', |
|
138 | - $newArgs, |
|
139 | - $args |
|
140 | - ); |
|
141 | - return array_merge( |
|
142 | - $newArgs, |
|
143 | - $args |
|
144 | - ); |
|
145 | - } |
|
136 | + $newArgs = apply_filters( |
|
137 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', |
|
138 | + $newArgs, |
|
139 | + $args |
|
140 | + ); |
|
141 | + return array_merge( |
|
142 | + $newArgs, |
|
143 | + $args |
|
144 | + ); |
|
145 | + } |
|
146 | 146 | } |
@@ -37,8 +37,8 @@ |
||
37 | 37 | public function config(): array |
38 | 38 | { |
39 | 39 | return [ |
40 | - 'fromType' => $this->namespace . 'Datetime', |
|
41 | - 'toType' => $this->namespace . 'Ticket', |
|
40 | + 'fromType' => $this->namespace.'Datetime', |
|
41 | + 'toType' => $this->namespace.'Ticket', |
|
42 | 42 | 'fromFieldName' => 'tickets', |
43 | 43 | 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
44 | 44 | 'connectionArgs' => self::get_connection_args(), |