Conditions | 3 |
Paths | 1 |
Total Lines | 36 |
Lines | 36 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
22 | public static function mutateFields(EEM_Event $model, Event $type) |
||
23 | { |
||
24 | /** |
||
25 | * Update additional data related to the entity. |
||
26 | * |
||
27 | * @param int $id The ID of the postObject being mutated |
||
28 | * @param array $input The input for the mutation |
||
29 | * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
||
30 | * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
||
31 | * @param AppContext $context The AppContext passed down to all resolvers |
||
32 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
||
33 | */ |
||
34 | return static function ( |
||
35 | $id, |
||
36 | array $input, |
||
37 | WP_Post_Type $post_type_object, |
||
38 | $mutation_name, |
||
39 | AppContext $context, |
||
40 | ResolveInfo $info |
||
41 | ) use ($model, $type) |
||
42 | { |
||
43 | // Make sure we are dealing with the right entity. |
||
44 | if ($post_type_object->graphql_single_name !== $type->name()) { |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | $entity = $model->get_one_by_ID($id); |
||
49 | |||
50 | if ($entity instanceof EE_Event) { |
||
51 | $args = EventMutation::prepare_fields($input, $mutation_name); |
||
52 | |||
53 | // Update the entity |
||
54 | $entity->save($args); |
||
55 | } |
||
56 | }; |
||
57 | } |
||
58 | } |
||
59 |