ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilExportZipBuiltObjective Class Reference
+ Inheritance diagram for ilExportZipBuiltObjective:
+ Collaboration diagram for ilExportZipBuiltObjective:

Public Member Functions

 __construct (Setup\Config $config)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 
 createTempDir ()
 
 __construct (Setup\Config $config)
 

Protected Member Functions

 deleteDirRecursive (string $path)
 

Protected Attributes

const FILENAME = "ILIAS_EXPORT.zip"
 
string $cwd
 
- Protected Attributes inherited from ilSetupObjective
Setup Config $config
 

Detailed Description

Definition at line 24 of file class.ilExportZipBuiltObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilExportZipBuiltObjective::__construct ( Setup\Config  $config)

Reimplemented from ilSetupObjective.

Definition at line 30 of file class.ilExportZipBuiltObjective.php.

31 {
33 $this->tmp_dir = $this->createTempDir();
34 if (is_null($this->tmp_dir)) {
35 throw new RuntimeException("Can't create temporary directory!");
36 }
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'");
39 }
40 $this->cwd = $_SERVER["PWD"];
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER, ilSetupObjective\$config, ILIAS\GlobalScreen\Provider\__construct(), and createTempDir().

+ Here is the call graph for this function:

Member Function Documentation

◆ achieve()

ilExportZipBuiltObjective::achieve ( Setup\Environment  $environment)

Definition at line 100 of file class.ilExportZipBuiltObjective.php.

100 : Setup\Environment
101 {
102 $meta = $environment->getConfigFor(ilExportMetadataGatheredObjective::EXPORT_META);
103 file_put_contents($this->tmp_dir . "/meta.txt", implode("\n", $meta) . "\n", FILE_APPEND);
104
105 // This will be recreated during import with new data for the imported instance.
106 $this->deleteDirRecursive($this->tmp_dir . "/web_data/default/client.ini.php");
107
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");
112
113 $this->deleteDirRecursive($this->tmp_dir . "/web_data");
114 $this->deleteDirRecursive($this->tmp_dir . "/Customizing");
115 $this->deleteDirRecursive($this->tmp_dir . "/public/data");
116 $this->deleteDirRecursive($this->tmp_dir . "/dump");
117
118 $this->addFolderToZip($this->tmp_dir, $this->cwd . "/" . self::FILENAME);
119
120 $this->deleteDirRecursive($this->tmp_dir);
121
122 return $environment;
123 }

References deleteDirRecursive(), ilExportMetadataGatheredObjective\EXPORT_META, and ILIAS\Setup\Environment\getConfigFor().

+ Here is the call graph for this function:

◆ createTempDir()

ilExportZipBuiltObjective::createTempDir ( )

Definition at line 188 of file class.ilExportZipBuiltObjective.php.

188 : ?string
189 {
190 $path = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . mt_rand() . microtime(true);
191 if (mkdir($path)) {
192 return $path;
193 }
194 return null;
195 }
$path
Definition: ltiservices.php:30

References $path.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ deleteDirRecursive()

ilExportZipBuiltObjective::deleteDirRecursive ( string  $path)
protected

Definition at line 165 of file class.ilExportZipBuiltObjective.php.

165 : void
166 {
167 if (is_file($path)) {
168 unlink($path);
169 return;
170 }
171
172 $files = new RecursiveIteratorIterator(
173 new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
174 RecursiveIteratorIterator::CHILD_FIRST
175 );
176
177 foreach ($files as $file_info) {
178 if ($file_info->isDir()) {
179 rmdir($file_info->getRealPath());
180 continue;
181 }
182 unlink($file_info->getRealPath());
183 }
184
185 rmdir($path);
186 }

References $path.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getHash()

ilExportZipBuiltObjective::getHash ( )

Definition at line 46 of file class.ilExportZipBuiltObjective.php.

46 : string
47 {
48 return hash("sha256", self::class);
49 }

◆ getLabel()

ilExportZipBuiltObjective::getLabel ( )

Definition at line 54 of file class.ilExportZipBuiltObjective.php.

54 : string
55 {
56 return "Export ILIAS to $this->cwd/" . self::FILENAME;
57 }

References FILENAME.

◆ getPreconditions()

ilExportZipBuiltObjective::getPreconditions ( Setup\Environment  $environment)

Definition at line 70 of file class.ilExportZipBuiltObjective.php.

70 : array
71 {
72 $dumper = new MysqlIfsnopDumper($this->config->getExportHooksPath());
73
74 return [
76 new Setup\ObjectiveCollection(
77 "",
78 false,
81 $this->tmp_dir . "/public/data/"
82 ),
83 new ilFileSystemDirectoryCopiedRecursivelyObjective("", $this->tmp_dir . "/public/data", true)
84 ),
87 $this->tmp_dir . "/web_data/"
88 ),
89 new ilFileSystemDirectoryCopiedRecursivelyObjective("public/data", $this->tmp_dir . "/web_data"),
90 ),
91 ),
92 new ilFileSystemDirectoryCopiedRecursivelyObjective("Customizing", $this->tmp_dir . "/Customizing"),
93 new ilDatabaseDumpedToDirectoryObjective($this->tmp_dir . "/dump", $dumper)
94 ];
95 }
A wrapper around an objective that adds some preconditions.

◆ isApplicable()

ilExportZipBuiltObjective::isApplicable ( Setup\Environment  $environment)

@inheritDoc

Definition at line 128 of file class.ilExportZipBuiltObjective.php.

128 : bool
129 {
130 return is_writable($this->cwd);
131 }

◆ isNotable()

ilExportZipBuiltObjective::isNotable ( )

Definition at line 62 of file class.ilExportZipBuiltObjective.php.

62 : bool
63 {
64 return true;
65 }

Field Documentation

◆ $cwd

string ilExportZipBuiltObjective::$cwd
protected

Definition at line 28 of file class.ilExportZipBuiltObjective.php.

◆ FILENAME

const ilExportZipBuiltObjective::FILENAME = "ILIAS_EXPORT.zip"
protected

Definition at line 26 of file class.ilExportZipBuiltObjective.php.

Referenced by getLabel().


The documentation for this class was generated from the following file: