ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 getArtifactName(): string
54  {
55  return 'base_dir';
56  }
57 
58  public function build(): Setup\Artifact
59  {
60  return new Setup\Artifact\ArrayArtifact($this->data);
61  }
62 
63  public function getPreconditions(Setup\Environment $environment): array
64  {
65  return [
66  new \ilIniFilesLoadedObjective(),
67  ];
68  }
69 
70  public static function get(): ?string
71  {
72  static $base;
73 
74  if ($base !== null) {
75  return $base;
76  }
77 
78  if (is_readable(self::PATH())) {
79  $data = require self::PATH();
80  }
81 
82  return $base = $data['base_dir'] ?? null;
83  }
84 }
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:36