ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilUIDemoFileUploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
8
15{
16
20 public function getUploadURL() : string
21 {
22 $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
23
24 return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_UPLOAD);
25 }
26
27
31 public function getExistingFileInfoURL() : string
32 {
33 $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
34
35 return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_INFO);
36 }
37
38
42 public function getFileRemovalURL() : string
43 {
44 $this->ctrl->initBaseClass(ilUIPluginRouterGUI::class);
45
46 return $this->ctrl->getLinkTargetByClass([ilUIPluginRouterGUI::class, self::class], self::CMD_REMOVE);
47 }
48
49
53 public function getFileIdentifierParameterName() : string
54 {
55 return 'my_file_id';
56 }
57
58
62 protected function getUploadResult() : HandlerResult
63 {
64 $status = HandlerResult::STATUS_OK;
65 $identifier = md5(random_bytes(65));
66 $message = 'Everything ok';
67
68 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
69 }
70
71
72 protected function getRemoveResult(string $identifier) : HandlerResult
73 {
74 $status = HandlerResult::STATUS_OK;
75 $message = 'File Deleted';
76
77 return new BasicHandlerResult($this->getFileIdentifierParameterName(), $status, $identifier, $message);
78 }
79
80
81 protected function getInfoResult(string $identifier) : FileInfoResult
82 {
83 return new BasicFileInfoResult($this->getFileIdentifierParameterName(), $identifier, "My funny Testfile $identifier.txt", 64);
84 }
85
86
87 public function getInfoForExistingFiles(array $file_ids) : array
88 {
89 $infos = [];
90 foreach ($file_ids as $file_id) {
91 $infos[] = new BasicFileInfoResult($this->getFileIdentifierParameterName(), $file_id, "Name $file_id.txt", rand(1000, 2000), "text/plain");
92 }
93
94 return $infos;
95 }
96}
An exception for terminatinating execution or to throw for unit testing.
Class ilUIDemoFileUploadHandlerGUI.
$message
Definition: xapiexit.php:14