ILIAS  release_8 Revision v8.23
class.ilZipJob.php
Go to the documentation of this file.
1 <?php
23 
30 class ilZipJob extends AbstractJob
31 {
32  private ?ilLogger $logger;
33 
34 
38  public function __construct()
39  {
40  global $DIC;
41  $this->logger = $DIC->logger()->cal();
42  }
43 
44 
48  public function getInputTypes(): array
49  {
50  return
51  [
52  new SingleType(StringValue::class),
53  ];
54  }
55 
56 
60  public function getOutputType(): Type
61  {
62  return new SingleType(StringValue::class);
63  }
64 
65 
69  public function isStateless(): bool
70  {
71  return true;
72  }
73 
74 
79  public function run(array $input, \ILIAS\BackgroundTasks\Observer $observer): Value
80  {
81  $this->logger->debug('Start zipping input dir!');
82  $this->logger->dump($input);
83  $tmpdir = rtrim($input[0]->getValue(), "/");
84  $this->logger->debug('Zipping directory:' . $tmpdir);
85  $zip_name = $tmpdir . '.zip';
86  ilFileUtils::zip($tmpdir, $zip_name);
87 
88  // delete temp directory
89  ilFileUtils::delDir($tmpdir);
90 
91  $zip_file_name = new StringValue();
92  $zip_file_name->setValue($zip_name);
93 
94  return $zip_file_name;
95  }
96 
97 
102  {
103  return 30;
104  }
105 }
__construct()
Construct.
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47
Class ChatMainBarProvider .
run(array $input, \ILIAS\BackgroundTasks\Observer $observer)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
ilLogger $logger
Description of class class.