@@ -17,31 +17,31 @@ |
||
17 | 17 | class AttendeesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * AttendeesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * AttendeesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class TicketsConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * TicketsConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * TicketsConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class DatetimesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * DatetimesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * DatetimesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -15,68 +15,68 @@ |
||
15 | 15 | class TicketUpdate extends EntityMutator |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Defines the mutation data modification closure. |
|
20 | - * |
|
21 | - * @param EEM_Ticket $model |
|
22 | - * @param Ticket $type |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
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); |
|
18 | + /** |
|
19 | + * Defines the mutation data modification closure. |
|
20 | + * |
|
21 | + * @param EEM_Ticket $model |
|
22 | + * @param Ticket $type |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
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 | - $datetimes = []; |
|
43 | - $prices = null; |
|
42 | + $datetimes = []; |
|
43 | + $prices = null; |
|
44 | 44 | |
45 | - $args = TicketMutation::prepareFields($input); |
|
45 | + $args = TicketMutation::prepareFields($input); |
|
46 | 46 | |
47 | - if (isset($args['datetimes'])) { |
|
48 | - $datetimes = $args['datetimes']; |
|
49 | - unset($args['datetimes']); |
|
50 | - } |
|
51 | - if (array_key_exists('prices', $args)) { |
|
52 | - $prices = $args['prices']; |
|
53 | - unset($args['prices']); |
|
54 | - } |
|
47 | + if (isset($args['datetimes'])) { |
|
48 | + $datetimes = $args['datetimes']; |
|
49 | + unset($args['datetimes']); |
|
50 | + } |
|
51 | + if (array_key_exists('prices', $args)) { |
|
52 | + $prices = $args['prices']; |
|
53 | + unset($args['prices']); |
|
54 | + } |
|
55 | 55 | |
56 | - $entity->save($args); |
|
56 | + $entity->save($args); |
|
57 | 57 | |
58 | - if (! empty($datetimes)) { |
|
59 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
60 | - } |
|
61 | - // if prices array is passed. |
|
62 | - if (is_array($prices)) { |
|
63 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
64 | - } |
|
58 | + if (! empty($datetimes)) { |
|
59 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
60 | + } |
|
61 | + // if prices array is passed. |
|
62 | + if (is_array($prices)) { |
|
63 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
64 | + } |
|
65 | 65 | |
66 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input); |
|
67 | - } catch (Exception $exception) { |
|
68 | - EntityMutator::handleExceptions( |
|
69 | - $exception, |
|
70 | - esc_html__( |
|
71 | - 'The ticket could not be deleted because of the following error(s)', |
|
72 | - 'event_espresso' |
|
73 | - ) |
|
74 | - ); |
|
75 | - } |
|
66 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input); |
|
67 | + } catch (Exception $exception) { |
|
68 | + EntityMutator::handleExceptions( |
|
69 | + $exception, |
|
70 | + esc_html__( |
|
71 | + 'The ticket could not be deleted because of the following error(s)', |
|
72 | + 'event_espresso' |
|
73 | + ) |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - return [ |
|
78 | - 'id' => $entity->ID(), |
|
79 | - ]; |
|
80 | - }; |
|
81 | - } |
|
77 | + return [ |
|
78 | + 'id' => $entity->ID(), |
|
79 | + ]; |
|
80 | + }; |
|
81 | + } |
|
82 | 82 | } |
@@ -34,7 +34,7 @@ discard block |
||
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_Ticket $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $entity->save($args); |
57 | 57 | |
58 | - if (! empty($datetimes)) { |
|
58 | + if ( ! empty($datetimes)) { |
|
59 | 59 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
60 | 60 | } |
61 | 61 | // if prices array is passed. |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class DatetimeBulkUpdate extends EntityMutator |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Defines the mutation data modification closure. |
|
13 | - * |
|
14 | - * @param EEM_Datetime $model |
|
15 | - * @param Datetime $type |
|
16 | - * @return callable |
|
17 | - */ |
|
18 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable |
|
19 | - { |
|
20 | - $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | - return array($bulkMutator, 'updateEntities'); |
|
23 | - } |
|
11 | + /** |
|
12 | + * Defines the mutation data modification closure. |
|
13 | + * |
|
14 | + * @param EEM_Datetime $model |
|
15 | + * @param Datetime $type |
|
16 | + * @return callable |
|
17 | + */ |
|
18 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable |
|
19 | + { |
|
20 | + $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | + return array($bulkMutator, 'updateEntities'); |
|
23 | + } |
|
24 | 24 | } |
@@ -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,73 +14,73 @@ |
||
14 | 14 | class EventUpdate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Event $model |
|
21 | - * @param Event $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateFields(EEM_Event $model, Event $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_Event $model |
|
21 | + * @param Event $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateFields(EEM_Event $model, Event $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_Event $entity */ |
|
58 | - $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | - $args = EventMutation::prepareFields($input); |
|
57 | + /** @var EE_Event $entity */ |
|
58 | + $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | + $args = EventMutation::prepareFields($input); |
|
60 | 60 | |
61 | - $venue = 'NO_VENUE_SET'; |
|
62 | - if (array_key_exists('venue', $args)) { |
|
63 | - $venue = $args['venue']; |
|
64 | - unset($args['venue']); |
|
65 | - } |
|
61 | + $venue = 'NO_VENUE_SET'; |
|
62 | + if (array_key_exists('venue', $args)) { |
|
63 | + $venue = $args['venue']; |
|
64 | + unset($args['venue']); |
|
65 | + } |
|
66 | 66 | |
67 | - // Update the entity |
|
68 | - $entity->save($args); |
|
67 | + // Update the entity |
|
68 | + $entity->save($args); |
|
69 | 69 | |
70 | - if ($venue !== 'NO_VENUE_SET') { |
|
71 | - EventMutation::setEventVenue($entity, $venue); |
|
72 | - } |
|
70 | + if ($venue !== 'NO_VENUE_SET') { |
|
71 | + EventMutation::setEventVenue($entity, $venue); |
|
72 | + } |
|
73 | 73 | |
74 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | - } catch (Exception $exception) { |
|
76 | - EntityMutator::handleExceptions( |
|
77 | - $exception, |
|
78 | - esc_html__( |
|
79 | - 'The event could not be updated because of the following error(s)', |
|
80 | - 'event_espresso' |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - }; |
|
85 | - } |
|
74 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | + } catch (Exception $exception) { |
|
76 | + EntityMutator::handleExceptions( |
|
77 | + $exception, |
|
78 | + esc_html__( |
|
79 | + 'The event could not be updated because of the following error(s)', |
|
80 | + 'event_espresso' |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + }; |
|
85 | + } |
|
86 | 86 | } |
@@ -34,7 +34,7 @@ discard block |
||
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_Datetime $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // Update the entity |
51 | 51 | $entity->save($args); |
52 | 52 | |
53 | - if (! empty($tickets)) { |
|
53 | + if ( ! empty($tickets)) { |
|
54 | 54 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
55 | 55 | } |
56 | 56 |
@@ -15,69 +15,69 @@ |
||
15 | 15 | class DatetimeUpdate extends EntityMutator |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Defines the mutation data modification closure. |
|
20 | - * |
|
21 | - * @param EEM_Datetime $model |
|
22 | - * @param Datetime $type |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
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); |
|
18 | + /** |
|
19 | + * Defines the mutation data modification closure. |
|
20 | + * |
|
21 | + * @param EEM_Datetime $model |
|
22 | + * @param Datetime $type |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
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 | - $tickets = []; |
|
43 | - $args = DatetimeMutation::prepareFields($input); |
|
42 | + $tickets = []; |
|
43 | + $args = DatetimeMutation::prepareFields($input); |
|
44 | 44 | |
45 | - if (isset($args['tickets'])) { |
|
46 | - $tickets = $args['tickets']; |
|
47 | - unset($args['tickets']); |
|
48 | - } |
|
45 | + if (isset($args['tickets'])) { |
|
46 | + $tickets = $args['tickets']; |
|
47 | + unset($args['tickets']); |
|
48 | + } |
|
49 | 49 | |
50 | - $venue = 'NO_VENUE_SET'; |
|
51 | - if (array_key_exists('venue', $args)) { |
|
52 | - $venue = $args['venue']; |
|
53 | - unset($args['venue']); |
|
54 | - } |
|
50 | + $venue = 'NO_VENUE_SET'; |
|
51 | + if (array_key_exists('venue', $args)) { |
|
52 | + $venue = $args['venue']; |
|
53 | + unset($args['venue']); |
|
54 | + } |
|
55 | 55 | |
56 | - // Update the entity |
|
57 | - $entity->save($args); |
|
56 | + // Update the entity |
|
57 | + $entity->save($args); |
|
58 | 58 | |
59 | - if (! empty($tickets)) { |
|
60 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | - } |
|
59 | + if (! empty($tickets)) { |
|
60 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | + } |
|
62 | 62 | |
63 | - if ($venue !== 'NO_VENUE_SET') { |
|
64 | - DatetimeMutation::setVenue($entity, $venue); |
|
65 | - } |
|
63 | + if ($venue !== 'NO_VENUE_SET') { |
|
64 | + DatetimeMutation::setVenue($entity, $venue); |
|
65 | + } |
|
66 | 66 | |
67 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | - } catch (Exception $exception) { |
|
69 | - EntityMutator::handleExceptions( |
|
70 | - $exception, |
|
71 | - esc_html__( |
|
72 | - 'The datetime could not be updated because of the following error(s)', |
|
73 | - 'event_espresso' |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
67 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | + } catch (Exception $exception) { |
|
69 | + EntityMutator::handleExceptions( |
|
70 | + $exception, |
|
71 | + esc_html__( |
|
72 | + 'The datetime could not be updated because of the following error(s)', |
|
73 | + 'event_espresso' |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $entity->ID(), |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $entity->ID(), |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -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,76 +17,76 @@ |
||
17 | 17 | |
18 | 18 | class BulkEntityDelete extends EntityMutator |
19 | 19 | { |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload() |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws UserError |
|
35 | - * @throws ReflectionException |
|
36 | - * @throws InvalidArgumentException |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | - /** |
|
43 | - * Stop now if a user isn't allowed to delete. |
|
44 | - */ |
|
45 | - if (! current_user_can('ee_delete_events')) { |
|
46 | - throw new UserError( |
|
47 | - esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
|
48 | - ); |
|
49 | - } |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload() |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws UserError |
|
35 | + * @throws ReflectionException |
|
36 | + * @throws InvalidArgumentException |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | + /** |
|
43 | + * Stop now if a user isn't allowed to delete. |
|
44 | + */ |
|
45 | + if (! current_user_can('ee_delete_events')) { |
|
46 | + throw new UserError( |
|
47 | + esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | |
51 | - $details = EntityReorder::prepareEntityDetailsFromInput($input); |
|
51 | + $details = EntityReorder::prepareEntityDetailsFromInput($input); |
|
52 | 52 | |
53 | - $deletePermanently = ! empty($input['deletePermanently']); |
|
53 | + $deletePermanently = ! empty($input['deletePermanently']); |
|
54 | 54 | |
55 | - $deletionMethod = __NAMESPACE__; |
|
56 | - // if it's for datetimes. |
|
57 | - if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
|
58 | - $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | - } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
|
60 | - $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | - } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
|
62 | - $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
|
63 | - } else { |
|
64 | - throw new UserError( |
|
65 | - esc_html__( |
|
66 | - 'A valid data model could not be obtained. Did you supply a valid entity type?', |
|
67 | - 'event_espresso' |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
55 | + $deletionMethod = __NAMESPACE__; |
|
56 | + // if it's for datetimes. |
|
57 | + if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
|
58 | + $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | + } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
|
60 | + $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | + } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
|
62 | + $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
|
63 | + } else { |
|
64 | + throw new UserError( |
|
65 | + esc_html__( |
|
66 | + 'A valid data model could not be obtained. Did you supply a valid entity type?', |
|
67 | + 'event_espresso' |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - $deleted = []; |
|
73 | - $failed = []; |
|
72 | + $deleted = []; |
|
73 | + $failed = []; |
|
74 | 74 | |
75 | - foreach ($details['entityDbids'] as $key => $entityDbid) { |
|
76 | - $guid = $details['entityGuids'][ $key ]; |
|
77 | - $entity = $details['entities'][ $entityDbid ]; |
|
78 | - try { |
|
79 | - $result = $deletionMethod($entity); |
|
80 | - EntityMutator::validateResults($result); |
|
81 | - // we are here it means the deletion was successful. |
|
82 | - $deleted[] = $guid; |
|
83 | - } catch (Exception $e) { |
|
84 | - // sorry mate, couldn't help you :( |
|
85 | - $failed[] = $guid; |
|
86 | - } |
|
87 | - } |
|
75 | + foreach ($details['entityDbids'] as $key => $entityDbid) { |
|
76 | + $guid = $details['entityGuids'][ $key ]; |
|
77 | + $entity = $details['entities'][ $entityDbid ]; |
|
78 | + try { |
|
79 | + $result = $deletionMethod($entity); |
|
80 | + EntityMutator::validateResults($result); |
|
81 | + // we are here it means the deletion was successful. |
|
82 | + $deleted[] = $guid; |
|
83 | + } catch (Exception $e) { |
|
84 | + // sorry mate, couldn't help you :( |
|
85 | + $failed[] = $guid; |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - return compact('deleted', 'failed'); |
|
90 | - }; |
|
91 | - } |
|
89 | + return compact('deleted', 'failed'); |
|
90 | + }; |
|
91 | + } |
|
92 | 92 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | * @throws InvalidDataTypeException |
39 | 39 | * @throws EE_Error |
40 | 40 | */ |
41 | - return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
41 | + return static function(array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | 42 | /** |
43 | 43 | * Stop now if a user isn't allowed to delete. |
44 | 44 | */ |
45 | - if (! current_user_can('ee_delete_events')) { |
|
45 | + if ( ! current_user_can('ee_delete_events')) { |
|
46 | 46 | throw new UserError( |
47 | 47 | esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
48 | 48 | ); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | $deletionMethod = __NAMESPACE__; |
56 | 56 | // if it's for datetimes. |
57 | 57 | if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
58 | - $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
58 | + $deletionMethod .= '\DatetimeDelete::'.($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | 59 | } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
60 | - $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
60 | + $deletionMethod .= '\TicketDelete::'.($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | 61 | } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
62 | 62 | $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
63 | 63 | } else { |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $failed = []; |
74 | 74 | |
75 | 75 | foreach ($details['entityDbids'] as $key => $entityDbid) { |
76 | - $guid = $details['entityGuids'][ $key ]; |
|
77 | - $entity = $details['entities'][ $entityDbid ]; |
|
76 | + $guid = $details['entityGuids'][$key]; |
|
77 | + $entity = $details['entities'][$entityDbid]; |
|
78 | 78 | try { |
79 | 79 | $result = $deletionMethod($entity); |
80 | 80 | EntityMutator::validateResults($result); |