@@ -13,68 +13,68 @@ |
||
13 | 13 | class TicketCreate extends EntityMutator |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Defines the mutation data modification closure. |
|
18 | - * |
|
19 | - * @param EEM_Ticket $model |
|
20 | - * @param Ticket $type |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Creates 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 | - */ |
|
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | - $id = null; |
|
35 | - try { |
|
36 | - EntityMutator::checkPermissions($model); |
|
16 | + /** |
|
17 | + * Defines the mutation data modification closure. |
|
18 | + * |
|
19 | + * @param EEM_Ticket $model |
|
20 | + * @param Ticket $type |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Creates 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 | + */ |
|
33 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | + $id = null; |
|
35 | + try { |
|
36 | + EntityMutator::checkPermissions($model); |
|
37 | 37 | |
38 | - $datetimes = []; |
|
39 | - $prices = []; |
|
38 | + $datetimes = []; |
|
39 | + $prices = []; |
|
40 | 40 | |
41 | - $args = TicketMutation::prepareFields($input); |
|
41 | + $args = TicketMutation::prepareFields($input); |
|
42 | 42 | |
43 | - if (isset($args['datetimes'])) { |
|
44 | - $datetimes = $args['datetimes']; |
|
45 | - unset($args['datetimes']); |
|
46 | - } |
|
47 | - if (isset($args['prices'])) { |
|
48 | - $prices = $args['prices']; |
|
49 | - unset($args['prices']); |
|
50 | - } |
|
43 | + if (isset($args['datetimes'])) { |
|
44 | + $datetimes = $args['datetimes']; |
|
45 | + unset($args['datetimes']); |
|
46 | + } |
|
47 | + if (isset($args['prices'])) { |
|
48 | + $prices = $args['prices']; |
|
49 | + unset($args['prices']); |
|
50 | + } |
|
51 | 51 | |
52 | - $entity = EE_Ticket::new_instance($args); |
|
53 | - $id = $entity->save(); |
|
54 | - EntityMutator::validateResults($id); |
|
52 | + $entity = EE_Ticket::new_instance($args); |
|
53 | + $id = $entity->save(); |
|
54 | + EntityMutator::validateResults($id); |
|
55 | 55 | |
56 | - if (! empty($datetimes)) { |
|
57 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
58 | - } |
|
59 | - // if prices are passed. |
|
60 | - if (! empty($prices)) { |
|
61 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
62 | - } |
|
56 | + if (! empty($datetimes)) { |
|
57 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
58 | + } |
|
59 | + // if prices are passed. |
|
60 | + if (! empty($prices)) { |
|
61 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
62 | + } |
|
63 | 63 | |
64 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input); |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'The ticket could not be created because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
64 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input); |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'The ticket could not be created because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | - return [ |
|
76 | - 'id' => $id, |
|
77 | - ]; |
|
78 | - }; |
|
79 | - } |
|
75 | + return [ |
|
76 | + 'id' => $id, |
|
77 | + ]; |
|
78 | + }; |
|
79 | + } |
|
80 | 80 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
33 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | 34 | $id = null; |
35 | 35 | try { |
36 | 36 | EntityMutator::checkPermissions($model); |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $id = $entity->save(); |
54 | 54 | EntityMutator::validateResults($id); |
55 | 55 | |
56 | - if (! empty($datetimes)) { |
|
56 | + if ( ! empty($datetimes)) { |
|
57 | 57 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
58 | 58 | } |
59 | 59 | // if prices are passed. |
60 | - if (! empty($prices)) { |
|
60 | + if ( ! empty($prices)) { |
|
61 | 61 | TicketMutation::setRelatedPrices($entity, $prices); |
62 | 62 | } |
63 | 63 |
@@ -17,107 +17,107 @@ |
||
17 | 17 | class DatetimeDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Datetime $model |
|
24 | - * @param Datetime $type |
|
25 | - * @return callable |
|
26 | - */ |
|
27 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $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_Datetime $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Datetime $model |
|
24 | + * @param Datetime $type |
|
25 | + * @return callable |
|
26 | + */ |
|
27 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $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_Datetime $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - // Delete the entity |
|
43 | - if (! empty($input['deletePermanently'])) { |
|
44 | - $result = DatetimeDelete::deleteDatetimeAndRelations($entity); |
|
45 | - } else { |
|
46 | - $result = DatetimeDelete::trashDatetimeAndRelations($entity); |
|
47 | - } |
|
48 | - EntityMutator::validateResults($result); |
|
42 | + // Delete the entity |
|
43 | + if (! empty($input['deletePermanently'])) { |
|
44 | + $result = DatetimeDelete::deleteDatetimeAndRelations($entity); |
|
45 | + } else { |
|
46 | + $result = DatetimeDelete::trashDatetimeAndRelations($entity); |
|
47 | + } |
|
48 | + EntityMutator::validateResults($result); |
|
49 | 49 | |
50 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input); |
|
51 | - } catch (Exception $exception) { |
|
52 | - EntityMutator::handleExceptions( |
|
53 | - $exception, |
|
54 | - esc_html__( |
|
55 | - 'The datetime could not be deleted because of the following error(s)', |
|
56 | - 'event_espresso' |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
50 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input); |
|
51 | + } catch (Exception $exception) { |
|
52 | + EntityMutator::handleExceptions( |
|
53 | + $exception, |
|
54 | + esc_html__( |
|
55 | + 'The datetime could not be deleted because of the following error(s)', |
|
56 | + 'event_espresso' |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - return [ |
|
62 | - 'deleted' => $entity, |
|
63 | - ]; |
|
64 | - }; |
|
65 | - } |
|
61 | + return [ |
|
62 | + 'deleted' => $entity, |
|
63 | + ]; |
|
64 | + }; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Deletes a datetime permanently along with its relations. |
|
69 | - * |
|
70 | - * @param EE_Datetime $entity |
|
71 | - * @return bool | int |
|
72 | - * @throws ReflectionException |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws EE_Error |
|
77 | - */ |
|
78 | - public static function deleteDatetimeAndRelations(EE_Datetime $entity) |
|
79 | - { |
|
80 | - // all related tickets |
|
81 | - $tickets = $entity->tickets(); |
|
82 | - foreach ($tickets as $ticket) { |
|
83 | - // if the ticket is related to only one datetime |
|
84 | - if ($ticket->count_related('Datetime') === 1) { |
|
85 | - TicketDelete::deleteTicketAndRelations($ticket); |
|
86 | - } |
|
87 | - } |
|
67 | + /** |
|
68 | + * Deletes a datetime permanently along with its relations. |
|
69 | + * |
|
70 | + * @param EE_Datetime $entity |
|
71 | + * @return bool | int |
|
72 | + * @throws ReflectionException |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws EE_Error |
|
77 | + */ |
|
78 | + public static function deleteDatetimeAndRelations(EE_Datetime $entity) |
|
79 | + { |
|
80 | + // all related tickets |
|
81 | + $tickets = $entity->tickets(); |
|
82 | + foreach ($tickets as $ticket) { |
|
83 | + // if the ticket is related to only one datetime |
|
84 | + if ($ticket->count_related('Datetime') === 1) { |
|
85 | + TicketDelete::deleteTicketAndRelations($ticket); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - // Remove relations with tickets |
|
90 | - $entity->_remove_relations('Ticket'); |
|
91 | - // Now delete the datetime permanently |
|
92 | - return $entity->delete_permanently(); |
|
93 | - } |
|
89 | + // Remove relations with tickets |
|
90 | + $entity->_remove_relations('Ticket'); |
|
91 | + // Now delete the datetime permanently |
|
92 | + return $entity->delete_permanently(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Trashes a datetime along with its lone relations. |
|
97 | - * |
|
98 | - * @param EE_Datetime $entity |
|
99 | - * @return bool | int |
|
100 | - * @throws ReflectionException |
|
101 | - * @throws InvalidArgumentException |
|
102 | - * @throws InvalidInterfaceException |
|
103 | - * @throws InvalidDataTypeException |
|
104 | - * @throws EE_Error |
|
105 | - */ |
|
106 | - public static function trashDatetimeAndRelations(EE_Datetime $entity) |
|
107 | - { |
|
108 | - // non trashed related tickets |
|
109 | - $tickets = $entity->tickets([[ |
|
110 | - 'TKT_deleted' => false, |
|
111 | - ]]); |
|
112 | - // loop though all tickets to check if we need to trash any |
|
113 | - foreach ($tickets as $ticket) { |
|
114 | - // if the ticket is related to only one datetime |
|
115 | - if ($ticket->count_related('Datetime') === 1) { |
|
116 | - // trash the ticket |
|
117 | - $ticket->delete(); |
|
118 | - } |
|
119 | - } |
|
120 | - // trash the datetime |
|
121 | - return $entity->delete(); |
|
122 | - } |
|
95 | + /** |
|
96 | + * Trashes a datetime along with its lone relations. |
|
97 | + * |
|
98 | + * @param EE_Datetime $entity |
|
99 | + * @return bool | int |
|
100 | + * @throws ReflectionException |
|
101 | + * @throws InvalidArgumentException |
|
102 | + * @throws InvalidInterfaceException |
|
103 | + * @throws InvalidDataTypeException |
|
104 | + * @throws EE_Error |
|
105 | + */ |
|
106 | + public static function trashDatetimeAndRelations(EE_Datetime $entity) |
|
107 | + { |
|
108 | + // non trashed related tickets |
|
109 | + $tickets = $entity->tickets([[ |
|
110 | + 'TKT_deleted' => false, |
|
111 | + ]]); |
|
112 | + // loop though all tickets to check if we need to trash any |
|
113 | + foreach ($tickets as $ticket) { |
|
114 | + // if the ticket is related to only one datetime |
|
115 | + if ($ticket->count_related('Datetime') === 1) { |
|
116 | + // trash the ticket |
|
117 | + $ticket->delete(); |
|
118 | + } |
|
119 | + } |
|
120 | + // trash the datetime |
|
121 | + return $entity->delete(); |
|
122 | + } |
|
123 | 123 | } |
@@ -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_Datetime $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 = DatetimeDelete::deleteDatetimeAndRelations($entity); |
45 | 45 | } else { |
46 | 46 | $result = DatetimeDelete::trashDatetimeAndRelations($entity); |
@@ -17,70 +17,70 @@ |
||
17 | 17 | class PriceDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Price $model |
|
24 | - * @param Price $type |
|
25 | - * @return callable |
|
26 | - */ |
|
27 | - public static function mutateAndGetPayload(EEM_Price $model, Price $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_Price $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Price $model |
|
24 | + * @param Price $type |
|
25 | + * @return callable |
|
26 | + */ |
|
27 | + public static function mutateAndGetPayload(EEM_Price $model, Price $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_Price $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - // Delete the entity |
|
43 | - if (! empty($input['deletePermanently'])) { |
|
44 | - $result = PriceDelete::deletePriceAndRelations($entity); |
|
45 | - } else { |
|
46 | - // trash the price |
|
47 | - $result = $entity->delete(); |
|
48 | - } |
|
49 | - EntityMutator::validateResults($result); |
|
42 | + // Delete the entity |
|
43 | + if (! empty($input['deletePermanently'])) { |
|
44 | + $result = PriceDelete::deletePriceAndRelations($entity); |
|
45 | + } else { |
|
46 | + // trash the price |
|
47 | + $result = $entity->delete(); |
|
48 | + } |
|
49 | + EntityMutator::validateResults($result); |
|
50 | 50 | |
51 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_delete', $entity, $input); |
|
52 | - } catch (Exception $exception) { |
|
53 | - EntityMutator::handleExceptions( |
|
54 | - $exception, |
|
55 | - esc_html__( |
|
56 | - 'The price 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_price_delete', $entity, $input); |
|
52 | + } catch (Exception $exception) { |
|
53 | + EntityMutator::handleExceptions( |
|
54 | + $exception, |
|
55 | + esc_html__( |
|
56 | + 'The price 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 price permanently along with its relations. |
|
70 | - * |
|
71 | - * @param EE_Price $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 deletePriceAndRelations(EE_Price $entity) |
|
80 | - { |
|
81 | - // Remove relation with ticket |
|
82 | - $entity->_remove_relations('Ticket'); |
|
83 | - // Now delete the price permanently |
|
84 | - return $entity->delete_permanently(); |
|
85 | - } |
|
68 | + /** |
|
69 | + * Deletes a price permanently along with its relations. |
|
70 | + * |
|
71 | + * @param EE_Price $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 deletePriceAndRelations(EE_Price $entity) |
|
80 | + { |
|
81 | + // Remove relation with ticket |
|
82 | + $entity->_remove_relations('Ticket'); |
|
83 | + // Now delete the price permanently |
|
84 | + return $entity->delete_permanently(); |
|
85 | + } |
|
86 | 86 | } |
@@ -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_Price $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 = PriceDelete::deletePriceAndRelations($entity); |
45 | 45 | } else { |
46 | 46 | // trash the price |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - return static function ( |
|
37 | + return static function( |
|
38 | 38 | int $id, |
39 | 39 | array $input, |
40 | 40 | WP_Post_Type $post_type_object, |
@@ -14,63 +14,63 @@ |
||
14 | 14 | class VenueUpdate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Venue $model |
|
21 | - * @param Venue $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateFields(EEM_Venue $model, Venue $type) |
|
25 | - { |
|
26 | - /** |
|
27 | - * Update additional data related to the entity. |
|
28 | - * |
|
29 | - * @param int $id The ID of the postObject being mutated |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | - * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - return static function ( |
|
38 | - int $id, |
|
39 | - array $input, |
|
40 | - WP_Post_Type $post_type_object, |
|
41 | - string $mutation_name, |
|
42 | - AppContext $context, |
|
43 | - ResolveInfo $info |
|
44 | - ) use ( |
|
45 | - $model, |
|
46 | - $type |
|
47 | - ) { |
|
48 | - try { |
|
49 | - // Make sure we are dealing with the right entity. |
|
50 | - if ( |
|
51 | - ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | - || $post_type_object->graphql_single_name !== $type->name() |
|
53 | - ) { |
|
54 | - return; |
|
55 | - } |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Venue $model |
|
21 | + * @param Venue $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateFields(EEM_Venue $model, Venue $type) |
|
25 | + { |
|
26 | + /** |
|
27 | + * Update additional data related to the entity. |
|
28 | + * |
|
29 | + * @param int $id The ID of the postObject being mutated |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | + * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + return static function ( |
|
38 | + int $id, |
|
39 | + array $input, |
|
40 | + WP_Post_Type $post_type_object, |
|
41 | + string $mutation_name, |
|
42 | + AppContext $context, |
|
43 | + ResolveInfo $info |
|
44 | + ) use ( |
|
45 | + $model, |
|
46 | + $type |
|
47 | + ) { |
|
48 | + try { |
|
49 | + // Make sure we are dealing with the right entity. |
|
50 | + if ( |
|
51 | + ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | + || $post_type_object->graphql_single_name !== $type->name() |
|
53 | + ) { |
|
54 | + return; |
|
55 | + } |
|
56 | 56 | |
57 | - /** @var EE_Venue $entity */ |
|
58 | - $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | - $args = VenueMutation::prepareFields($input); |
|
57 | + /** @var EE_Venue $entity */ |
|
58 | + $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | + $args = VenueMutation::prepareFields($input); |
|
60 | 60 | |
61 | - // Update the entity |
|
62 | - $entity->save($args); |
|
61 | + // Update the entity |
|
62 | + $entity->save($args); |
|
63 | 63 | |
64 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input); |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'The venue could not be updated because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - }; |
|
75 | - } |
|
64 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input); |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'The venue could not be updated because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | + }; |
|
75 | + } |
|
76 | 76 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @throws EE_Error |
35 | 35 | * @throws ReflectionException |
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_Price $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -14,49 +14,49 @@ |
||
14 | 14 | |
15 | 15 | class PriceUpdate extends EntityMutator |
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 | - * Updates 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 | - * @throws EE_Error |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | - try { |
|
38 | - /** @var EE_Price $entity */ |
|
39 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
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 | + * Updates 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 | + * @throws EE_Error |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | + try { |
|
38 | + /** @var EE_Price $entity */ |
|
39 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
40 | 40 | |
41 | - $args = PriceMutation::prepareFields($input); |
|
41 | + $args = PriceMutation::prepareFields($input); |
|
42 | 42 | |
43 | - // Update the entity |
|
44 | - $entity->save($args); |
|
43 | + // Update the entity |
|
44 | + $entity->save($args); |
|
45 | 45 | |
46 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_update', $entity, $input); |
|
47 | - } catch (Exception $exception) { |
|
48 | - EntityMutator::handleExceptions( |
|
49 | - $exception, |
|
50 | - esc_html__( |
|
51 | - 'The price could not be updated because of the following error(s)', |
|
52 | - 'event_espresso' |
|
53 | - ) |
|
54 | - ); |
|
55 | - } |
|
46 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_update', $entity, $input); |
|
47 | + } catch (Exception $exception) { |
|
48 | + EntityMutator::handleExceptions( |
|
49 | + $exception, |
|
50 | + esc_html__( |
|
51 | + 'The price could not be updated because of the following error(s)', |
|
52 | + 'event_espresso' |
|
53 | + ) |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | - return [ |
|
58 | - 'id' => $entity->ID(), |
|
59 | - ]; |
|
60 | - }; |
|
61 | - } |
|
57 | + return [ |
|
58 | + 'id' => $entity->ID(), |
|
59 | + ]; |
|
60 | + }; |
|
61 | + } |
|
62 | 62 | } |
@@ -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 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
33 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | 34 | $id = null; |
35 | 35 | try { |
36 | 36 | EntityMutator::checkPermissions($model); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $id = $entity->save(); |
48 | 48 | EntityMutator::validateResults($id); |
49 | 49 | |
50 | - if (! empty($tickets)) { |
|
50 | + if ( ! empty($tickets)) { |
|
51 | 51 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
52 | 52 | } |
53 | 53 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | - return $id ? [ 'id' => $id ] : []; |
|
65 | + return $id ? ['id' => $id] : []; |
|
66 | 66 | }; |
67 | 67 | } |
68 | 68 | } |
@@ -13,67 +13,67 @@ |
||
13 | 13 | class DatetimeCreate extends EntityMutator |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Defines the mutation data modification closure. |
|
18 | - * |
|
19 | - * @param EEM_Datetime $model |
|
20 | - * @param Datetime $type |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Creates 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 | - */ |
|
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | - $id = null; |
|
35 | - try { |
|
36 | - EntityMutator::checkPermissions($model); |
|
16 | + /** |
|
17 | + * Defines the mutation data modification closure. |
|
18 | + * |
|
19 | + * @param EEM_Datetime $model |
|
20 | + * @param Datetime $type |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Creates 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 | + */ |
|
33 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | + $id = null; |
|
35 | + try { |
|
36 | + EntityMutator::checkPermissions($model); |
|
37 | 37 | |
38 | - $tickets = []; |
|
39 | - $args = DatetimeMutation::prepareFields($input); |
|
38 | + $tickets = []; |
|
39 | + $args = DatetimeMutation::prepareFields($input); |
|
40 | 40 | |
41 | - if (isset($args['tickets'])) { |
|
42 | - $tickets = $args['tickets']; |
|
43 | - unset($args['tickets']); |
|
44 | - } |
|
41 | + if (isset($args['tickets'])) { |
|
42 | + $tickets = $args['tickets']; |
|
43 | + unset($args['tickets']); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - $venue = 'NO_VENUE_SET'; |
|
48 | - if (array_key_exists('venue', $args)) { |
|
49 | - $venue = $args['venue']; |
|
50 | - unset($args['venue']); |
|
51 | - } |
|
47 | + $venue = 'NO_VENUE_SET'; |
|
48 | + if (array_key_exists('venue', $args)) { |
|
49 | + $venue = $args['venue']; |
|
50 | + unset($args['venue']); |
|
51 | + } |
|
52 | 52 | |
53 | - $entity = EE_Datetime::new_instance($args); |
|
54 | - $id = $entity->save(); |
|
55 | - EntityMutator::validateResults($id); |
|
53 | + $entity = EE_Datetime::new_instance($args); |
|
54 | + $id = $entity->save(); |
|
55 | + EntityMutator::validateResults($id); |
|
56 | 56 | |
57 | - if (! empty($tickets)) { |
|
58 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
59 | - } |
|
57 | + if (! empty($tickets)) { |
|
58 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
59 | + } |
|
60 | 60 | |
61 | - if ($venue !== 'NO_VENUE_SET') { |
|
62 | - DatetimeMutation::setVenue($entity, $venue); |
|
63 | - } |
|
61 | + if ($venue !== 'NO_VENUE_SET') { |
|
62 | + DatetimeMutation::setVenue($entity, $venue); |
|
63 | + } |
|
64 | 64 | |
65 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input); |
|
66 | - } catch (Exception $exception) { |
|
67 | - EntityMutator::handleExceptions( |
|
68 | - $exception, |
|
69 | - esc_html__( |
|
70 | - 'The datetime could not be created because of the following error(s)', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
65 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input); |
|
66 | + } catch (Exception $exception) { |
|
67 | + EntityMutator::handleExceptions( |
|
68 | + $exception, |
|
69 | + esc_html__( |
|
70 | + 'The datetime could not be created because of the following error(s)', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - return $id ? [ 'id' => $id ] : []; |
|
77 | - }; |
|
78 | - } |
|
76 | + return $id ? [ 'id' => $id ] : []; |
|
77 | + }; |
|
78 | + } |
|
79 | 79 | } |