ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Exercise\IRSS\CollectionWrapper Class Reference
+ Collaboration diagram for ILIAS\Exercise\IRSS\CollectionWrapper:

Public Member Functions

 __construct (InternalDataService $data)
 
 createEmptyCollection ()
 
 getCollectionForIdString (string $rcid)
 
 deleteCollectionForIdString (string $rcid, ResourceStakeholder $stakeholder)
 
 copyResourcesToDir (string $rcid, ResourceStakeholder $stakeholder, string $dir)
 
 importFilesFromLegacyUploadToCollection (ResourceCollection $collection, array $file_input, ResourceStakeholder $stakeholder)
 
 importFilesFromDirectoryToCollection (ResourceCollection $collection, string $directory, ResourceStakeholder $stakeholder)
 
 importFileFromLegacyUpload (array $file_input, ResourceStakeholder $stakeholder)
 
 importFileFromUploadResult (UploadResult $result, ResourceStakeholder $stakeholder)
 
 deliverFile (string $rid)
 
 stream (string $rid)
 
 getCollectionResourcesInfo (ResourceCollection $collection)
 
 clone (string $from_rc_id)
 
 cloneResource (string $from_rid)
 
 deleteResource (string $rid, ResourceStakeholder $stakeholder)
 
 addEntryOfZipResourceToCollection (string $rid, string $entry, ResourceCollection $target_collection, ResourceStakeholder $target_stakeholder)
 

Protected Member Functions

 getNewCollectionId ()
 
 getNewCollectionIdAsString ()
 
 getResourceIdForIdString (string $rid)
 

Protected Attributes

InternalDataService $data
 
ILIAS FileUpload FileUpload $upload
 
ILIAS ResourceStorage Services $irss
 

Detailed Description

Definition at line 33 of file CollectionWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Exercise\IRSS\CollectionWrapper::__construct ( InternalDataService  $data)

Definition at line 39 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\$data, $DIC, and ILIAS\Repository\upload().

41  {
42  global $DIC;
43 
44  $this->irss = $DIC->resourceStorage();
45  $this->upload = $DIC->upload();
46  $this->data = $data;
47  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addEntryOfZipResourceToCollection()

ILIAS\Exercise\IRSS\CollectionWrapper::addEntryOfZipResourceToCollection ( string  $rid,
string  $entry,
ResourceCollection  $target_collection,
ResourceStakeholder  $target_stakeholder 
)

Definition at line 280 of file CollectionWrapper.php.

References ILIAS\ResourceStorage\Collection\ResourceCollection\add(), ILIAS\Filesystem\Stream\Streams\ofFileInsideZIP(), and ILIAS\Exercise\IRSS\CollectionWrapper\stream().

285  {
286  $entry_parts = explode("/", $entry);
287  $zip_path = $this->stream($rid)->getMetadata("uri");
288 
289  $stream = Streams::ofFileInsideZIP(
290  $zip_path,
291  $entry
292  );
293  $feedback_rid = $this->irss->manage()->stream(
294  $stream,
295  $target_stakeholder,
296  $entry_parts[2]
297  );
298  $target_collection->add($feedback_rid);
299  $this->irss->collection()->store($target_collection);
300  }
static ofFileInsideZIP(string $path_to_zip, string $path_inside_zip)
Definition: Streams.php:84
+ Here is the call graph for this function:

◆ clone()

ILIAS\Exercise\IRSS\CollectionWrapper::clone ( string  $from_rc_id)

Definition at line 250 of file CollectionWrapper.php.

252  : string {
253  if ($from_rc_id !== "") {
254  $cloned_rcid = $this->irss->collection()->clone($this->irss->collection()->id($from_rc_id));
255  return $cloned_rcid->serialize();
256  }
257  return "";
258  }

◆ cloneResource()

ILIAS\Exercise\IRSS\CollectionWrapper::cloneResource ( string  $from_rid)

Definition at line 260 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\getResourceIdForIdString().

262  : string {
263  if ($from_rid !== "") {
264  $cloned_rid = $this->irss->manage()->clone($this->getResourceIdForIdString($from_rid));
265  return $cloned_rid->serialize();
266  }
267  return "";
268  }
+ Here is the call graph for this function:

◆ copyResourcesToDir()

ILIAS\Exercise\IRSS\CollectionWrapper::copyResourcesToDir ( string  $rcid,
ResourceStakeholder  $stakeholder,
string  $dir 
)

Definition at line 80 of file CollectionWrapper.php.

84  {
85  $collection = $this->irss->collection()->get($this->irss->collection()->id($rcid));
86  foreach ($collection->getResourceIdentifications() as $rid) {
87  $info = $this->irss->manage()->getResource($rid)
88  ->getCurrentRevision()
89  ->getInformation();
90  $stream = $this->irss->consume()->stream($rid);
91  $stream->getContents();
92  }
93  }

◆ createEmptyCollection()

ILIAS\Exercise\IRSS\CollectionWrapper::createEmptyCollection ( )

Definition at line 59 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\getNewCollectionId().

59  : string
60  {
61  $new_id = $this->getNewCollectionId();
62  $new_collection = $this->irss->collection()->get($new_id);
63  $this->irss->collection()->store($new_collection);
64  return $new_id->serialize();
65  }
+ Here is the call graph for this function:

◆ deleteCollectionForIdString()

ILIAS\Exercise\IRSS\CollectionWrapper::deleteCollectionForIdString ( string  $rcid,
ResourceStakeholder  $stakeholder 
)

Definition at line 72 of file CollectionWrapper.php.

References $id.

75  : void {
76  $id = $this->irss->collection()->id($rcid);
77  $this->irss->collection()->remove($id, $stakeholder, true);
78  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ deleteResource()

ILIAS\Exercise\IRSS\CollectionWrapper::deleteResource ( string  $rid,
ResourceStakeholder  $stakeholder 
)

Definition at line 270 of file CollectionWrapper.php.

References $res, and ILIAS\Exercise\IRSS\CollectionWrapper\getResourceIdForIdString().

270  : void
271  {
272  if ($rid !== "") {
273  $res = $this->getResourceIdForIdString($rid);
274  if ($res) {
275  $this->irss->manage()->remove($this->getResourceIdForIdString($rid), $stakeholder);
276  }
277  }
278  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ deliverFile()

ILIAS\Exercise\IRSS\CollectionWrapper::deliverFile ( string  $rid)

Definition at line 214 of file CollectionWrapper.php.

References $id, and ILIAS\Exercise\IRSS\CollectionWrapper\getResourceIdForIdString().

214  : void
215  {
216  $id = $this->getResourceIdForIdString($rid);
217  if ($id) {
218  $this->irss->consume()->download($id)->run();
219  }
220  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getCollectionForIdString()

ILIAS\Exercise\IRSS\CollectionWrapper::getCollectionForIdString ( string  $rcid)

Definition at line 67 of file CollectionWrapper.php.

67  : ResourceCollection
68  {
69  return $this->irss->collection()->get($this->irss->collection()->id($rcid));
70  }

◆ getCollectionResourcesInfo()

ILIAS\Exercise\IRSS\CollectionWrapper::getCollectionResourcesInfo ( ResourceCollection  $collection)

Definition at line 231 of file CollectionWrapper.php.

References ILIAS\ResourceStorage\Collection\ResourceCollection\getResourceIdentifications().

233  : \Generator {
234  foreach ($collection->getResourceIdentifications() as $rid) {
235  $info = $this->irss->manage()->getResource($rid)
236  ->getCurrentRevision()
237  ->getInformation();
238  $src = $this->irss->consume()->src($rid)->getSrc();
239  yield $this->data->resourceInformation(
240  $rid->serialize(),
241  $info->getTitle(),
242  $info->getSize(),
243  $info->getCreationDate()->getTimestamp(),
244  $info->getMimeType(),
245  $src
246  );
247  }
248  }
+ Here is the call graph for this function:

◆ getNewCollectionId()

ILIAS\Exercise\IRSS\CollectionWrapper::getNewCollectionId ( )
protected

Definition at line 49 of file CollectionWrapper.php.

Referenced by ILIAS\Exercise\IRSS\CollectionWrapper\createEmptyCollection(), and ILIAS\Exercise\IRSS\CollectionWrapper\getNewCollectionIdAsString().

49  : ResourceCollectionIdentification
50  {
51  return $this->irss->collection()->id();
52  }
+ Here is the caller graph for this function:

◆ getNewCollectionIdAsString()

ILIAS\Exercise\IRSS\CollectionWrapper::getNewCollectionIdAsString ( )
protected

Definition at line 54 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\getNewCollectionId().

54  : string
55  {
56  return $this->getNewCollectionId()->serialize();
57  }
+ Here is the call graph for this function:

◆ getResourceIdForIdString()

ILIAS\Exercise\IRSS\CollectionWrapper::getResourceIdForIdString ( string  $rid)
protected

Definition at line 161 of file CollectionWrapper.php.

Referenced by ILIAS\Exercise\IRSS\CollectionWrapper\cloneResource(), ILIAS\Exercise\IRSS\CollectionWrapper\deleteResource(), ILIAS\Exercise\IRSS\CollectionWrapper\deliverFile(), and ILIAS\Exercise\IRSS\CollectionWrapper\stream().

161  : ?ResourceIdentification
162  {
163  return $this->irss->manage()->find($rid);
164  }
+ Here is the caller graph for this function:

◆ importFileFromLegacyUpload()

ILIAS\Exercise\IRSS\CollectionWrapper::importFileFromLegacyUpload ( array  $file_input,
ResourceStakeholder  $stakeholder 
)

Definition at line 166 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\$upload.

169  : string {
171 
172  if (is_array($file_input)) {
173  if (!$upload->hasBeenProcessed()) {
174  $upload->process();
175  }
176  foreach ($upload->getResults() as $name => $result) {
177  // we must check if these are files from this input
178  if ($name !== ($file_input["tmp_name"] ?? "")) {
179  continue;
180  }
181  // if the result is not OK, we skip it
182  if (!$result->isOK()) {
183  continue;
184  }
185 
186  // we store the file in the IRSS
187  $rid = $this->irss->manage()->upload(
188  $result,
189  $stakeholder
190  );
191  return $rid->serialize();
192  }
193  }
194  return "";
195  }
ILIAS FileUpload FileUpload $upload

◆ importFileFromUploadResult()

ILIAS\Exercise\IRSS\CollectionWrapper::importFileFromUploadResult ( UploadResult  $result,
ResourceStakeholder  $stakeholder 
)

Definition at line 197 of file CollectionWrapper.php.

References ILIAS\FileUpload\DTO\UploadResult\isOK().

200  : string {
201  // if the result is not OK, we skip it
202  if (!$result->isOK()) {
203  return "";
204  }
205 
206  // we store the file in the IRSS
207  $rid = $this->irss->manage()->upload(
208  $result,
209  $stakeholder
210  );
211  return $rid->serialize();
212  }
+ Here is the call graph for this function:

◆ importFilesFromDirectoryToCollection()

ILIAS\Exercise\IRSS\CollectionWrapper::importFilesFromDirectoryToCollection ( ResourceCollection  $collection,
string  $directory,
ResourceStakeholder  $stakeholder 
)

Definition at line 129 of file CollectionWrapper.php.

References Vendor\Package\$e, ILIAS\ResourceStorage\Collection\ResourceCollection\add(), ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath(), and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

133  : void {
134  $sourceFS = LegacyPathHelper::deriveFilesystemFrom($directory);
135  $sourceDir = LegacyPathHelper::createRelativePath($directory);
136 
137  // check if arguments are directories
138  if (!$sourceFS->hasDir($sourceDir)) {
139  return;
140  }
141 
142  $sourceList = $sourceFS->listContents($sourceDir, false);
143 
144  foreach ($sourceList as $item) {
145  if ($item->isDir()) {
146  continue;
147  }
148  try {
149  $stream = $sourceFS->readStream($item->getPath());
150  $rid = $this->irss->manage()->stream(
151  $stream,
152  $stakeholder
153  );
154  $collection->add($rid);
155  } catch (\ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
156  }
157  }
158  $this->irss->collection()->store($collection);
159  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
Class ChatMainBarProvider .
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

◆ importFilesFromLegacyUploadToCollection()

ILIAS\Exercise\IRSS\CollectionWrapper::importFilesFromLegacyUploadToCollection ( ResourceCollection  $collection,
array  $file_input,
ResourceStakeholder  $stakeholder 
)

Definition at line 95 of file CollectionWrapper.php.

References ILIAS\Exercise\IRSS\CollectionWrapper\$upload, and ILIAS\ResourceStorage\Collection\ResourceCollection\add().

99  : void {
101 
102  if (is_array($file_input)) {
103  if (!$upload->hasBeenProcessed()) {
104  $upload->process();
105  }
106  foreach ($upload->getResults() as $name => $result) {
107  // we must check if these are files from this input
108  if (!in_array($name, $file_input["tmp_name"] ?? [], true)) {
109  continue;
110  }
111  // if the result is not OK, we skip it
112  if (!$result->isOK()) {
113  continue;
114  }
115 
116  // we store the file in the IRSS
117  $rid = $this->irss->manage()->upload(
118  $result,
119  $stakeholder
120  );
121  // and add its identification to the collection
122  $collection->add($rid);
123  }
124  // we store the collection after all files have been added
125  $this->irss->collection()->store($collection);
126  }
127  }
ILIAS FileUpload FileUpload $upload
+ Here is the call graph for this function:

◆ stream()

ILIAS\Exercise\IRSS\CollectionWrapper::stream ( string  $rid)

Definition at line 222 of file CollectionWrapper.php.

References $id, and ILIAS\Exercise\IRSS\CollectionWrapper\getResourceIdForIdString().

Referenced by ILIAS\Exercise\IRSS\CollectionWrapper\addEntryOfZipResourceToCollection().

222  : ?FileStream
223  {
224  $id = $this->getResourceIdForIdString($rid);
225  if ($id) {
226  return $this->irss->consume()->stream($id)->getStream();
227  }
228  return null;
229  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data

InternalDataService ILIAS\Exercise\IRSS\CollectionWrapper::$data
protected

◆ $irss

ILIAS ResourceStorage Services ILIAS\Exercise\IRSS\CollectionWrapper::$irss
protected

Definition at line 37 of file CollectionWrapper.php.

◆ $upload


The documentation for this class was generated from the following file: