ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BaseDirObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
31{
32 public const BASE_DIR = './src/FileDelivery/artifacts/base_dir.php';
33
34 protected array $data = [];
35
36 public function getArtifactPath(): string
37 {
38 return self::BASE_DIR;
39 }
40
41 #[\Override]
42 public function buildIn(Environment $env): Artifact
43 {
45 if ($ilias_ini instanceof \ilIniFile) {
46 $base_dir = $ilias_ini->readVariable('clients', 'datadir');
47 $client_id = $ilias_ini->readVariable('clients', 'default');
48 if (!empty($base_dir) && !empty($client_id)) {
49 $this->data['base_dir'] = rtrim(rtrim($base_dir, '/') . '/' . $client_id, '/') . '/';
50 }
51 }
52 return $this->build();
53 }
54
55 public function getArtifactName(): string
56 {
57 return 'base_dir';
58 }
59
60 public function build(): Artifact
61 {
62 return new ArrayArtifact($this->data);
63 }
64
65 #[\Override]
66 public function getPreconditions(Environment $environment): array
67 {
68 return [
69 new \ilIniFilesLoadedObjective(),
70 ];
71 }
72
73 public static function get(): ?string
74 {
75 static $base;
76
77 if ($base !== null) {
78 return $base;
79 }
80
81 if (is_readable(self::PATH())) {
82 $data = require self::PATH();
83 }
84
85 return $base = $data['base_dir'] ?? null;
86 }
87}
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
An array as an artifact.
string $client_id
Definition: class.ilias.php:36
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:28
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.