ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
BaseDirObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\FileDelivery\Setup;
22 
24 use ILIAS\Setup;
25 
30 {
31  public const BASE_DIR = './src/FileDelivery/artifacts/base_dir.php';
32 
33  protected array $data = [];
34 
35  public function getArtifactPath(): string
36  {
37  return self::BASE_DIR;
38  }
39 
40  public function buildIn(Setup\Environment $env): Setup\Artifact
41  {
42  $ilias_ini = $env->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
43  if ($ilias_ini instanceof \ilIniFile) {
44  $base_dir = $ilias_ini->readVariable('clients', 'datadir');
45  $client_id = $ilias_ini->readVariable('clients', 'default');
46  if (!empty($base_dir) && !empty($client_id)) {
47  $this->data['base_dir'] = rtrim(rtrim($base_dir, '/') . '/' . $client_id, '/') . '/';
48  }
49  }
50  return $this->build();
51  }
52 
53  public function build(): Setup\Artifact
54  {
55  return new Setup\Artifact\ArrayArtifact($this->data);
56  }
57 
58  public function getPreconditions(Setup\Environment $environment): array
59  {
60  return [
61  new \ilIniFilesLoadedObjective(),
62  ];
63  }
64 
65  public static function get(): ?string
66  {
67  static $base;
68 
69  if (isset($base)) {
70  return $base;
71  }
72 
73  if (is_readable(self::BASE_DIR)) {
74  $data = require self::BASE_DIR;
75  }
76 
77  return $base = $data['base_dir'] ?? null;
78  }
79 }
This is an objective to build some artifact.
getPreconditions(Setup\Environment $environment)
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
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:27
string $client_id
Definition: class.ilias.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...