Conditions | 2 |
Paths | 1 |
Total Lines | 34 |
Lines | 34 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
23 | public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
||
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 | */ |
||
33 | return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
||
34 | try { |
||
35 | /** @var EE_Price $entity */ |
||
36 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
||
37 | |||
38 | $args = PriceMutation::prepareFields($input); |
||
39 | |||
40 | // Update the entity |
||
41 | $entity->save($args); |
||
42 | } catch (Exception $exception) { |
||
43 | EntityMutator::handleExceptions( |
||
44 | $exception, |
||
45 | esc_html__( |
||
46 | 'The price could not be updated because of the following error(s)', |
||
47 | 'event_espresso' |
||
48 | ) |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | return [ |
||
53 | 'id' => $entity->ID(), |
||
54 | ]; |
||
55 | }; |
||
56 | } |
||
57 | } |
||
58 |