ILIAS  release_8 Revision v8.24
ClientIdReadObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Setup\Objective;
22
23use ILIAS\Setup;
24
33{
39 public function getHash(): string
40 {
41 return hash("sha256", self::class);
42 }
43
47 public function getLabel(): string
48 {
49 return "Read client-id from data-directory.";
50 }
51
57 public function isNotable(): bool
58 {
59 return false;
60 }
61
65 public function getPreconditions(Setup\Environment $environment): array
66 {
67 return [];
68 }
69
73 public function achieve(Setup\Environment $environment): Setup\Environment
74 {
75 $dir = $this->getDataDirectoryPath();
76 $candidates = array_filter(
77 $this->scanDirectory($dir),
78 function ($c) use ($dir): bool {
79 if ($c == "." || $c == "..") {
80 return false;
81 }
82 return $this->isDirectory($dir . "/" . $c);
83 }
84 );
85
86 if (count($candidates) == 0) {
88 "There are no directories in the webdata-dir at '$dir'. " .
89 "Probably ILIAS is not installed."
90 );
91 }
92
93 if (count($candidates) != 1) {
94 $ilias_version = ILIAS_VERSION_NUMERIC;
95
97 "There is more than one directory in the webdata-dir at '$dir'. " .
98 "Probably this is an ILIAS installation that uses clients. Clients " .
99 "are not supported anymore since ILIAS $ilias_version " .
100 "(see: https://docu.ilias.de/goto.php?target=wiki_1357_Setup_-_Abandon_Multi_Client)"
101 );
102 }
103
104 $client_id = array_shift($candidates);
105 return $environment->withResource(Setup\Environment::RESOURCE_CLIENT_ID, $client_id);
106 }
107
108 protected function getDataDirectoryPath(): string
109 {
110 return dirname(__DIR__, 3) . "/data";
111 }
112
113 protected function scanDirectory(string $path): array
114 {
115 return scandir($path);
116 }
117
118 protected function isDirectory(string $path): bool
119 {
120 return is_dir($path);
121 }
122
126 public function isApplicable(Setup\Environment $environment): bool
127 {
128 return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID) === null;
129 }
130}
Read the client id of the installation from the data directory.
achieve(Setup\Environment $environment)
@inheritdocs
getPreconditions(Setup\Environment $environment)
@inheritdocs
isApplicable(Setup\Environment $environment)
@inheritDoc
Signals that some goal won't be achievable by actions of the system ever.
string $client_id
Definition: class.ilias.php:22
$c
Definition: cli.php:38
const ILIAS_VERSION_NUMERIC
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
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...