ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
InstructionFileManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
30 protected \ilExcInstructionFilesStakeholder $stakeholder;
31 protected \ILIAS\FileUpload\FileUpload $upload;
32 protected int $ass_id;
34
35 public function __construct(
36 int $ass_id,
39 ) {
40 global $DIC;
41
42 $this->upload = $DIC->upload();
43
44 $this->repo = $repo;
45 $this->ass_id = $ass_id;
46 $this->stakeholder = $stakeholder;
47 }
48
50 {
51 return $this->stakeholder;
52 }
53
54 public function getCollectionIdString(): string
55 {
56 return $this->repo->getIdStringForAssId($this->ass_id);
57 }
58
59 public function createCollection(): void
60 {
61 $this->repo->createCollection($this->ass_id);
62 }
63
64 public function importFromLegacyUpload(array $file_input): void
65 {
66 $this->repo->importFromLegacyUpload(
67 $this->ass_id,
68 $file_input,
69 $this->stakeholder
70 );
71 }
72
73 public function importFromDirectory(string $dir): void
74 {
75 $this->repo->importFromDirectory(
76 $this->ass_id,
77 $dir,
78 $this->stakeholder
79 );
80 }
81
82 public function deleteCollection(): void
83 {
84 $this->repo->deleteCollection(
85 $this->ass_id,
86 $this->stakeholder
87 );
88 }
89
91 {
92 return $this->repo->getCollection($this->ass_id);
93 }
94
95 public function getFiles(): array
96 {
97 if ($this->repo->hasCollection($this->ass_id)) {
98 return array_map(function (ResourceInformation $info): array {
99 return [
100 'rid' => $info->getRid(),
101 'name' => $info->getTitle(),
102 'size' => $info->getSize(),
103 'ctime' => $info->getCreationTimestamp(),
104 'fullpath' => $info->getSrc(),
105 'mime' => $info->getMimeType(), // this is additional to still use the image delivery in class.ilExAssignmentGUI.php:306
106 'order' => 0 // sorting is currently not supported
107 ];
108 }, iterator_to_array($this->repo->getCollectionResourcesInfo($this->ass_id)));
109 }
110 return [];
111 }
112
113 public function deliver(string $full_path, string $file): void
114 {
115 if ($this->repo->hasCollection($this->ass_id)) {
116 $this->repo->deliverFile($this->ass_id, $file);
117 }
118 }
119
120 public function getStream(
121 string $rid
122 ): ?FileStream {
123 return $this->repo->getStream($this->ass_id, $rid);
124 }
125
126 public function cloneTo(
127 int $to_ass_id
128 ): void {
129 $this->repo->clone($this->ass_id, $to_ass_id);
130 }
131}
__construct(int $ass_id, InstructionFileRepository $repo, \ilExcInstructionFilesStakeholder $stakeholder)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
The base interface for all filesystem streams.
Definition: FileStream.php:32
global $DIC
Definition: shib_login.php:26