ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilFileSystemDirectoriesCreatedObjective.php
Go to the documentation of this file.
1 <?php
2 
3 use ILIAS\Setup;
4 
5 /******************************************************************************
6  *
7  * This file is part of ILIAS, a powerful learning management system.
8  *
9  * ILIAS is licensed with the GPL-3.0, you should have received a copy
10  * of said license along with the source code.
11  *
12  * If this is not the case or you just want to try ILIAS, you'll find
13  * us at:
14  * https://www.ilias.de
15  * https://github.com/ILIAS-eLearning
16  *
17  *****************************************************************************/
18 class ilFileSystemDirectoriesCreatedObjective implements Setup\Objective
19 {
20  protected \ilFileSystemSetupConfig $config;
21 
22  public function __construct(
24  ) {
25  $this->config = $config;
26  }
27 
28  public function getHash(): string
29  {
30  return hash("sha256", self::class);
31  }
32 
33  public function getLabel(): string
34  {
35  return "ILIAS directories are created";
36  }
37 
38  public function isNotable(): bool
39  {
40  return false;
41  }
42 
46  public function getPreconditions(Setup\Environment $environment): array
47  {
48  $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
49  $data_dir = $this->config->getDataDir();
50  $web_dir = dirname(__DIR__, 4) . "/data";
51 
52  $client_data_dir = $data_dir . '/' . $client_id;
53  $client_web_dir = $web_dir . '/' . $client_id;
54 
55  return [
57  new Setup\Objective\DirectoryCreatedObjective($data_dir),
58  new Setup\Objective\DirectoryCreatedObjective($web_dir),
59  new Setup\Objective\DirectoryCreatedObjective(
60  $client_web_dir
61  ),
62  new Setup\Objective\DirectoryCreatedObjective(
63  $client_data_dir
64  )
65  ];
66  }
67 
68  public function achieve(Setup\Environment $environment): Setup\Environment
69  {
70  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
71 
72  $ini->setVariable("clients", "datadir", $this->config->getDataDir());
73 
74  if (!$ini->write()) {
75  throw new Setup\UnachievableException("Could not write ilias.ini.php");
76  }
77 
78  return $environment;
79  }
80 
84  public function isApplicable(Setup\Environment $environment): bool
85  {
86  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
87 
88  return $ini->readVariable("clients", "datadir") !== $this->config->getDataDir();
89  }
90 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
$client_id
Definition: ltiauth.php:68
$ini
Definition: raiseError.php:4