@@ -14,54 +14,54 @@ |
||
14 | 14 | class PriceCreate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Price $model |
|
21 | - * @param Price $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
25 | - { |
|
26 | - /** |
|
27 | - * Creates an entity. |
|
28 | - * |
|
29 | - * @param array $input The input for the mutation |
|
30 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
31 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
35 | - try { |
|
36 | - EntityMutator::checkPermissions($model); |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Price $model |
|
21 | + * @param Price $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
25 | + { |
|
26 | + /** |
|
27 | + * Creates an entity. |
|
28 | + * |
|
29 | + * @param array $input The input for the mutation |
|
30 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
31 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
35 | + try { |
|
36 | + EntityMutator::checkPermissions($model); |
|
37 | 37 | |
38 | - $args = PriceMutation::prepareFields($input); |
|
38 | + $args = PriceMutation::prepareFields($input); |
|
39 | 39 | |
40 | - if (empty($args['PRT_ID'])) { |
|
41 | - // translators: the placeholder is the name of the field. |
|
42 | - throw new UserError( |
|
43 | - sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
44 | - ); |
|
45 | - } |
|
40 | + if (empty($args['PRT_ID'])) { |
|
41 | + // translators: the placeholder is the name of the field. |
|
42 | + throw new UserError( |
|
43 | + sprintf(esc_html__('A valid %1$s must be passed.', 'event_espresso'), 'priceType') |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | - $entity = EE_Price::new_instance($args); |
|
48 | - $id = $entity->save(); |
|
49 | - EntityMutator::validateResults($id); |
|
47 | + $entity = EE_Price::new_instance($args); |
|
48 | + $id = $entity->save(); |
|
49 | + EntityMutator::validateResults($id); |
|
50 | 50 | |
51 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_create', $entity, $input); |
|
52 | - } catch (Exception $exception) { |
|
53 | - EntityMutator::handleExceptions( |
|
54 | - $exception, |
|
55 | - esc_html__( |
|
56 | - 'The price could not be created because of the following error(s)', |
|
57 | - 'event_espresso' |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
51 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_create', $entity, $input); |
|
52 | + } catch (Exception $exception) { |
|
53 | + EntityMutator::handleExceptions( |
|
54 | + $exception, |
|
55 | + esc_html__( |
|
56 | + 'The price could not be created because of the following error(s)', |
|
57 | + 'event_espresso' |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | |
62 | - return [ |
|
63 | - 'id' => $id, |
|
64 | - ]; |
|
65 | - }; |
|
66 | - } |
|
62 | + return [ |
|
63 | + 'id' => $id, |
|
64 | + ]; |
|
65 | + }; |
|
66 | + } |
|
67 | 67 | } |