ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjFileSingleFileDelegate.php
Go to the documentation of this file.
1<?php
2
20
26{
30 protected $object_id;
31
35 protected $uploaded_suffixes = [];
36
37 public function handle(
38 int $parent_id,
39 array $post_data,
41 ilObjFileGUI $gui
43 // Create new FileObject
44 $file = new ilObjFile();
45 $this->object_id = $file->create();
46 $gui->putObjectInTree($file, $parent_id);
47// $gui->handleAutoRating($file);
48
49 // Response
51
52 // Append Upload
53 $title = $post_data['title'];
54 $description = $post_data['description'];
55 try {
56 $file->appendUpload($result, $title ?? $result->getName());
57 $file->setDescription($description);
58 $file->update();
59 $response->fileName = $file->getFileName();
60 $response->fileSize = $file->getFileSize();
61 $response->fileType = $file->getFileType();
62 $response->error = null;
63 $this->uploaded_suffixes[] = $file->getFileExtension();
64 } catch (Exception $e) {
65 $file->delete();
66 $response->error = $e->getMessage();
67 }
68
69 return $response;
70 }
71
72 public function getUploadedSuffixes() : array
73 {
74 return array_map('strtolower', $this->uploaded_suffixes);
75 }
76}
$result
An exception for terminatinating execution or to throw for unit testing.
GUI class for file objects.
Class ilObjFileSingleFileDelegate.
handle(int $parent_id, array $post_data, UploadResult $result, ilObjFileGUI $gui)
Class ilObjFileUploadResponse.
Class ilObjFile.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
create($a_clone_mode=false)
Interface ilObjUploadDelegateInterface.
$response