@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @param EEM_Price $model |
27 | 27 | * @param Price $type |
28 | - * @return callable |
|
28 | + * @return \Closure |
|
29 | 29 | */ |
30 | 30 | public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
31 | 31 | { |
@@ -6,13 +6,11 @@ |
||
6 | 6 | use EE_Price; |
7 | 7 | use EventEspresso\core\domain\services\graphql\types\Price; |
8 | 8 | use EventEspresso\core\domain\services\graphql\data\mutations\PriceMutation; |
9 | - |
|
10 | 9 | use EE_Error; |
11 | 10 | use InvalidArgumentException; |
12 | 11 | use ReflectionException; |
13 | 12 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
14 | 13 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
15 | - |
|
16 | 14 | use GraphQL\Type\Definition\ResolveInfo; |
17 | 15 | use WPGraphQL\AppContext; |
18 | 16 | use GraphQL\Error\UserError; |
@@ -20,60 +20,60 @@ |
||
20 | 20 | class PriceCreate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Price $model |
|
27 | - * @param Price $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Creates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Price $model |
|
27 | + * @param Price $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Creates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create an entity. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create an entity. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - $args = PriceMutation::prepareFields($input); |
|
58 | + $args = PriceMutation::prepareFields($input); |
|
59 | 59 | |
60 | - if (empty($args['PRT_ID'])) { |
|
61 | - // translators: the placeholder is the name of the field. |
|
62 | - throw new UserError( |
|
63 | - sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
64 | - ); |
|
65 | - } |
|
60 | + if (empty($args['PRT_ID'])) { |
|
61 | + // translators: the placeholder is the name of the field. |
|
62 | + throw new UserError( |
|
63 | + sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | - $entity = EE_Price::new_instance($args); |
|
68 | - $id = $entity->save(); |
|
67 | + $entity = EE_Price::new_instance($args); |
|
68 | + $id = $entity->save(); |
|
69 | 69 | |
70 | - if (empty($id)) { |
|
71 | - throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | - } |
|
70 | + if (empty($id)) { |
|
71 | + throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | + } |
|
73 | 73 | |
74 | - return [ |
|
75 | - 'id' => $id, |
|
76 | - ]; |
|
77 | - }; |
|
78 | - } |
|
74 | + return [ |
|
75 | + 'id' => $id, |
|
76 | + ]; |
|
77 | + }; |
|
78 | + } |
|
79 | 79 | } |
@@ -43,12 +43,12 @@ |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create an entity. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
@@ -5,13 +5,11 @@ |
||
5 | 5 | use EEM_Price; |
6 | 6 | use EE_Price; |
7 | 7 | use EventEspresso\core\domain\services\graphql\types\Price; |
8 | - |
|
9 | 8 | use EE_Error; |
10 | 9 | use InvalidArgumentException; |
11 | 10 | use ReflectionException; |
12 | 11 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
13 | 12 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
14 | - |
|
15 | 13 | use GraphQL\Type\Definition\ResolveInfo; |
16 | 14 | use WPGraphQL\AppContext; |
17 | 15 | use GraphQL\Error\UserError; |
@@ -20,74 +20,74 @@ |
||
20 | 20 | class PriceDelete |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Price $model |
|
27 | - * @param Price $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Deletes an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | - /** |
|
48 | - * Stop now if a user isn't allowed to create an entity. |
|
49 | - */ |
|
50 | - if (! current_user_can('ee_edit_events')) { |
|
51 | - // translators: the %1$s is the name of the object being mutated |
|
52 | - throw new UserError( |
|
53 | - sprintf( |
|
54 | - esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), |
|
55 | - $type->name() |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
59 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Price $model |
|
27 | + * @param Price $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Deletes an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + /** |
|
48 | + * Stop now if a user isn't allowed to create an entity. |
|
49 | + */ |
|
50 | + if (! current_user_can('ee_edit_events')) { |
|
51 | + // translators: the %1$s is the name of the object being mutated |
|
52 | + throw new UserError( |
|
53 | + sprintf( |
|
54 | + esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), |
|
55 | + $type->name() |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
60 | 60 | |
61 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
62 | - $entity = null; |
|
61 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
62 | + $entity = null; |
|
63 | 63 | |
64 | - if ($id) { |
|
65 | - $entity = $model->get_one_by_ID($id); |
|
66 | - } |
|
64 | + if ($id) { |
|
65 | + $entity = $model->get_one_by_ID($id); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * If there's no existing entity, throw an exception |
|
70 | - */ |
|
71 | - if (! $id || ! ($entity instanceof EE_Price)) { |
|
72 | - // translators: the placeholder is the name of the type being updated |
|
73 | - throw new UserError( |
|
74 | - sprintf( |
|
75 | - esc_html__('No %1$s could be found to delete', 'event_espresso'), |
|
76 | - $type->name() |
|
77 | - ) |
|
78 | - ); |
|
79 | - } |
|
68 | + /** |
|
69 | + * If there's no existing entity, throw an exception |
|
70 | + */ |
|
71 | + if (! $id || ! ($entity instanceof EE_Price)) { |
|
72 | + // translators: the placeholder is the name of the type being updated |
|
73 | + throw new UserError( |
|
74 | + sprintf( |
|
75 | + esc_html__('No %1$s could be found to delete', 'event_espresso'), |
|
76 | + $type->name() |
|
77 | + ) |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | - // Delete the entity |
|
82 | - $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
81 | + // Delete the entity |
|
82 | + $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
83 | 83 | |
84 | - if (empty($result)) { |
|
85 | - throw new UserError(esc_html__('The object failed to delete but no error was provided', 'event_espresso')); |
|
86 | - } |
|
84 | + if (empty($result)) { |
|
85 | + throw new UserError(esc_html__('The object failed to delete but no error was provided', 'event_espresso')); |
|
86 | + } |
|
87 | 87 | |
88 | - return [ |
|
89 | - 'deleted' => $entity, |
|
90 | - ]; |
|
91 | - }; |
|
92 | - } |
|
88 | + return [ |
|
89 | + 'deleted' => $entity, |
|
90 | + ]; |
|
91 | + }; |
|
92 | + } |
|
93 | 93 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | /** |
48 | 48 | * Stop now if a user isn't allowed to create an entity. |
49 | 49 | */ |
50 | - if (! current_user_can('ee_edit_events')) { |
|
50 | + if ( ! current_user_can('ee_edit_events')) { |
|
51 | 51 | // translators: the %1$s is the name of the object being mutated |
52 | 52 | throw new UserError( |
53 | 53 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * If there's no existing entity, throw an exception |
70 | 70 | */ |
71 | - if (! $id || ! ($entity instanceof EE_Price)) { |
|
71 | + if ( ! $id || ! ($entity instanceof EE_Price)) { |
|
72 | 72 | // translators: the placeholder is the name of the type being updated |
73 | 73 | throw new UserError( |
74 | 74 | sprintf( |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @param EEM_Price $model |
27 | 27 | * @param Price $type |
28 | - * @return callable |
|
28 | + * @return \Closure |
|
29 | 29 | */ |
30 | 30 | public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
31 | 31 | { |
@@ -16,36 +16,36 @@ |
||
16 | 16 | class PriceBaseTypeEnum extends EnumBase |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * PriceBaseTypeEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName('PriceBaseTypeEnum'); |
|
25 | - $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * PriceBaseTypeEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName('PriceBaseTypeEnum'); |
|
25 | + $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - protected function getValues() |
|
35 | - { |
|
36 | - return [ |
|
37 | - 'BASE_PRICE' => [ |
|
38 | - 'value' => EEM_Price_Type::base_type_base_price, |
|
39 | - ], |
|
40 | - 'DISCOUNT' => [ |
|
41 | - 'value' => EEM_Price_Type::base_type_discount, |
|
42 | - ], |
|
43 | - 'SURCHARGE' => [ |
|
44 | - 'value' => EEM_Price_Type::base_type_surcharge, |
|
45 | - ], |
|
46 | - 'TAX' => [ |
|
47 | - 'value' => EEM_Price_Type::base_type_tax, |
|
48 | - ], |
|
49 | - ]; |
|
50 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + protected function getValues() |
|
35 | + { |
|
36 | + return [ |
|
37 | + 'BASE_PRICE' => [ |
|
38 | + 'value' => EEM_Price_Type::base_type_base_price, |
|
39 | + ], |
|
40 | + 'DISCOUNT' => [ |
|
41 | + 'value' => EEM_Price_Type::base_type_discount, |
|
42 | + ], |
|
43 | + 'SURCHARGE' => [ |
|
44 | + 'value' => EEM_Price_Type::base_type_surcharge, |
|
45 | + ], |
|
46 | + 'TAX' => [ |
|
47 | + 'value' => EEM_Price_Type::base_type_tax, |
|
48 | + ], |
|
49 | + ]; |
|
50 | + } |
|
51 | 51 | } |
@@ -21,89 +21,89 @@ |
||
21 | 21 | class TicketUpdate |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Defines the mutation data modification closure. |
|
26 | - * |
|
27 | - * @param EEM_Ticket $model |
|
28 | - * @param Ticket $type |
|
29 | - * @return callable |
|
30 | - */ |
|
31 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
32 | - { |
|
33 | - /** |
|
34 | - * Updates an entity. |
|
35 | - * |
|
36 | - * @param array $input The input for the mutation |
|
37 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | - * @return array |
|
40 | - * @throws UserError |
|
41 | - * @throws ReflectionException |
|
42 | - * @throws InvalidArgumentException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - * @throws InvalidDataTypeException |
|
45 | - * @throws EE_Error |
|
46 | - */ |
|
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create an entity. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
57 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
58 | - |
|
59 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | - $entity = null; |
|
61 | - |
|
62 | - if ($id) { |
|
63 | - $entity = $model->get_one_by_ID($id); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * If there's no existing entity, throw an exception |
|
68 | - */ |
|
69 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
70 | - // translators: the placeholder is the name of the type being updated |
|
71 | - throw new UserError( |
|
72 | - sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | - ); |
|
74 | - } |
|
75 | - |
|
76 | - $datetimes = []; |
|
77 | - $prices = []; |
|
78 | - |
|
79 | - $args = TicketMutation::prepareFields($input); |
|
80 | - |
|
81 | - if (isset($args['datetimes'])) { |
|
82 | - $datetimes = $args['datetimes']; |
|
83 | - unset($args['datetimes']); |
|
84 | - } |
|
85 | - if (isset($args['prices'])) { |
|
86 | - $prices = $args['prices']; |
|
87 | - unset($args['prices']); |
|
88 | - } |
|
89 | - |
|
90 | - // Update the entity |
|
91 | - $result = $entity->save($args); |
|
92 | - |
|
93 | - if (empty($result)) { |
|
94 | - throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
95 | - } |
|
96 | - |
|
97 | - if (! empty($datetimes)) { |
|
98 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
99 | - } |
|
100 | - if (! empty($prices)) { |
|
101 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
102 | - } |
|
103 | - |
|
104 | - return [ |
|
105 | - 'id' => $id, |
|
106 | - ]; |
|
107 | - }; |
|
108 | - } |
|
24 | + /** |
|
25 | + * Defines the mutation data modification closure. |
|
26 | + * |
|
27 | + * @param EEM_Ticket $model |
|
28 | + * @param Ticket $type |
|
29 | + * @return callable |
|
30 | + */ |
|
31 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
32 | + { |
|
33 | + /** |
|
34 | + * Updates an entity. |
|
35 | + * |
|
36 | + * @param array $input The input for the mutation |
|
37 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | + * @return array |
|
40 | + * @throws UserError |
|
41 | + * @throws ReflectionException |
|
42 | + * @throws InvalidArgumentException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + * @throws InvalidDataTypeException |
|
45 | + * @throws EE_Error |
|
46 | + */ |
|
47 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create an entity. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
58 | + |
|
59 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | + $entity = null; |
|
61 | + |
|
62 | + if ($id) { |
|
63 | + $entity = $model->get_one_by_ID($id); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * If there's no existing entity, throw an exception |
|
68 | + */ |
|
69 | + if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
70 | + // translators: the placeholder is the name of the type being updated |
|
71 | + throw new UserError( |
|
72 | + sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | + ); |
|
74 | + } |
|
75 | + |
|
76 | + $datetimes = []; |
|
77 | + $prices = []; |
|
78 | + |
|
79 | + $args = TicketMutation::prepareFields($input); |
|
80 | + |
|
81 | + if (isset($args['datetimes'])) { |
|
82 | + $datetimes = $args['datetimes']; |
|
83 | + unset($args['datetimes']); |
|
84 | + } |
|
85 | + if (isset($args['prices'])) { |
|
86 | + $prices = $args['prices']; |
|
87 | + unset($args['prices']); |
|
88 | + } |
|
89 | + |
|
90 | + // Update the entity |
|
91 | + $result = $entity->save($args); |
|
92 | + |
|
93 | + if (empty($result)) { |
|
94 | + throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
95 | + } |
|
96 | + |
|
97 | + if (! empty($datetimes)) { |
|
98 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
99 | + } |
|
100 | + if (! empty($prices)) { |
|
101 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
102 | + } |
|
103 | + |
|
104 | + return [ |
|
105 | + 'id' => $id, |
|
106 | + ]; |
|
107 | + }; |
|
108 | + } |
|
109 | 109 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws InvalidDataTypeException |
45 | 45 | * @throws EE_Error |
46 | 46 | */ |
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create an entity. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * If there's no existing entity, throw an exception |
68 | 68 | */ |
69 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
69 | + if ( ! $id || ! ($entity instanceof EE_Ticket)) { |
|
70 | 70 | // translators: the placeholder is the name of the type being updated |
71 | 71 | throw new UserError( |
72 | 72 | sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
95 | 95 | } |
96 | 96 | |
97 | - if (! empty($datetimes)) { |
|
97 | + if ( ! empty($datetimes)) { |
|
98 | 98 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
99 | 99 | } |
100 | - if (! empty($prices)) { |
|
100 | + if ( ! empty($prices)) { |
|
101 | 101 | TicketMutation::setRelatedPrices($entity, $prices); |
102 | 102 | } |
103 | 103 |
@@ -21,81 +21,81 @@ |
||
21 | 21 | class DatetimeUpdate |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Defines the mutation data modification closure. |
|
26 | - * |
|
27 | - * @param EEM_Datetime $model |
|
28 | - * @param Datetime $type |
|
29 | - * @return callable |
|
30 | - */ |
|
31 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
32 | - { |
|
33 | - /** |
|
34 | - * Updates an entity. |
|
35 | - * |
|
36 | - * @param array $input The input for the mutation |
|
37 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | - * @return array |
|
40 | - * @throws UserError |
|
41 | - * @throws ReflectionException |
|
42 | - * @throws InvalidArgumentException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - * @throws InvalidDataTypeException |
|
45 | - * @throws EE_Error |
|
46 | - */ |
|
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create a datetime. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
57 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
58 | - |
|
59 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | - $entity = null; |
|
61 | - |
|
62 | - if ($id) { |
|
63 | - $entity = $model->get_one_by_ID($id); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * If there's no existing datetime, throw an exception |
|
68 | - */ |
|
69 | - if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
70 | - // translators: the placeholder is the name of the type being updated |
|
71 | - throw new UserError( |
|
72 | - sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | - ); |
|
74 | - } |
|
75 | - |
|
76 | - $tickets = []; |
|
77 | - |
|
78 | - $args = DatetimeMutation::prepareFields($input); |
|
79 | - |
|
80 | - if (isset($args['tickets'])) { |
|
81 | - $tickets = $args['tickets']; |
|
82 | - unset($args['tickets']); |
|
83 | - } |
|
84 | - |
|
85 | - // Update the entity |
|
86 | - $result = $entity->save($args); |
|
87 | - |
|
88 | - if (empty($result)) { |
|
89 | - throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
90 | - } |
|
91 | - |
|
92 | - if (! empty($tickets)) { |
|
93 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
94 | - } |
|
95 | - |
|
96 | - return [ |
|
97 | - 'id' => $id, |
|
98 | - ]; |
|
99 | - }; |
|
100 | - } |
|
24 | + /** |
|
25 | + * Defines the mutation data modification closure. |
|
26 | + * |
|
27 | + * @param EEM_Datetime $model |
|
28 | + * @param Datetime $type |
|
29 | + * @return callable |
|
30 | + */ |
|
31 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
32 | + { |
|
33 | + /** |
|
34 | + * Updates an entity. |
|
35 | + * |
|
36 | + * @param array $input The input for the mutation |
|
37 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | + * @return array |
|
40 | + * @throws UserError |
|
41 | + * @throws ReflectionException |
|
42 | + * @throws InvalidArgumentException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + * @throws InvalidDataTypeException |
|
45 | + * @throws EE_Error |
|
46 | + */ |
|
47 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create a datetime. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
58 | + |
|
59 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | + $entity = null; |
|
61 | + |
|
62 | + if ($id) { |
|
63 | + $entity = $model->get_one_by_ID($id); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * If there's no existing datetime, throw an exception |
|
68 | + */ |
|
69 | + if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
70 | + // translators: the placeholder is the name of the type being updated |
|
71 | + throw new UserError( |
|
72 | + sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | + ); |
|
74 | + } |
|
75 | + |
|
76 | + $tickets = []; |
|
77 | + |
|
78 | + $args = DatetimeMutation::prepareFields($input); |
|
79 | + |
|
80 | + if (isset($args['tickets'])) { |
|
81 | + $tickets = $args['tickets']; |
|
82 | + unset($args['tickets']); |
|
83 | + } |
|
84 | + |
|
85 | + // Update the entity |
|
86 | + $result = $entity->save($args); |
|
87 | + |
|
88 | + if (empty($result)) { |
|
89 | + throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
90 | + } |
|
91 | + |
|
92 | + if (! empty($tickets)) { |
|
93 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
94 | + } |
|
95 | + |
|
96 | + return [ |
|
97 | + 'id' => $id, |
|
98 | + ]; |
|
99 | + }; |
|
100 | + } |
|
101 | 101 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws InvalidDataTypeException |
45 | 45 | * @throws EE_Error |
46 | 46 | */ |
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create a datetime. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * If there's no existing datetime, throw an exception |
68 | 68 | */ |
69 | - if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
69 | + if ( ! $id || ! ($entity instanceof EE_Datetime)) { |
|
70 | 70 | // translators: the placeholder is the name of the type being updated |
71 | 71 | throw new UserError( |
72 | 72 | sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
90 | 90 | } |
91 | 91 | |
92 | - if (! empty($tickets)) { |
|
92 | + if ( ! empty($tickets)) { |
|
93 | 93 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
94 | 94 | } |
95 | 95 |
@@ -21,70 +21,70 @@ |
||
21 | 21 | class PriceUpdate |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Defines the mutation data modification closure. |
|
26 | - * |
|
27 | - * @param EEM_Price $model |
|
28 | - * @param Price $type |
|
29 | - * @return callable |
|
30 | - */ |
|
31 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
32 | - { |
|
33 | - /** |
|
34 | - * Updates an entity. |
|
35 | - * |
|
36 | - * @param array $input The input for the mutation |
|
37 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | - * @return array |
|
40 | - * @throws UserError |
|
41 | - * @throws ReflectionException |
|
42 | - * @throws InvalidArgumentException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - * @throws InvalidDataTypeException |
|
45 | - * @throws EE_Error |
|
46 | - */ |
|
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create an entity. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
57 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
24 | + /** |
|
25 | + * Defines the mutation data modification closure. |
|
26 | + * |
|
27 | + * @param EEM_Price $model |
|
28 | + * @param Price $type |
|
29 | + * @return callable |
|
30 | + */ |
|
31 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
32 | + { |
|
33 | + /** |
|
34 | + * Updates an entity. |
|
35 | + * |
|
36 | + * @param array $input The input for the mutation |
|
37 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
38 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
39 | + * @return array |
|
40 | + * @throws UserError |
|
41 | + * @throws ReflectionException |
|
42 | + * @throws InvalidArgumentException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + * @throws InvalidDataTypeException |
|
45 | + * @throws EE_Error |
|
46 | + */ |
|
47 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create an entity. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
58 | 58 | |
59 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | - $entity = null; |
|
59 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
60 | + $entity = null; |
|
61 | 61 | |
62 | - if ($id) { |
|
63 | - $entity = $model->get_one_by_ID($id); |
|
64 | - } |
|
62 | + if ($id) { |
|
63 | + $entity = $model->get_one_by_ID($id); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * If there's no existing entity, throw an exception |
|
68 | - */ |
|
69 | - if (! $id || ! ($entity instanceof EE_Price)) { |
|
70 | - // translators: the placeholder is the name of the type being updated |
|
71 | - throw new UserError( |
|
72 | - sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | - ); |
|
74 | - } |
|
66 | + /** |
|
67 | + * If there's no existing entity, throw an exception |
|
68 | + */ |
|
69 | + if (! $id || ! ($entity instanceof EE_Price)) { |
|
70 | + // translators: the placeholder is the name of the type being updated |
|
71 | + throw new UserError( |
|
72 | + sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - $args = PriceMutation::prepareFields($input); |
|
76 | + $args = PriceMutation::prepareFields($input); |
|
77 | 77 | |
78 | - // Update the entity |
|
79 | - $result = $entity->save($args); |
|
78 | + // Update the entity |
|
79 | + $result = $entity->save($args); |
|
80 | 80 | |
81 | - if (empty($result)) { |
|
82 | - throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
83 | - } |
|
81 | + if (empty($result)) { |
|
82 | + throw new UserError(esc_html__('The object failed to update but no error was provided', 'event_espresso')); |
|
83 | + } |
|
84 | 84 | |
85 | - return [ |
|
86 | - 'id' => $id, |
|
87 | - ]; |
|
88 | - }; |
|
89 | - } |
|
85 | + return [ |
|
86 | + 'id' => $id, |
|
87 | + ]; |
|
88 | + }; |
|
89 | + } |
|
90 | 90 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws InvalidDataTypeException |
45 | 45 | * @throws EE_Error |
46 | 46 | */ |
47 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create an entity. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * If there's no existing entity, throw an exception |
68 | 68 | */ |
69 | - if (! $id || ! ($entity instanceof EE_Price)) { |
|
69 | + if ( ! $id || ! ($entity instanceof EE_Price)) { |
|
70 | 70 | // translators: the placeholder is the name of the type being updated |
71 | 71 | throw new UserError( |
72 | 72 | sprintf(esc_html__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @param EEM_Price $model |
27 | 27 | * @param Price $type |
28 | - * @return callable |
|
28 | + * @return \Closure |
|
29 | 29 | */ |
30 | 30 | public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
31 | 31 | { |
@@ -6,13 +6,11 @@ |
||
6 | 6 | use EE_Price; |
7 | 7 | use EventEspresso\core\domain\services\graphql\types\Price; |
8 | 8 | use EventEspresso\core\domain\services\graphql\data\mutations\PriceMutation; |
9 | - |
|
10 | 9 | use EE_Error; |
11 | 10 | use InvalidArgumentException; |
12 | 11 | use ReflectionException; |
13 | 12 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
14 | 13 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
15 | - |
|
16 | 14 | use GraphQL\Type\Definition\ResolveInfo; |
17 | 15 | use WPGraphQL\AppContext; |
18 | 16 | use GraphQL\Error\UserError; |
@@ -20,64 +20,64 @@ |
||
20 | 20 | class DatetimeCreate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Datetime $model |
|
27 | - * @param Datetime $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Creates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Datetime $model |
|
27 | + * @param Datetime $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Creates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create a datetime. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create a datetime. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - $tickets = []; |
|
58 | + $tickets = []; |
|
59 | 59 | |
60 | - $args = DatetimeMutation::prepareFields($input); |
|
60 | + $args = DatetimeMutation::prepareFields($input); |
|
61 | 61 | |
62 | - if (isset($args['tickets'])) { |
|
63 | - $tickets = $args['tickets']; |
|
64 | - unset($args['tickets']); |
|
65 | - } |
|
62 | + if (isset($args['tickets'])) { |
|
63 | + $tickets = $args['tickets']; |
|
64 | + unset($args['tickets']); |
|
65 | + } |
|
66 | 66 | |
67 | - $entity = EE_Datetime::new_instance($args); |
|
68 | - $id = $entity->save(); |
|
67 | + $entity = EE_Datetime::new_instance($args); |
|
68 | + $id = $entity->save(); |
|
69 | 69 | |
70 | - if (empty($id)) { |
|
71 | - throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | - } |
|
70 | + if (empty($id)) { |
|
71 | + throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | + } |
|
73 | 73 | |
74 | - if (! empty($tickets)) { |
|
75 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
76 | - } |
|
74 | + if (! empty($tickets)) { |
|
75 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $id, |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $id, |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create a datetime. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
72 | 72 | } |
73 | 73 | |
74 | - if (! empty($tickets)) { |
|
74 | + if ( ! empty($tickets)) { |
|
75 | 75 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
76 | 76 | } |
77 | 77 |
@@ -20,72 +20,72 @@ |
||
20 | 20 | class TicketCreate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - * @param Ticket $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Creates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + * @param Ticket $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Creates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create an entity. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create an entity. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - $datetimes = []; |
|
59 | - $prices = []; |
|
58 | + $datetimes = []; |
|
59 | + $prices = []; |
|
60 | 60 | |
61 | - $args = TicketMutation::prepareFields($input); |
|
61 | + $args = TicketMutation::prepareFields($input); |
|
62 | 62 | |
63 | - if (isset($args['datetimes'])) { |
|
64 | - $datetimes = $args['datetimes']; |
|
65 | - unset($args['datetimes']); |
|
66 | - } |
|
67 | - if (isset($args['prices'])) { |
|
68 | - $prices = $args['prices']; |
|
69 | - unset($args['prices']); |
|
70 | - } |
|
63 | + if (isset($args['datetimes'])) { |
|
64 | + $datetimes = $args['datetimes']; |
|
65 | + unset($args['datetimes']); |
|
66 | + } |
|
67 | + if (isset($args['prices'])) { |
|
68 | + $prices = $args['prices']; |
|
69 | + unset($args['prices']); |
|
70 | + } |
|
71 | 71 | |
72 | - $entity = EE_Ticket::new_instance($args); |
|
73 | - $id = $entity->save(); |
|
72 | + $entity = EE_Ticket::new_instance($args); |
|
73 | + $id = $entity->save(); |
|
74 | 74 | |
75 | - if (empty($id)) { |
|
76 | - throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
77 | - } |
|
75 | + if (empty($id)) { |
|
76 | + throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
|
77 | + } |
|
78 | 78 | |
79 | - if (! empty($datetimes)) { |
|
80 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
81 | - } |
|
82 | - if (! empty($prices)) { |
|
83 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
84 | - } |
|
79 | + if (! empty($datetimes)) { |
|
80 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
81 | + } |
|
82 | + if (! empty($prices)) { |
|
83 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
84 | + } |
|
85 | 85 | |
86 | - return [ |
|
87 | - 'id' => $id, |
|
88 | - ]; |
|
89 | - }; |
|
90 | - } |
|
86 | + return [ |
|
87 | + 'id' => $id, |
|
88 | + ]; |
|
89 | + }; |
|
90 | + } |
|
91 | 91 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create an entity. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(esc_html__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | throw new UserError(esc_html__('The object failed to create but no error was provided', 'event_espresso')); |
77 | 77 | } |
78 | 78 | |
79 | - if (! empty($datetimes)) { |
|
79 | + if ( ! empty($datetimes)) { |
|
80 | 80 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
81 | 81 | } |
82 | - if (! empty($prices)) { |
|
82 | + if ( ! empty($prices)) { |
|
83 | 83 | TicketMutation::setRelatedPrices($entity, $prices); |
84 | 84 | } |
85 | 85 |
@@ -20,74 +20,74 @@ |
||
20 | 20 | class TicketDelete |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - * @param Ticket $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Deletes an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | - /** |
|
48 | - * Stop now if a user isn't allowed to create an entity. |
|
49 | - */ |
|
50 | - if (! current_user_can('ee_edit_events')) { |
|
51 | - // translators: the %1$s is the name of the object being mutated |
|
52 | - throw new UserError( |
|
53 | - sprintf( |
|
54 | - esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), |
|
55 | - $type->name() |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
59 | - $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + * @param Ticket $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Deletes an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + /** |
|
48 | + * Stop now if a user isn't allowed to create an entity. |
|
49 | + */ |
|
50 | + if (! current_user_can('ee_edit_events')) { |
|
51 | + // translators: the %1$s is the name of the object being mutated |
|
52 | + throw new UserError( |
|
53 | + sprintf( |
|
54 | + esc_html__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), |
|
55 | + $type->name() |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | + $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null; |
|
60 | 60 | |
61 | - $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
62 | - $entity = null; |
|
61 | + $id = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0; |
|
62 | + $entity = null; |
|
63 | 63 | |
64 | - if ($id) { |
|
65 | - $entity = $model->get_one_by_ID($id); |
|
66 | - } |
|
64 | + if ($id) { |
|
65 | + $entity = $model->get_one_by_ID($id); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * If there's no existing entity, throw an exception |
|
70 | - */ |
|
71 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
72 | - // translators: the placeholder is the name of the type being updated |
|
73 | - throw new UserError( |
|
74 | - sprintf( |
|
75 | - esc_html__('No %1$s could be found to delete', 'event_espresso'), |
|
76 | - $type->name() |
|
77 | - ) |
|
78 | - ); |
|
79 | - } |
|
68 | + /** |
|
69 | + * If there's no existing entity, throw an exception |
|
70 | + */ |
|
71 | + if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
72 | + // translators: the placeholder is the name of the type being updated |
|
73 | + throw new UserError( |
|
74 | + sprintf( |
|
75 | + esc_html__('No %1$s could be found to delete', 'event_espresso'), |
|
76 | + $type->name() |
|
77 | + ) |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | - // Delete the entity |
|
82 | - $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
81 | + // Delete the entity |
|
82 | + $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
83 | 83 | |
84 | - if (empty($result)) { |
|
85 | - throw new UserError(esc_html__('The object failed to delete but no error was provided', 'event_espresso')); |
|
86 | - } |
|
84 | + if (empty($result)) { |
|
85 | + throw new UserError(esc_html__('The object failed to delete but no error was provided', 'event_espresso')); |
|
86 | + } |
|
87 | 87 | |
88 | - return [ |
|
89 | - 'deleted' => $entity, |
|
90 | - ]; |
|
91 | - }; |
|
92 | - } |
|
88 | + return [ |
|
89 | + 'deleted' => $entity, |
|
90 | + ]; |
|
91 | + }; |
|
92 | + } |
|
93 | 93 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | /** |
48 | 48 | * Stop now if a user isn't allowed to create an entity. |
49 | 49 | */ |
50 | - if (! current_user_can('ee_edit_events')) { |
|
50 | + if ( ! current_user_can('ee_edit_events')) { |
|
51 | 51 | // translators: the %1$s is the name of the object being mutated |
52 | 52 | throw new UserError( |
53 | 53 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * If there's no existing entity, throw an exception |
70 | 70 | */ |
71 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
71 | + if ( ! $id || ! ($entity instanceof EE_Ticket)) { |
|
72 | 72 | // translators: the placeholder is the name of the type being updated |
73 | 73 | throw new UserError( |
74 | 74 | sprintf( |