ILIAS  release_8 Revision v8.24
class.ilFileSystemComponentDataDirectoryCreatedObjective.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\Setup;
20
22{
23 public const DATADIR = 1;
24 public const WEBDIR = 2;
25
26 protected string $component_dir;
27
28 protected int $base_location;
29
30
31 public function __construct(
32 string $component_dir,
33 int $base_location = self::DATADIR
34 ) {
36
37 $this->component_dir = $component_dir;
38 $this->base_location = $base_location;
39 }
40
41
42 public function getHash(): string
43 {
44 return hash("sha256", self::class . "::" . $this->component_dir . $this->base_location);
45 }
46
47 protected function buildPath(Setup\Environment $environment): ?string
48 {
49 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
50 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
51
52 if ($ini === null || $client_id === null) {
53 return null;
54 }
55
56 if ($this->base_location === self::DATADIR) {
57 $data_dir = $ini->readVariable('clients', 'datadir');
58 } elseif ($this->base_location === self::WEBDIR) {
59 $data_dir = dirname(__DIR__, 4) . "/data";
60 }
61 if (!isset($data_dir)) {
62 throw new LogicException('cannot determine base directory');
63 }
64
65 $client_data_dir = $data_dir . '/' . $client_id;
66 $new_dir = $client_data_dir . '/' . $this->component_dir;
67 return $new_dir;
68 }
69
73 public function getPreconditions(Setup\Environment $environment): array
74 {
75 // case if it is a fresh ILIAS installation
76 if ($environment->hasConfigFor("filesystem")) {
77 $config = $environment->getConfigFor("filesystem");
78 return [
80 ];
81 }
82
83 // case if ILIAS is already installed
84 return [
86 ];
87 }
88
89 public function achieve(Setup\Environment $environment): Setup\Environment
90 {
91 $this->path = $this->buildPath($environment);
92 return parent::achieve($environment);
93 }
94
98 public function isApplicable(Setup\Environment $environment): bool
99 {
100 if (($path = $this->buildPath($environment)) === null) {
101 return false;
102 }
103 $this->path = $path;
104 return parent::isApplicable($environment);
105 }
106}
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$client_id
Definition: ltiauth.php:68
$path
Definition: ltiservices.php:32
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4