ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIniFilesPopulatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 public function getHash(): string
26 {
27 return hash("sha256", self::class);
28 }
29
30 public function getLabel(): string
31 {
32 return "The ilias.ini.php and client.ini.php are populated.";
33 }
34
35 public function isNotable(): bool
36 {
37 return true;
38 }
39
40 public function getPreconditions(Setup\Environment $environment): array
41 {
42 $client_id = (string) $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
43 if ($client_id === null) {
44 throw new \LogicException(
45 "Expected a client_id in the environment."
46 );
47 }
48 $client_dir = $this->getClientDir($client_id);
49
50 // TODO: This shows an unfortunate connection between the webdir and the
51 // client.ini.php. Why does the client.ini reside in the webdir? If we
52 // remove the client-feature, the client-ini will go away...
53 return [
54 new Setup\Objective\DirectoryCreatedObjective(dirname(__DIR__, 4) . "/public/data"),
58 ];
59 }
60
61 public function achieve(Setup\Environment $environment): Setup\Environment
62 {
63 $client_id = (string) $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
64
65 $path = $this->getILIASIniPath();
66 if (!file_exists($path)) {
67 $ini = new ilIniFile($path);
68 $ini->GROUPS = parse_ini_file(__DIR__ . "/../ilias.master.ini.php", true);
69 $ini->write();
70 $environment = $environment
71 ->withResource(Setup\Environment::RESOURCE_ILIAS_INI, $ini);
72 }
73
75 if (!file_exists($path)) {
76 $client_ini = new ilIniFile($path);
77 $client_ini->GROUPS = parse_ini_file(__DIR__ . "/../client.master.ini.php", true);
78 $client_ini->write();
79 $environment = $environment
80 ->withResource(Setup\Environment::RESOURCE_CLIENT_INI, $client_ini);
81 }
82
83 return $environment;
84 }
85
89 public function isApplicable(Setup\Environment $environment): bool
90 {
91 $client_id = (string) $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
92
93 return !file_exists($this->getILIASIniPath())
94 || !file_exists($this->getClientIniPath($client_id));
95 }
96
97 protected function getClientDir(string $client_id): string
98 {
99 return dirname(__DIR__, 4) . "/public/data/" . $client_id;
100 }
101
102 protected function getClientIniPath(string $client_id): string
103 {
104 return $this->getClientDir($client_id) . "/client.ini.php";
105 }
106
107 protected function getILIASIniPath(): string
108 {
109 return dirname(__DIR__, 4) . "/ilias.ini.php";
110 }
111}
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
isApplicable(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
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:67
$path
Definition: ltiservices.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:20