ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilZipJob.php
Go to the documentation of this file.
1<?php
2
26
33class ilZipJob extends AbstractJob
34{
35 private ?ilLogger $logger;
37
41 public function __construct()
42 {
43 global $DIC;
44 $this->logger = $DIC->logger()->cal();
45 $this->archives = $DIC->archives();
46 }
47
48
52 public function getInputTypes(): array
53 {
54 return
55 [
56 new SingleType(StringValue::class),
57 ];
58 }
59
60
64 public function getOutputType(): Type
65 {
66 return new SingleType(StringValue::class);
67 }
68
69
73 public function isStateless(): bool
74 {
75 return true;
76 }
77
78
83 public function run(array $input, Observer $observer): Value
84 {
85 $this->logger->debug('Start zipping input dir!');
86 $this->logger->dump($input);
87 $string = $input[0]->getValue();
88 $tmpdir = rtrim((string) $string, "/");
89 $this->logger->debug('Zipping directory:' . $tmpdir);
90 $zip_name = $tmpdir . '.zip';
91
92 $zip = $this->archives->zip([]);
93 $zip->addDirectory($tmpdir);
94 $zip_stream = $zip->get();
95 stream_copy_to_stream($zip_stream->detach(), fopen($zip_name, 'wb')); // we currently have to write to disk
96
97 // delete temp directory
98 ilFileUtils::delDir($tmpdir);
99
100 $zip_file_name = new StringValue();
101 $zip_file_name->setValue($zip_name);
102
103 return $zip_file_name;
104 }
105
106
111 {
112 return 30;
113 }
114}
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.
Archives $archives
run(array $input, Observer $observer)
@inheritDoc
getOutputType()
@inheritDoc
ilLogger $logger
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: shib_login.php:26