ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DownloadAllBackgroundTask.php
Go to the documentation of this file.
1<?php
2
20
22
29{
30 protected int $mcst_ref_id = 0;
31 protected int $mcst_id = 0;
32 protected ?int $user_id = null;
35 protected \ilLanguage $lng;
36 private ?\ilLogger $logger = null;
37
38 public function __construct(
39 int $a_usr_id,
40 int $a_mcst_ref_id,
41 int $a_mcst_id
42 ) {
43 global $DIC;
44
45 $this->user_id = $a_usr_id;
46 $this->mcst_ref_id = $a_mcst_ref_id;
47 $this->mcst_id = $a_mcst_id;
48
49 $this->task_factory = $DIC->backgroundTasks()->taskFactory();
50 $this->task_manager = $DIC->backgroundTasks()->taskManager();
51 $this->logger = $DIC->logger()->mcst();
52 }
53
54 public function run(): bool
55 {
56 $bucket = new BasicBucket();
57 $bucket->setUserId($this->user_id);
58
59 $this->logger->debug("* Create task 'collect_data_job' using the following values:");
60 $this->logger->debug("job class = " . DownloadAllCollectFilesJob::class);
61 $this->logger->debug("mcst_id = " . $this->mcst_id . ", mcst_ref_id = " . $this->mcst_ref_id . ", user_id = " . (int) $this->user_id);
62
63 $collect_data_job = $this->task_factory->createTask(
64 DownloadAllCollectFilesJob::class,
65 [
66 (int) $this->user_id,
67 (int) $this->mcst_ref_id
68 ]
69 );
70
71 $this->logger->debug("* Create task 'zip job' using the following values:");
72 $this->logger->debug("job class = " . DownloadAllZipJob::class);
73 $this->logger->debug("sending as input the task called->collect_data_job");
74
75 $zip_job = $this->task_factory->createTask(DownloadAllZipJob::class, [$collect_data_job]);
76
77 $download_name = \ilFileUtils::getASCIIFilename(\ilObject::_lookupTitle($this->mcst_id));
78 $bucket->setTitle($download_name);
79
80 $this->logger->debug("* Create task 'download_interaction' using the following values:");
81 $this->logger->debug("job class = " . DownloadAllZipInteraction::class);
82 $this->logger->debug("download_name which is the same as bucket title = " . $download_name . " + the zip_job task");
83 // see comments here -> https://github.com/leifos-gmbh/ILIAS/commit/df6fc44a4c85da33bd8dd5b391a396349e7fa68f
84 $download_interaction = $this->task_factory->createTask(DownloadAllZipInteraction::class, [$zip_job, $download_name]);
85
86 //download name
87 $bucket->setTask($download_interaction);
88 $this->task_manager->run($bucket);
89 return true;
90 }
91}
__construct(int $a_usr_id, int $a_mcst_ref_id, int $a_mcst_id)
static getASCIIFilename(string $a_filename)
Component logger with individual log levels by component id.
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26