ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.UploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\ResourceStorage\Services as ResourceStorage;
30
36{
37 public function __construct(
38 private readonly ResourceStorage $storage,
39 private readonly Stakeholder $stakeholder
40 ) {
41
43 }
44
45 protected function getUploadResult(): HandlerResult
46 {
47 $this->upload->process();
48
49 $result_array = $this->upload->getResults();
50 $result = end($result_array);
51
52 if (!($result instanceof UploadResult) || !$result->isOK()) {
53 return new BasicHandlerResult(
56 '',
57 $result->getStatus()->getMessage()
58 );
59 }
60
61 return new BasicHandlerResult(
64 $this->storage->manage()->upload($result, $this->stakeholder)->serialize(),
65 'file upload OK'
66 );
67 }
68
69 protected function getRemoveResult(string $identifier): HandlerResult
70 {
71 return new BasicHandlerResult(
74 $identifier,
75 'We just don\'t do anything here.'
76 );
77 }
78
79 public function getInfoResult(string $identifier): ?FileInfoResult
80 {
81 $title = $mime = 'unknown';
82 $size = 0;
83 if (($id = $this->storage->manage()->find($identifier)) !== null) {
84 $revision = $this->storage->manage()->getCurrentRevision($id)->getInformation();
85 $title = $revision->getTitle();
86 $size = $revision->getSize();
87 $mime = $revision->getMimeType();
88 }
89
90 return new BasicFileInfoResult(
92 $identifier,
93 $title,
94 $size,
95 $mime
96 );
97 }
98
102 public function getInfoForExistingFiles(array $file_ids): array
103 {
104 $info_results = [];
105 foreach ($file_ids as $identifier) {
106 $info_results[] = $this->getInfoResult($identifier);
107 }
108
109 return $info_results;
110 }
111}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private readonly ResourceStorage $storage, private readonly Stakeholder $stakeholder)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc