19declare(strict_types=1);
34 if (is_null($this->tmp_dir)) {
35 throw new RuntimeException(
"Can't create temporary directory!");
37 if(! array_key_exists(
'PWD',
$_SERVER)) {
38 throw new RuntimeException(
"Can't get to current directory. \nIf you ran the script using 'sudo', please try using 'sudo -s'");
48 return hash(
"sha256", self::class);
81 $this->tmp_dir .
"/public/data/"
87 $this->tmp_dir .
"/web_data/"
103 file_put_contents($this->tmp_dir .
"/meta.txt", implode(
"\n", $meta) .
"\n", FILE_APPEND);
108 $this->addFolderToZip($this->tmp_dir .
"/web_data", $this->tmp_dir .
"/web_data.zip");
109 $this->addFolderToZip($this->tmp_dir .
"/Customizing", $this->tmp_dir .
"/Customizing.zip");
110 $this->addFolderToZip($this->tmp_dir .
"/public/data", $this->tmp_dir .
"/data.zip");
111 $this->addFolderToZip($this->tmp_dir .
"/dump", $this->tmp_dir .
"/dump.zip");
118 $this->addFolderToZip($this->tmp_dir, $this->cwd .
"/" . self::FILENAME);
130 return is_writable($this->cwd);
133 protected function addFolderToZip($source, $destination, $flags = ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE): bool
135 if (!file_exists($source)) {
136 throw new RuntimeException(
"File does not exist: " . $source);
139 $zip =
new ZipArchive();
140 if (!$zip->open($destination, $flags)) {
141 throw new RuntimeException(
"Cannot open zip archive: " . $destination);
145 $files =
new RecursiveIteratorIterator(
146 new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS),
147 RecursiveIteratorIterator::SELF_FIRST
150 $sourceWithSeparator = $source . DIRECTORY_SEPARATOR;
153 foreach ($files as $file) {
154 if ($file->isDir()) {
155 $zip->addEmptyDir(str_replace($sourceWithSeparator,
'', $file . DIRECTORY_SEPARATOR));
157 if ($file->isFile()) {
158 $zip->addFile($file->getPathname(), str_replace($sourceWithSeparator,
'', $file->getPathname()));
162 return $zip->close();
167 if (is_file(
$path)) {
172 $files =
new RecursiveIteratorIterator(
173 new RecursiveDirectoryIterator(
$path, FilesystemIterator::SKIP_DOTS),
174 RecursiveIteratorIterator::CHILD_FIRST
177 foreach ($files as $file_info) {
178 if ($file_info->isDir()) {
179 rmdir($file_info->getRealPath());
182 unlink($file_info->getRealPath());
190 $path = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . mt_rand() . microtime(
true);
A objective collection is a objective that is achieved once all subobjectives are achieved.
A wrapper around an objective that adds some preconditions.
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
__construct(Setup\Config $config)
deleteDirRecursive(string $path)
isApplicable(Setup\Environment $environment)
@inheritDoc
A configuration for the setup.
An environment holds resources to be used in the setup process.
getConfigFor(string $component)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...