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

Public Member Functions

 __construct (protected \ilFileSystemSetupConfig $config)
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 @inheritDoc More...
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 Get to know whether the objective is applicable. More...
 

Protected Member Functions

 deleteRecursive (string $path, bool $delete_base_dir=false)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileSystemDirectoriesCreatedObjective::__construct ( protected \ilFileSystemSetupConfig  $config)

Definition at line 31 of file class.ilFileSystemDirectoriesCreatedObjective.php.

32 {
33 }

Member Function Documentation

◆ achieve()

ilFileSystemDirectoriesCreatedObjective::achieve ( Environment  $environment)

Objectives can be achieved.

They might add resources to the environment when they have been achieved.

This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources.

Implements ILIAS\Setup\Objective.

Definition at line 110 of file class.ilFileSystemDirectoriesCreatedObjective.php.

111 {
112 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
113
114 $ini->setVariable("clients", "datadir", $this->config->getDataDir());
115 if (!$ini->write()) {
116 throw new UnachievableException("Could not write ilias.ini.php");
117 }
118
119 if ($environment->hasConfigFor("tmp_dir")) {
120 $tmp_dir = $environment->getConfigFor("tmp_dir");
121 if (!is_null($tmp_dir)) {
122 $this->deleteRecursive($tmp_dir, true);
123 }
124 }
125
126 return $environment;
127 }
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
hasConfigFor(string $component)
getConfigFor(string $component)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$ini
Definition: raiseError.php:20

References $ini, deleteRecursive(), ILIAS\Setup\Environment\getConfigFor(), ILIAS\Setup\Environment\getResource(), and ILIAS\Setup\Environment\hasConfigFor().

+ Here is the call graph for this function:

◆ deleteRecursive()

ilFileSystemDirectoriesCreatedObjective::deleteRecursive ( string  $path,
bool  $delete_base_dir = false 
)
protected

Definition at line 143 of file class.ilFileSystemDirectoriesCreatedObjective.php.

143 : void
144 {
145 if (is_file($path)) {
146 unlink($path);
147 return;
148 }
149
150 $files = new RecursiveIteratorIterator(
151 new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
152 RecursiveIteratorIterator::CHILD_FIRST
153 );
154
155 foreach ($files as $file_info) {
156 if ($file_info->isDir()) {
157 rmdir($file_info->getRealPath());
158 continue;
159 }
160 unlink($file_info->getRealPath());
161 }
162
163 if ($delete_base_dir) {
164 rmdir($path);
165 }
166 }
$path
Definition: ltiservices.php:30

References $path.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getHash()

ilFileSystemDirectoriesCreatedObjective::getHash ( )

Get a hash for this objective.

The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 35 of file class.ilFileSystemDirectoriesCreatedObjective.php.

35 : string
36 {
37 return hash("sha256", self::class);
38 }

◆ getLabel()

ilFileSystemDirectoriesCreatedObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 40 of file class.ilFileSystemDirectoriesCreatedObjective.php.

40 : string
41 {
42 return "ILIAS directories are created";
43 }

◆ getPreconditions()

ilFileSystemDirectoriesCreatedObjective::getPreconditions ( Environment  $environment)
Returns
DirectoryCreatedObjective[]|\ilIniFilesPopulatedObjective[]

Implements ILIAS\Setup\Objective.

Definition at line 53 of file class.ilFileSystemDirectoriesCreatedObjective.php.

53 : array
54 {
55 $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
56 $data_dir = $this->config->getDataDir();
57 $web_dir = dirname(__DIR__, 5) . "/public/data";
58 $root = dirname(__DIR__, 5);
59
60 $client_data_dir = $data_dir . '/' . $client_id;
61 $client_web_dir = $web_dir . '/' . $client_id;
62
63 $web_dir_objective = new DirectoryCreatedObjective($client_web_dir);
64 $data_dir_objective = new DirectoryCreatedObjective($client_data_dir);
65 $customizing_dir_objective = new NullObjective();
66
67 if ($environment->hasConfigFor(InstallCommand::IMPORT)) {
68 $tmp_dir = $environment->getConfigFor("tmp_dir");
69
70 $web_dir_objective = new ObjectiveWithPreconditions(
72 $web_dir
73 ),
75 $tmp_dir . DIRECTORY_SEPARATOR . "web_data",
76 $web_dir,
77 false,
78 true
79 )
80 );
81 $data_dir_objective = new ObjectiveWithPreconditions(
84 ),
86 $tmp_dir . DIRECTORY_SEPARATOR . "data",
88 false,
89 true
90 )
91 );
92 $customizing_dir_objective = new ilFileSystemDirectoryCopiedRecursivelyObjective(
93 $tmp_dir . DIRECTORY_SEPARATOR . "Customizing",
94 $root . "/public/Customizing",
95 false,
96 true
97 );
98 }
99
100 return [
103 new DirectoryCreatedObjective($web_dir),
104 $web_dir_objective,
105 $data_dir_objective,
106 $customizing_dir_objective
107 ];
108 }
A non-objective, nothing to do to achieve it...
A wrapper around an objective that adds some preconditions.
$client_id
Definition: ltiauth.php:67

References $client_id, $data_dir, ILIAS\Setup\Environment\getConfigFor(), ILIAS\Setup\Environment\getResource(), and ILIAS\Setup\Environment\hasConfigFor().

+ Here is the call graph for this function:

◆ isApplicable()

ilFileSystemDirectoriesCreatedObjective::isApplicable ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 132 of file class.ilFileSystemDirectoriesCreatedObjective.php.

132 : bool
133 {
134 if ($environment->hasConfigFor(InstallCommand::IMPORT)) {
135 return true;
136 }
137
138 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
139
140 return $ini->readVariable("clients", "datadir") !== $this->config->getDataDir();
141 }

References $ini, ILIAS\Setup\Environment\getResource(), and ILIAS\Setup\Environment\hasConfigFor().

+ Here is the call graph for this function:

◆ isNotable()

ilFileSystemDirectoriesCreatedObjective::isNotable ( )

Get to know if this is an interesting objective for a human.

Implements ILIAS\Setup\Objective.

Definition at line 45 of file class.ilFileSystemDirectoriesCreatedObjective.php.

45 : bool
46 {
47 return true;
48 }

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