19declare(strict_types=1);
25trait FileDataRCHandling
30 protected function getCurrentCollection(
34 set_error_handler(static function ($severity, $message, $file, $line): void {
35 throw new ErrorException($message, $severity, 0, $file, $line);
40 $file_system =
$DIC->filesystem()->storage();
41 $rcid = $this->storage->collection()->id();
42 $collection = $this->storage->collection()->get($rcid);
43 foreach ($path_to_files as $path_to_file) {
44 $base_dir = (new \ILIAS\FileDelivery\Setup\BaseDirObjective())
::get();
45 $path_to_file = str_replace($base_dir,
'/', $path_to_file);
46 $rid = $this->storage->manage()->stream(
47 $file_system->readStream($path_to_file),
49 md5(basename($path_to_file))
51 $collection->add($rid);
53 $this->storage->collection()->store($collection);
54 }
catch (Exception
$e) {
55 throw new Exception(
"Storing file into collection failed: " .
$e->getMessage());
57 restore_error_handler();
67 public function filesFromLegacyToIRSS(array $mail_data): array
71 foreach ($mail_data[
'attachments'] as $file) {
72 $path_to_files[] = $this->fdm->getAbsoluteAttachmentPoolPathByFilename($file);
75 foreach ($collection->getResourceIdentifications() as $rcid) {
76 $files[] = $rcid->serialize();
89 foreach ($mail_data as $attachment) {
90 $path_to_files[] = $this->fdm->getAbsoluteAttachmentPoolPathByFilename($attachment);
93 $rcid = $collection->getIdentification();
104 $collection = $this->storage->collection()->get($identification);
105 $all_ids = $collection->getResourceIdentifications();
106 foreach ($all_ids as
$id) {
107 $files[] =
$id->serialize();
117 protected function handleAttachments(array $attachments): array
120 foreach ($attachments as $attachment) {
121 $info = $this->upload_handler->getInfoResult($attachment);
122 if (
$info->getFileIdentifier() !==
'unknown') {
123 $src = $this->upload_handler->getStreamConsumer($attachment);
124 $stored = $this->fdm->storeAsAttachment(
126 (
string) $src->getStream()
128 if ($stored ===
false) {
129 throw new Exception(
"File '" .
$info->getName() .
"' could not be stored");
132 $this->upload_handler->removeFileForIdentifier($attachment);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Class ResourceCollection.
Class ResourceCollectionIdentification.
static _sanitizeFilemame(string $a_filename)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.