@@ 11-58 (lines=48) @@ | ||
8 | use GraphQL\Type\Definition\ResolveInfo; |
|
9 | use WPGraphQL\AppContext; |
|
10 | ||
11 | class FormSectionDelete extends EntityMutator |
|
12 | { |
|
13 | ||
14 | /** |
|
15 | * Defines the mutation data modification closure. |
|
16 | * |
|
17 | * @param EEM_Form_Section $model |
|
18 | * @return callable |
|
19 | */ |
|
20 | public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
21 | { |
|
22 | /** |
|
23 | * Deletes an entity. |
|
24 | * |
|
25 | * @param array $input The input for the mutation |
|
26 | * @param AppContext $context The AppContext passed down to all resolvers |
|
27 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
28 | * @return array |
|
29 | */ |
|
30 | return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
31 | try { |
|
32 | /** @var EE_Form_Section $entity */ |
|
33 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
34 | ||
35 | $result = $entity->delete(); |
|
36 | EntityMutator::validateResults($result); |
|
37 | ||
38 | do_action( |
|
39 | 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete', |
|
40 | $entity, |
|
41 | $input |
|
42 | ); |
|
43 | } catch (Exception $exception) { |
|
44 | EntityMutator::handleExceptions( |
|
45 | $exception, |
|
46 | esc_html__( |
|
47 | 'The form section could not be deleted because of the following error(s)', |
|
48 | 'event_espresso' |
|
49 | ) |
|
50 | ); |
|
51 | } |
|
52 | ||
53 | return [ |
|
54 | 'deleted' => $entity, |
|
55 | ]; |
|
56 | }; |
|
57 | } |
|
58 | } |
|
59 |
@@ 14-65 (lines=52) @@ | ||
11 | use WPGraphQL\AppContext; |
|
12 | use Exception; |
|
13 | ||
14 | class FormSectionUpdate extends EntityMutator |
|
15 | { |
|
16 | ||
17 | /** |
|
18 | * Defines the mutation data modification closure. |
|
19 | * |
|
20 | * @param EEM_Form_Section $model |
|
21 | * @return callable |
|
22 | */ |
|
23 | public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
24 | { |
|
25 | /** |
|
26 | * Updates an entity. |
|
27 | * |
|
28 | * @param array $input The input for the mutation |
|
29 | * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | * @return array |
|
32 | * @throws EE_Error |
|
33 | * @throws ReflectionException |
|
34 | */ |
|
35 | return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | try { |
|
37 | /** @var EE_Form_Section $entity */ |
|
38 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
39 | ||
40 | $args = FormSectionMutation::prepareFields($input); |
|
41 | ||
42 | // Update the entity |
|
43 | $entity->save($args); |
|
44 | ||
45 | do_action( |
|
46 | 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_update', |
|
47 | $entity, |
|
48 | $input |
|
49 | ); |
|
50 | } catch (Exception $exception) { |
|
51 | EntityMutator::handleExceptions( |
|
52 | $exception, |
|
53 | esc_html__( |
|
54 | 'The form section could not be updated because of the following error(s)', |
|
55 | 'event_espresso' |
|
56 | ) |
|
57 | ); |
|
58 | } |
|
59 | ||
60 | return [ |
|
61 | 'id' => $entity->UUID(), |
|
62 | ]; |
|
63 | }; |
|
64 | } |
|
65 | } |
|
66 |
@@ 15-63 (lines=49) @@ | ||
12 | use ReflectionException; |
|
13 | use WPGraphQL\AppContext; |
|
14 | ||
15 | class PriceUpdate extends EntityMutator |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * Defines the mutation data modification closure. |
|
20 | * |
|
21 | * @param EEM_Price $model |
|
22 | * @param Price $type |
|
23 | * @return callable |
|
24 | */ |
|
25 | public static function mutateAndGetPayload(EEM_Price $model, Price $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_Price $entity */ |
|
40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | ||
42 | $args = PriceMutation::prepareFields($input); |
|
43 | ||
44 | // Update the entity |
|
45 | $entity->save($args); |
|
46 | ||
47 | do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_update', $entity, $input); |
|
48 | } catch (Exception $exception) { |
|
49 | EntityMutator::handleExceptions( |
|
50 | $exception, |
|
51 | esc_html__( |
|
52 | 'The price could not be updated because of the following error(s)', |
|
53 | 'event_espresso' |
|
54 | ) |
|
55 | ); |
|
56 | } |
|
57 | ||
58 | return [ |
|
59 | 'id' => $entity->ID(), |
|
60 | ]; |
|
61 | }; |
|
62 | } |
|
63 | } |
|
64 |