ILIAS  release_8 Revision v8.24
class.ilZipJob.php
Go to the documentation of this file.
1<?php
23
30class 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}
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
Component logger with individual log levels by component id.
Description of class class.
getOutputType()
@inheritDoc
ilLogger $logger
run(array $input, \ILIAS\BackgroundTasks\Observer $observer)
@inheritDoc
getInputTypes()
@inheritDoc
isStateless()
@inheritDoc
__construct()
Construct.
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
global $DIC
Definition: feed.php:28
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47
Class ChatMainBarProvider \MainMenu\Provider.