Conditions | 3 |
Paths | 1 |
Total Lines | 33 |
Lines | 33 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
22 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
||
23 | { |
||
24 | /** |
||
25 | * Deletes an entity. |
||
26 | * |
||
27 | * @param array $input The input for the mutation |
||
28 | * @param AppContext $context The AppContext passed down to all resolvers |
||
29 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
||
30 | * @return array|void |
||
31 | */ |
||
32 | return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
||
33 | try { |
||
34 | /** @var EE_Datetime $entity */ |
||
35 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
||
36 | |||
37 | // Delete the entity |
||
38 | $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
||
39 | EntityMutator::validateResults($result); |
||
40 | } catch (Exception $exception) { |
||
41 | EntityMutator::handleExceptions( |
||
42 | $exception, |
||
43 | esc_html__( |
||
44 | 'The datetime could not be deleted because of the following error(s)', |
||
45 | 'event_espresso' |
||
46 | ) |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | return [ |
||
51 | 'deleted' => $entity, |
||
52 | ]; |
||
53 | }; |
||
54 | } |
||
55 | } |
||
56 |