Conditions | 3 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
39 | public function resolve($object, array $args, $context, ResolveInfo $info) |
||
40 | { |
||
41 | /** @var File $file */ |
||
42 | $file = Versioned::get_by_stage(File::class, Versioned::DRAFT)->byID($args['id']); |
||
43 | if (!$file) { |
||
44 | throw new \InvalidArgumentException(sprintf( |
||
45 | '%s#%s not found', |
||
46 | File::class, |
||
47 | $args['id'] |
||
48 | )); |
||
49 | } |
||
50 | |||
51 | if (!$file->canArchive()) { |
||
52 | throw new \InvalidArgumentException(sprintf( |
||
53 | '%s#%s delete not allowed', |
||
54 | File::class, |
||
55 | $args['id'] |
||
56 | )); |
||
57 | } |
||
58 | |||
59 | $file->doArchive(); |
||
60 | |||
61 | return $args['id']; |
||
62 | } |
||
63 | } |
||
64 |