@@ -14,52 +14,52 @@ |
||
14 | 14 | class FormSectionUpdate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Form_Section $model |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Updates an entity. |
|
27 | - * |
|
28 | - * @param array $input The input for the mutation |
|
29 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | - * @return array |
|
32 | - * @throws EE_Error |
|
33 | - * @throws ReflectionException |
|
34 | - */ |
|
35 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | - try { |
|
37 | - /** @var EE_Form_Section $entity */ |
|
38 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Form_Section $model |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Updates an entity. |
|
27 | + * |
|
28 | + * @param array $input The input for the mutation |
|
29 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | + * @return array |
|
32 | + * @throws EE_Error |
|
33 | + * @throws ReflectionException |
|
34 | + */ |
|
35 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | + try { |
|
37 | + /** @var EE_Form_Section $entity */ |
|
38 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
39 | 39 | |
40 | - $args = FormSectionMutation::prepareFields($input); |
|
40 | + $args = FormSectionMutation::prepareFields($input); |
|
41 | 41 | |
42 | - // Update the entity |
|
43 | - $entity->save($args); |
|
42 | + // Update the entity |
|
43 | + $entity->save($args); |
|
44 | 44 | |
45 | - do_action( |
|
46 | - 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_update', |
|
47 | - $entity, |
|
48 | - $input |
|
49 | - ); |
|
50 | - } catch (Exception $exception) { |
|
51 | - EntityMutator::handleExceptions( |
|
52 | - $exception, |
|
53 | - esc_html__( |
|
54 | - 'The form section could not be updated because of the following error(s)', |
|
55 | - 'event_espresso' |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
45 | + do_action( |
|
46 | + 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_update', |
|
47 | + $entity, |
|
48 | + $input |
|
49 | + ); |
|
50 | + } catch (Exception $exception) { |
|
51 | + EntityMutator::handleExceptions( |
|
52 | + $exception, |
|
53 | + esc_html__( |
|
54 | + 'The form section could not be updated because of the following error(s)', |
|
55 | + 'event_espresso' |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - return [ |
|
61 | - 'id' => $entity->UUID(), |
|
62 | - ]; |
|
63 | - }; |
|
64 | - } |
|
60 | + return [ |
|
61 | + 'id' => $entity->UUID(), |
|
62 | + ]; |
|
63 | + }; |
|
64 | + } |
|
65 | 65 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @throws EE_Error |
33 | 33 | * @throws ReflectionException |
34 | 34 | */ |
35 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
35 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | 36 | try { |
37 | 37 | /** @var EE_Form_Section $entity */ |
38 | 38 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -17,91 +17,91 @@ |
||
17 | 17 | class TicketDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Ticket $model |
|
24 | - * @param Ticket $type |
|
25 | - * @return callable |
|
26 | - */ |
|
27 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
28 | - { |
|
29 | - /** |
|
30 | - * Deletes an entity. |
|
31 | - * |
|
32 | - * @param array $input The input for the mutation |
|
33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | - try { |
|
39 | - /** @var EE_Ticket $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Ticket $model |
|
24 | + * @param Ticket $type |
|
25 | + * @return callable |
|
26 | + */ |
|
27 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
28 | + { |
|
29 | + /** |
|
30 | + * Deletes an entity. |
|
31 | + * |
|
32 | + * @param array $input The input for the mutation |
|
33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | + try { |
|
39 | + /** @var EE_Ticket $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - // Delete the entity |
|
43 | - if (! empty($input['deletePermanently'])) { |
|
44 | - $result = TicketDelete::deleteTicketAndRelations($entity); |
|
45 | - } else { |
|
46 | - // trash the ticket |
|
47 | - $result = TicketDelete::trashTicket($entity); |
|
48 | - } |
|
49 | - EntityMutator::validateResults($result); |
|
42 | + // Delete the entity |
|
43 | + if (! empty($input['deletePermanently'])) { |
|
44 | + $result = TicketDelete::deleteTicketAndRelations($entity); |
|
45 | + } else { |
|
46 | + // trash the ticket |
|
47 | + $result = TicketDelete::trashTicket($entity); |
|
48 | + } |
|
49 | + EntityMutator::validateResults($result); |
|
50 | 50 | |
51 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_delete', $entity, $input); |
|
52 | - } catch (Exception $exception) { |
|
53 | - EntityMutator::handleExceptions( |
|
54 | - $exception, |
|
55 | - esc_html__( |
|
56 | - 'The ticket could not be deleted because of the following error(s)', |
|
57 | - 'event_espresso' |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
51 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_delete', $entity, $input); |
|
52 | + } catch (Exception $exception) { |
|
53 | + EntityMutator::handleExceptions( |
|
54 | + $exception, |
|
55 | + esc_html__( |
|
56 | + 'The ticket could not be deleted because of the following error(s)', |
|
57 | + 'event_espresso' |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | |
62 | - return [ |
|
63 | - 'deleted' => $entity, |
|
64 | - ]; |
|
65 | - }; |
|
66 | - } |
|
62 | + return [ |
|
63 | + 'deleted' => $entity, |
|
64 | + ]; |
|
65 | + }; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Deletes a ticket permanently along with its relations. |
|
70 | - * |
|
71 | - * @param EE_Ticket $entity |
|
72 | - * @return bool | int |
|
73 | - * @throws ReflectionException |
|
74 | - * @throws InvalidArgumentException |
|
75 | - * @throws InvalidInterfaceException |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - * @throws EE_Error |
|
78 | - */ |
|
79 | - public static function deleteTicketAndRelations(EE_Ticket $entity) |
|
80 | - { |
|
81 | - // Remove related non-default prices for the ticket |
|
82 | - $entity->delete_related_permanently('Price', [['PRC_is_default' => false]]); |
|
83 | - // The ticket still might have relations with default taxes, lets divorce them |
|
84 | - $entity->_remove_relations('Price'); |
|
85 | - // Remove relation with datetimes |
|
86 | - $entity->_remove_relations('Datetime'); |
|
87 | - // Now delete the ticket permanently |
|
88 | - return $entity->delete_permanently(); |
|
89 | - } |
|
68 | + /** |
|
69 | + * Deletes a ticket permanently along with its relations. |
|
70 | + * |
|
71 | + * @param EE_Ticket $entity |
|
72 | + * @return bool | int |
|
73 | + * @throws ReflectionException |
|
74 | + * @throws InvalidArgumentException |
|
75 | + * @throws InvalidInterfaceException |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + * @throws EE_Error |
|
78 | + */ |
|
79 | + public static function deleteTicketAndRelations(EE_Ticket $entity) |
|
80 | + { |
|
81 | + // Remove related non-default prices for the ticket |
|
82 | + $entity->delete_related_permanently('Price', [['PRC_is_default' => false]]); |
|
83 | + // The ticket still might have relations with default taxes, lets divorce them |
|
84 | + $entity->_remove_relations('Price'); |
|
85 | + // Remove relation with datetimes |
|
86 | + $entity->_remove_relations('Datetime'); |
|
87 | + // Now delete the ticket permanently |
|
88 | + return $entity->delete_permanently(); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Trashes a ticket. |
|
93 | - * |
|
94 | - * @param EE_Ticket $entity |
|
95 | - * @return bool | int |
|
96 | - * @throws ReflectionException |
|
97 | - * @throws InvalidArgumentException |
|
98 | - * @throws InvalidInterfaceException |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - * @throws EE_Error |
|
101 | - */ |
|
102 | - public static function trashTicket(EE_Ticket $entity) |
|
103 | - { |
|
104 | - // trash the ticket |
|
105 | - return $entity->delete(); |
|
106 | - } |
|
91 | + /** |
|
92 | + * Trashes a ticket. |
|
93 | + * |
|
94 | + * @param EE_Ticket $entity |
|
95 | + * @return bool | int |
|
96 | + * @throws ReflectionException |
|
97 | + * @throws InvalidArgumentException |
|
98 | + * @throws InvalidInterfaceException |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + * @throws EE_Error |
|
101 | + */ |
|
102 | + public static function trashTicket(EE_Ticket $entity) |
|
103 | + { |
|
104 | + // trash the ticket |
|
105 | + return $entity->delete(); |
|
106 | + } |
|
107 | 107 | } |
@@ -34,13 +34,13 @@ |
||
34 | 34 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
35 | 35 | * @return array |
36 | 36 | */ |
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | 38 | try { |
39 | 39 | /** @var EE_Ticket $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
41 | 41 | |
42 | 42 | // Delete the entity |
43 | - if (! empty($input['deletePermanently'])) { |
|
43 | + if ( ! empty($input['deletePermanently'])) { |
|
44 | 44 | $result = TicketDelete::deleteTicketAndRelations($entity); |
45 | 45 | } else { |
46 | 46 | // trash the ticket |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
30 | 30 | * @return array |
31 | 31 | */ |
32 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
32 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
33 | 33 | $id = null; |
34 | 34 | try { |
35 | 35 | EntityMutator::checkPermissions($model); |
@@ -11,51 +11,51 @@ |
||
11 | 11 | |
12 | 12 | class FormSectionCreate extends EntityMutator |
13 | 13 | { |
14 | - /** |
|
15 | - * Defines the mutation data modification closure. |
|
16 | - * |
|
17 | - * @param EEM_Form_Section $model |
|
18 | - * @return callable |
|
19 | - */ |
|
20 | - public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
21 | - { |
|
22 | - /** |
|
23 | - * Creates an entity. |
|
24 | - * |
|
25 | - * @param array $input The input for the mutation |
|
26 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
27 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
28 | - * @return array |
|
29 | - */ |
|
30 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
31 | - $id = null; |
|
32 | - try { |
|
33 | - EntityMutator::checkPermissions($model); |
|
14 | + /** |
|
15 | + * Defines the mutation data modification closure. |
|
16 | + * |
|
17 | + * @param EEM_Form_Section $model |
|
18 | + * @return callable |
|
19 | + */ |
|
20 | + public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
21 | + { |
|
22 | + /** |
|
23 | + * Creates an entity. |
|
24 | + * |
|
25 | + * @param array $input The input for the mutation |
|
26 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
27 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
28 | + * @return array |
|
29 | + */ |
|
30 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
31 | + $id = null; |
|
32 | + try { |
|
33 | + EntityMutator::checkPermissions($model); |
|
34 | 34 | |
35 | - $args = FormSectionMutation::prepareFields($input); |
|
35 | + $args = FormSectionMutation::prepareFields($input); |
|
36 | 36 | |
37 | - $entity = EE_Form_Section::new_instance($args); |
|
38 | - $id = $entity->save(); |
|
39 | - EntityMutator::validateResults($id); |
|
37 | + $entity = EE_Form_Section::new_instance($args); |
|
38 | + $id = $entity->save(); |
|
39 | + EntityMutator::validateResults($id); |
|
40 | 40 | |
41 | - do_action( |
|
42 | - 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_create', |
|
43 | - $entity, |
|
44 | - $input |
|
45 | - ); |
|
46 | - } catch (Exception $exception) { |
|
47 | - EntityMutator::handleExceptions( |
|
48 | - $exception, |
|
49 | - esc_html__( |
|
50 | - 'The form section could not be created because of the following error(s)', |
|
51 | - 'event_espresso' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
41 | + do_action( |
|
42 | + 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_create', |
|
43 | + $entity, |
|
44 | + $input |
|
45 | + ); |
|
46 | + } catch (Exception $exception) { |
|
47 | + EntityMutator::handleExceptions( |
|
48 | + $exception, |
|
49 | + esc_html__( |
|
50 | + 'The form section could not be created because of the following error(s)', |
|
51 | + 'event_espresso' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - return [ |
|
57 | - 'id' => $id, |
|
58 | - ]; |
|
59 | - }; |
|
60 | - } |
|
56 | + return [ |
|
57 | + 'id' => $id, |
|
58 | + ]; |
|
59 | + }; |
|
60 | + } |
|
61 | 61 | } |
@@ -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); |
@@ -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' |
@@ -15,38 +15,38 @@ |
||
15 | 15 | */ |
16 | 16 | class FormSectionAppliesToEnum extends EnumBase |
17 | 17 | { |
18 | - /** |
|
19 | - * FormSectionAppliesToEnum constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->setName($this->namespace . 'FormSectionAppliesToEnum'); |
|
24 | - $this->setDescription(esc_html__( |
|
25 | - 'Form user type that this form section should be presented to.', |
|
26 | - 'event_espresso' |
|
27 | - )); |
|
28 | - parent::__construct(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * FormSectionAppliesToEnum constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->setName($this->namespace . 'FormSectionAppliesToEnum'); |
|
24 | + $this->setDescription(esc_html__( |
|
25 | + 'Form user type that this form section should be presented to.', |
|
26 | + 'event_espresso' |
|
27 | + )); |
|
28 | + parent::__construct(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getValues(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'ALL' => [ |
|
39 | - 'value' => EEM_Form_Section::APPLIES_TO_ALL, |
|
40 | - ], |
|
41 | - 'PRIMARY' => [ |
|
42 | - 'value' => EEM_Form_Section::APPLIES_TO_PRIMARY, |
|
43 | - ], |
|
44 | - 'PURCHASER' => [ |
|
45 | - 'value' => EEM_Form_Section::APPLIES_TO_PURCHASER, |
|
46 | - ], |
|
47 | - 'REGISTRANTS' => [ |
|
48 | - 'value' => EEM_Form_Section::APPLIES_TO_REGISTRANTS, |
|
49 | - ], |
|
50 | - ]; |
|
51 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getValues(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'ALL' => [ |
|
39 | + 'value' => EEM_Form_Section::APPLIES_TO_ALL, |
|
40 | + ], |
|
41 | + 'PRIMARY' => [ |
|
42 | + 'value' => EEM_Form_Section::APPLIES_TO_PRIMARY, |
|
43 | + ], |
|
44 | + 'PURCHASER' => [ |
|
45 | + 'value' => EEM_Form_Section::APPLIES_TO_PURCHASER, |
|
46 | + ], |
|
47 | + 'REGISTRANTS' => [ |
|
48 | + 'value' => EEM_Form_Section::APPLIES_TO_REGISTRANTS, |
|
49 | + ], |
|
50 | + ]; |
|
51 | + } |
|
52 | 52 | } |
@@ -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 |
@@ -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 | } |
@@ -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(), |
@@ -18,127 +18,127 @@ |
||
18 | 18 | */ |
19 | 19 | class DatetimeTicketsConnection extends ConnectionBase |
20 | 20 | { |
21 | - /** |
|
22 | - * DatetimeConnection constructor. |
|
23 | - * |
|
24 | - * @param EEM_Ticket $model |
|
25 | - */ |
|
26 | - public function __construct(EEM_Ticket $model) |
|
27 | - { |
|
28 | - parent::__construct($model); |
|
29 | - } |
|
21 | + /** |
|
22 | + * DatetimeConnection constructor. |
|
23 | + * |
|
24 | + * @param EEM_Ticket $model |
|
25 | + */ |
|
26 | + public function __construct(EEM_Ticket $model) |
|
27 | + { |
|
28 | + parent::__construct($model); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function config(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'fromType' => $this->namespace . 'Datetime', |
|
39 | - 'toType' => $this->namespace . 'Ticket', |
|
40 | - 'fromFieldName' => 'tickets', |
|
41 | - 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
42 | - 'connectionArgs' => self::get_connection_args(), |
|
43 | - 'resolve' => [$this, 'resolveConnection'], |
|
44 | - ]; |
|
45 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function config(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'fromType' => $this->namespace . 'Datetime', |
|
39 | + 'toType' => $this->namespace . 'Ticket', |
|
40 | + 'fromFieldName' => 'tickets', |
|
41 | + 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
42 | + 'connectionArgs' => self::get_connection_args(), |
|
43 | + 'resolve' => [$this, 'resolveConnection'], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param $entity |
|
50 | - * @param $args |
|
51 | - * @param $context |
|
52 | - * @param $info |
|
53 | - * @return array|Deferred|mixed |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function resolveConnection($entity, $args, $context, $info) |
|
57 | - { |
|
58 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
59 | - return $resolver->get_connection(); |
|
60 | - } |
|
48 | + /** |
|
49 | + * @param $entity |
|
50 | + * @param $args |
|
51 | + * @param $context |
|
52 | + * @param $info |
|
53 | + * @return array|Deferred|mixed |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function resolveConnection($entity, $args, $context, $info) |
|
57 | + { |
|
58 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
59 | + return $resolver->get_connection(); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Given an optional array of args, this returns the args to be used in the connection |
|
64 | - * |
|
65 | - * @param array $args The args to modify the defaults |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
69 | - public static function get_connection_args(array $args = []): array |
|
70 | - { |
|
71 | - $newArgs = [ |
|
72 | - 'orderby' => [ |
|
73 | - 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], |
|
74 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
75 | - ], |
|
76 | - 'datetime' => [ |
|
77 | - 'type' => 'ID', |
|
78 | - 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
79 | - ], |
|
80 | - 'datetimeIn' => [ |
|
81 | - 'type' => ['list_of' => 'ID'], |
|
82 | - 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
83 | - ], |
|
84 | - 'datetimeId' => [ |
|
85 | - 'type' => 'Int', |
|
86 | - 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
87 | - ], |
|
88 | - 'datetimeIdIn' => [ |
|
89 | - 'type' => ['list_of' => 'Int'], |
|
90 | - 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
91 | - ], |
|
92 | - 'event' => [ |
|
93 | - 'type' => 'ID', |
|
94 | - 'description' => esc_html__('Globally unique event ID to get the tickets for.', 'event_espresso'), |
|
95 | - ], |
|
96 | - 'eventIn' => [ |
|
97 | - 'type' => ['list_of' => 'ID'], |
|
98 | - 'description' => esc_html__('Globally unique event IDs to get the tickets for.', 'event_espresso'), |
|
99 | - ], |
|
100 | - 'eventId' => [ |
|
101 | - 'type' => 'Int', |
|
102 | - 'description' => esc_html__('Event ID to get the tickets for.', 'event_espresso'), |
|
103 | - ], |
|
104 | - 'eventIdIn' => [ |
|
105 | - 'type' => ['list_of' => 'Int'], |
|
106 | - 'description' => esc_html__('Event IDs to get the tickets for.', 'event_espresso'), |
|
107 | - ], |
|
108 | - 'includeDefaultTickets' => [ |
|
109 | - 'type' => 'Boolean', |
|
110 | - 'description' => esc_html__('Whether to add default tickets to the list.', 'event_espresso'), |
|
111 | - ], |
|
112 | - 'search' => [ |
|
113 | - 'type' => 'String', |
|
114 | - 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
115 | - ], |
|
116 | - 'isDefault' => [ |
|
117 | - 'type' => 'Boolean', |
|
118 | - 'description' => esc_html__('Filter the default tickets', 'event_espresso'), |
|
119 | - ], |
|
120 | - 'isRequired' => [ |
|
121 | - 'type' => 'Boolean', |
|
122 | - 'description' => esc_html__('Filter the required tickets', 'event_espresso'), |
|
123 | - ], |
|
124 | - 'isTaxable' => [ |
|
125 | - 'type' => 'Boolean', |
|
126 | - 'description' => esc_html__('Filter the taxable tickets', 'event_espresso'), |
|
127 | - ], |
|
128 | - 'isTrashed' => [ |
|
129 | - 'type' => 'Boolean', |
|
130 | - 'description' => esc_html__('Filter the trashed tickets', 'event_espresso'), |
|
131 | - ], |
|
132 | - ]; |
|
62 | + /** |
|
63 | + * Given an optional array of args, this returns the args to be used in the connection |
|
64 | + * |
|
65 | + * @param array $args The args to modify the defaults |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
69 | + public static function get_connection_args(array $args = []): array |
|
70 | + { |
|
71 | + $newArgs = [ |
|
72 | + 'orderby' => [ |
|
73 | + 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], |
|
74 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
75 | + ], |
|
76 | + 'datetime' => [ |
|
77 | + 'type' => 'ID', |
|
78 | + 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
79 | + ], |
|
80 | + 'datetimeIn' => [ |
|
81 | + 'type' => ['list_of' => 'ID'], |
|
82 | + 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
83 | + ], |
|
84 | + 'datetimeId' => [ |
|
85 | + 'type' => 'Int', |
|
86 | + 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
87 | + ], |
|
88 | + 'datetimeIdIn' => [ |
|
89 | + 'type' => ['list_of' => 'Int'], |
|
90 | + 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
91 | + ], |
|
92 | + 'event' => [ |
|
93 | + 'type' => 'ID', |
|
94 | + 'description' => esc_html__('Globally unique event ID to get the tickets for.', 'event_espresso'), |
|
95 | + ], |
|
96 | + 'eventIn' => [ |
|
97 | + 'type' => ['list_of' => 'ID'], |
|
98 | + 'description' => esc_html__('Globally unique event IDs to get the tickets for.', 'event_espresso'), |
|
99 | + ], |
|
100 | + 'eventId' => [ |
|
101 | + 'type' => 'Int', |
|
102 | + 'description' => esc_html__('Event ID to get the tickets for.', 'event_espresso'), |
|
103 | + ], |
|
104 | + 'eventIdIn' => [ |
|
105 | + 'type' => ['list_of' => 'Int'], |
|
106 | + 'description' => esc_html__('Event IDs to get the tickets for.', 'event_espresso'), |
|
107 | + ], |
|
108 | + 'includeDefaultTickets' => [ |
|
109 | + 'type' => 'Boolean', |
|
110 | + 'description' => esc_html__('Whether to add default tickets to the list.', 'event_espresso'), |
|
111 | + ], |
|
112 | + 'search' => [ |
|
113 | + 'type' => 'String', |
|
114 | + 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
115 | + ], |
|
116 | + 'isDefault' => [ |
|
117 | + 'type' => 'Boolean', |
|
118 | + 'description' => esc_html__('Filter the default tickets', 'event_espresso'), |
|
119 | + ], |
|
120 | + 'isRequired' => [ |
|
121 | + 'type' => 'Boolean', |
|
122 | + 'description' => esc_html__('Filter the required tickets', 'event_espresso'), |
|
123 | + ], |
|
124 | + 'isTaxable' => [ |
|
125 | + 'type' => 'Boolean', |
|
126 | + 'description' => esc_html__('Filter the taxable tickets', 'event_espresso'), |
|
127 | + ], |
|
128 | + 'isTrashed' => [ |
|
129 | + 'type' => 'Boolean', |
|
130 | + 'description' => esc_html__('Filter the trashed tickets', 'event_espresso'), |
|
131 | + ], |
|
132 | + ]; |
|
133 | 133 | |
134 | - $newArgs = apply_filters( |
|
135 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', |
|
136 | - $newArgs, |
|
137 | - $args |
|
138 | - ); |
|
139 | - return array_merge( |
|
140 | - $newArgs, |
|
141 | - $args |
|
142 | - ); |
|
143 | - } |
|
134 | + $newArgs = apply_filters( |
|
135 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', |
|
136 | + $newArgs, |
|
137 | + $args |
|
138 | + ); |
|
139 | + return array_merge( |
|
140 | + $newArgs, |
|
141 | + $args |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | } |
@@ -35,8 +35,8 @@ |
||
35 | 35 | public function config(): array |
36 | 36 | { |
37 | 37 | return [ |
38 | - 'fromType' => $this->namespace . 'Ticket', |
|
39 | - 'toType' => $this->namespace . 'Price', |
|
38 | + 'fromType' => $this->namespace.'Ticket', |
|
39 | + 'toType' => $this->namespace.'Price', |
|
40 | 40 | 'fromFieldName' => 'prices', |
41 | 41 | 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
42 | 42 | 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
@@ -18,132 +18,132 @@ |
||
18 | 18 | */ |
19 | 19 | class TicketPricesConnection extends ConnectionBase |
20 | 20 | { |
21 | - /** |
|
22 | - * TicketConnection constructor. |
|
23 | - * |
|
24 | - * @param EEM_Price $model |
|
25 | - */ |
|
26 | - public function __construct(EEM_Price $model) |
|
27 | - { |
|
28 | - parent::__construct($model); |
|
29 | - } |
|
21 | + /** |
|
22 | + * TicketConnection constructor. |
|
23 | + * |
|
24 | + * @param EEM_Price $model |
|
25 | + */ |
|
26 | + public function __construct(EEM_Price $model) |
|
27 | + { |
|
28 | + parent::__construct($model); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function config(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'fromType' => $this->namespace . 'Ticket', |
|
39 | - 'toType' => $this->namespace . 'Price', |
|
40 | - 'fromFieldName' => 'prices', |
|
41 | - 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
|
42 | - 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
43 | - 'resolve' => [$this, 'resolveConnection'], |
|
44 | - ]; |
|
45 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function config(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'fromType' => $this->namespace . 'Ticket', |
|
39 | + 'toType' => $this->namespace . 'Price', |
|
40 | + 'fromFieldName' => 'prices', |
|
41 | + 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
|
42 | + 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
43 | + 'resolve' => [$this, 'resolveConnection'], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param $entity |
|
50 | - * @param $args |
|
51 | - * @param $context |
|
52 | - * @param $info |
|
53 | - * @return array|Deferred|mixed |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function resolveConnection($entity, $args, $context, $info) |
|
57 | - { |
|
58 | - $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
59 | - return $resolver->get_connection(); |
|
60 | - } |
|
48 | + /** |
|
49 | + * @param $entity |
|
50 | + * @param $args |
|
51 | + * @param $context |
|
52 | + * @param $info |
|
53 | + * @return array|Deferred|mixed |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function resolveConnection($entity, $args, $context, $info) |
|
57 | + { |
|
58 | + $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
59 | + return $resolver->get_connection(); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * Given an optional array of args, this returns the args to be used in the connection |
|
65 | - * |
|
66 | - * @param array $args The args to modify the defaults |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | - public static function get_connection_args(array $args = []): array |
|
71 | - { |
|
72 | - $newArgs = [ |
|
73 | - 'in' => [ |
|
74 | - 'type' => ['list_of' => 'ID'], |
|
75 | - 'description' => esc_html__('Limit prices to the given globally unique IDs', 'event_espresso'), |
|
76 | - ], |
|
77 | - 'idIn' => [ |
|
78 | - 'type' => ['list_of' => 'ID'], |
|
79 | - 'description' => esc_html__('Limit prices to the given IDs', 'event_espresso'), |
|
80 | - ], |
|
81 | - 'event' => [ |
|
82 | - 'type' => 'ID', |
|
83 | - 'description' => esc_html__('Globally unique event ID to get the prices for.', 'event_espresso'), |
|
84 | - ], |
|
85 | - 'eventId' => [ |
|
86 | - 'type' => 'Int', |
|
87 | - 'description' => esc_html__('Event ID to get the prices for.', 'event_espresso'), |
|
88 | - ], |
|
89 | - 'includeDefaultPrices' => [ |
|
90 | - 'type' => 'Boolean', |
|
91 | - 'description' => esc_html__('Whether to add default prices to the list.', 'event_espresso'), |
|
92 | - ], |
|
93 | - 'includeDefaultTicketsPrices' => [ |
|
94 | - 'type' => 'Boolean', |
|
95 | - 'description' => esc_html__('Whether to add default tickets prices to the list.', 'event_espresso'), |
|
96 | - ], |
|
97 | - 'isDefault' => [ |
|
98 | - 'type' => 'Boolean', |
|
99 | - 'description' => esc_html__('Filter the default prices', 'event_espresso'), |
|
100 | - ], |
|
101 | - 'ticket' => [ |
|
102 | - 'type' => 'ID', |
|
103 | - 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
104 | - ], |
|
105 | - 'ticketIn' => [ |
|
106 | - 'type' => ['list_of' => 'ID'], |
|
107 | - 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
108 | - ], |
|
109 | - 'ticketId' => [ |
|
110 | - 'type' => 'Int', |
|
111 | - 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
112 | - ], |
|
113 | - 'ticketIdIn' => [ |
|
114 | - 'type' => ['list_of' => 'Int'], |
|
115 | - 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
116 | - ], |
|
117 | - 'priceType' => [ |
|
118 | - 'type' => 'ID', |
|
119 | - 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
120 | - ], |
|
121 | - 'priceTypeIn' => [ |
|
122 | - 'type' => ['list_of' => 'ID'], |
|
123 | - 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
124 | - ], |
|
125 | - 'priceTypeId' => [ |
|
126 | - 'type' => 'Int', |
|
127 | - 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
128 | - ], |
|
129 | - 'priceTypeIdIn' => [ |
|
130 | - 'type' => ['list_of' => 'Int'], |
|
131 | - 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
132 | - ], |
|
133 | - 'priceBaseTypeIn' => [ |
|
134 | - 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
135 | - 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
136 | - ], |
|
137 | - ]; |
|
63 | + /** |
|
64 | + * Given an optional array of args, this returns the args to be used in the connection |
|
65 | + * |
|
66 | + * @param array $args The args to modify the defaults |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | + public static function get_connection_args(array $args = []): array |
|
71 | + { |
|
72 | + $newArgs = [ |
|
73 | + 'in' => [ |
|
74 | + 'type' => ['list_of' => 'ID'], |
|
75 | + 'description' => esc_html__('Limit prices to the given globally unique IDs', 'event_espresso'), |
|
76 | + ], |
|
77 | + 'idIn' => [ |
|
78 | + 'type' => ['list_of' => 'ID'], |
|
79 | + 'description' => esc_html__('Limit prices to the given IDs', 'event_espresso'), |
|
80 | + ], |
|
81 | + 'event' => [ |
|
82 | + 'type' => 'ID', |
|
83 | + 'description' => esc_html__('Globally unique event ID to get the prices for.', 'event_espresso'), |
|
84 | + ], |
|
85 | + 'eventId' => [ |
|
86 | + 'type' => 'Int', |
|
87 | + 'description' => esc_html__('Event ID to get the prices for.', 'event_espresso'), |
|
88 | + ], |
|
89 | + 'includeDefaultPrices' => [ |
|
90 | + 'type' => 'Boolean', |
|
91 | + 'description' => esc_html__('Whether to add default prices to the list.', 'event_espresso'), |
|
92 | + ], |
|
93 | + 'includeDefaultTicketsPrices' => [ |
|
94 | + 'type' => 'Boolean', |
|
95 | + 'description' => esc_html__('Whether to add default tickets prices to the list.', 'event_espresso'), |
|
96 | + ], |
|
97 | + 'isDefault' => [ |
|
98 | + 'type' => 'Boolean', |
|
99 | + 'description' => esc_html__('Filter the default prices', 'event_espresso'), |
|
100 | + ], |
|
101 | + 'ticket' => [ |
|
102 | + 'type' => 'ID', |
|
103 | + 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
104 | + ], |
|
105 | + 'ticketIn' => [ |
|
106 | + 'type' => ['list_of' => 'ID'], |
|
107 | + 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
108 | + ], |
|
109 | + 'ticketId' => [ |
|
110 | + 'type' => 'Int', |
|
111 | + 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
112 | + ], |
|
113 | + 'ticketIdIn' => [ |
|
114 | + 'type' => ['list_of' => 'Int'], |
|
115 | + 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
116 | + ], |
|
117 | + 'priceType' => [ |
|
118 | + 'type' => 'ID', |
|
119 | + 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
120 | + ], |
|
121 | + 'priceTypeIn' => [ |
|
122 | + 'type' => ['list_of' => 'ID'], |
|
123 | + 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
124 | + ], |
|
125 | + 'priceTypeId' => [ |
|
126 | + 'type' => 'Int', |
|
127 | + 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
128 | + ], |
|
129 | + 'priceTypeIdIn' => [ |
|
130 | + 'type' => ['list_of' => 'Int'], |
|
131 | + 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
132 | + ], |
|
133 | + 'priceBaseTypeIn' => [ |
|
134 | + 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
135 | + 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
136 | + ], |
|
137 | + ]; |
|
138 | 138 | |
139 | - $newArgs = apply_filters( |
|
140 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__price_args', |
|
141 | - $newArgs, |
|
142 | - $args |
|
143 | - ); |
|
144 | - return array_merge( |
|
145 | - $newArgs, |
|
146 | - $args |
|
147 | - ); |
|
148 | - } |
|
139 | + $newArgs = apply_filters( |
|
140 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__price_args', |
|
141 | + $newArgs, |
|
142 | + $args |
|
143 | + ); |
|
144 | + return array_merge( |
|
145 | + $newArgs, |
|
146 | + $args |
|
147 | + ); |
|
148 | + } |
|
149 | 149 | } |
@@ -37,8 +37,8 @@ |
||
37 | 37 | public function config(): array |
38 | 38 | { |
39 | 39 | return [ |
40 | - 'fromType' => $this->namespace . 'Event', |
|
41 | - 'toType' => $this->namespace . 'Datetime', |
|
40 | + 'fromType' => $this->namespace.'Event', |
|
41 | + 'toType' => $this->namespace.'Datetime', |
|
42 | 42 | 'fromFieldName' => 'datetimes', |
43 | 43 | 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
44 | 44 | 'connectionArgs' => self::get_connection_args(), |
@@ -18,119 +18,119 @@ |
||
18 | 18 | */ |
19 | 19 | class EventDatetimesConnection extends ConnectionBase |
20 | 20 | { |
21 | - /** |
|
22 | - * DatetimeConnection constructor. |
|
23 | - * |
|
24 | - * @param EEM_Datetime $model |
|
25 | - */ |
|
26 | - public function __construct(EEM_Datetime $model) |
|
27 | - { |
|
28 | - parent::__construct($model); |
|
29 | - } |
|
21 | + /** |
|
22 | + * DatetimeConnection constructor. |
|
23 | + * |
|
24 | + * @param EEM_Datetime $model |
|
25 | + */ |
|
26 | + public function __construct(EEM_Datetime $model) |
|
27 | + { |
|
28 | + parent::__construct($model); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function config(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'fromType' => $this->namespace . 'Event', |
|
39 | - 'toType' => $this->namespace . 'Datetime', |
|
40 | - 'fromFieldName' => 'datetimes', |
|
41 | - 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
|
42 | - 'connectionArgs' => self::get_connection_args(), |
|
43 | - 'resolve' => [$this, 'resolveConnection'], |
|
44 | - ]; |
|
45 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function config(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'fromType' => $this->namespace . 'Event', |
|
39 | + 'toType' => $this->namespace . 'Datetime', |
|
40 | + 'fromFieldName' => 'datetimes', |
|
41 | + 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
|
42 | + 'connectionArgs' => self::get_connection_args(), |
|
43 | + 'resolve' => [$this, 'resolveConnection'], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param $entity |
|
50 | - * @param $args |
|
51 | - * @param $context |
|
52 | - * @param $info |
|
53 | - * @return array|Deferred|mixed |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function resolveConnection($entity, $args, $context, $info) |
|
57 | - { |
|
58 | - $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
59 | - return $resolver->get_connection(); |
|
60 | - } |
|
48 | + /** |
|
49 | + * @param $entity |
|
50 | + * @param $args |
|
51 | + * @param $context |
|
52 | + * @param $info |
|
53 | + * @return array|Deferred|mixed |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function resolveConnection($entity, $args, $context, $info) |
|
57 | + { |
|
58 | + $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
59 | + return $resolver->get_connection(); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Given an optional array of args, this returns the args to be used in the connection |
|
64 | - * |
|
65 | - * @param array $args The args to modify the defaults |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
69 | - public static function get_connection_args(array $args = []): array |
|
70 | - { |
|
71 | - $newArgs = [ |
|
72 | - 'orderby' => [ |
|
73 | - 'type' => ['list_of' => 'EspressoDatetimesConnectionOrderbyInput'], |
|
74 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
75 | - ], |
|
76 | - 'event' => [ |
|
77 | - 'type' => 'ID', |
|
78 | - 'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), |
|
79 | - ], |
|
80 | - 'eventIn' => [ |
|
81 | - 'type' => ['list_of' => 'ID'], |
|
82 | - 'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), |
|
83 | - ], |
|
84 | - 'eventId' => [ |
|
85 | - 'type' => 'Int', |
|
86 | - 'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), |
|
87 | - ], |
|
88 | - 'eventIdIn' => [ |
|
89 | - 'type' => ['list_of' => 'Int'], |
|
90 | - 'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), |
|
91 | - ], |
|
92 | - 'ticket' => [ |
|
93 | - 'type' => 'ID', |
|
94 | - 'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), |
|
95 | - ], |
|
96 | - 'ticketIn' => [ |
|
97 | - 'type' => ['list_of' => 'ID'], |
|
98 | - 'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), |
|
99 | - ], |
|
100 | - 'ticketId' => [ |
|
101 | - 'type' => 'Int', |
|
102 | - 'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), |
|
103 | - ], |
|
104 | - 'ticketIdIn' => [ |
|
105 | - 'type' => ['list_of' => 'Int'], |
|
106 | - 'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), |
|
107 | - ], |
|
108 | - 'upcoming' => [ |
|
109 | - 'type' => 'Boolean', |
|
110 | - 'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), |
|
111 | - ], |
|
112 | - 'active' => [ |
|
113 | - 'type' => 'Boolean', |
|
114 | - 'description' => esc_html__('Datetimes which are active.', 'event_espresso'), |
|
115 | - ], |
|
116 | - 'expired' => [ |
|
117 | - 'type' => 'Boolean', |
|
118 | - 'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), |
|
119 | - ], |
|
120 | - 'search' => [ |
|
121 | - 'type' => 'String', |
|
122 | - 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
123 | - ], |
|
124 | - ]; |
|
62 | + /** |
|
63 | + * Given an optional array of args, this returns the args to be used in the connection |
|
64 | + * |
|
65 | + * @param array $args The args to modify the defaults |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
69 | + public static function get_connection_args(array $args = []): array |
|
70 | + { |
|
71 | + $newArgs = [ |
|
72 | + 'orderby' => [ |
|
73 | + 'type' => ['list_of' => 'EspressoDatetimesConnectionOrderbyInput'], |
|
74 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
75 | + ], |
|
76 | + 'event' => [ |
|
77 | + 'type' => 'ID', |
|
78 | + 'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), |
|
79 | + ], |
|
80 | + 'eventIn' => [ |
|
81 | + 'type' => ['list_of' => 'ID'], |
|
82 | + 'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), |
|
83 | + ], |
|
84 | + 'eventId' => [ |
|
85 | + 'type' => 'Int', |
|
86 | + 'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), |
|
87 | + ], |
|
88 | + 'eventIdIn' => [ |
|
89 | + 'type' => ['list_of' => 'Int'], |
|
90 | + 'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), |
|
91 | + ], |
|
92 | + 'ticket' => [ |
|
93 | + 'type' => 'ID', |
|
94 | + 'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), |
|
95 | + ], |
|
96 | + 'ticketIn' => [ |
|
97 | + 'type' => ['list_of' => 'ID'], |
|
98 | + 'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), |
|
99 | + ], |
|
100 | + 'ticketId' => [ |
|
101 | + 'type' => 'Int', |
|
102 | + 'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), |
|
103 | + ], |
|
104 | + 'ticketIdIn' => [ |
|
105 | + 'type' => ['list_of' => 'Int'], |
|
106 | + 'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), |
|
107 | + ], |
|
108 | + 'upcoming' => [ |
|
109 | + 'type' => 'Boolean', |
|
110 | + 'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), |
|
111 | + ], |
|
112 | + 'active' => [ |
|
113 | + 'type' => 'Boolean', |
|
114 | + 'description' => esc_html__('Datetimes which are active.', 'event_espresso'), |
|
115 | + ], |
|
116 | + 'expired' => [ |
|
117 | + 'type' => 'Boolean', |
|
118 | + 'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), |
|
119 | + ], |
|
120 | + 'search' => [ |
|
121 | + 'type' => 'String', |
|
122 | + 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
123 | + ], |
|
124 | + ]; |
|
125 | 125 | |
126 | - $newArgs = apply_filters( |
|
127 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__datetime_args', |
|
128 | - $newArgs, |
|
129 | - $args |
|
130 | - ); |
|
131 | - return array_merge( |
|
132 | - $newArgs, |
|
133 | - $args |
|
134 | - ); |
|
135 | - } |
|
126 | + $newArgs = apply_filters( |
|
127 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__datetime_args', |
|
128 | + $newArgs, |
|
129 | + $args |
|
130 | + ); |
|
131 | + return array_merge( |
|
132 | + $newArgs, |
|
133 | + $args |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | } |