ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilOverwritesExistingInstallationConfirmed.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
12{
16 public function getHash() : string
17 {
18 return hash(
19 "sha256",
20 get_class($this)
21 );
22 }
23
27 public function getLabel() : string
28 {
29 return "Confirm that an existing installation should be overwritten if applicable.";
30 }
31
35 public function isNotable() : bool
36 {
37 return false;
38 }
39
43 public function getPreconditions(Setup\Environment $environment) : array
44 {
45 return [];
46 }
47
51 public function achieve(Setup\Environment $environment) : Setup\Environment
52 {
53 if (!$this->iniExists() && !$this->clientIniExists()) {
54 return $environment;
55 }
56
57 $admin_interaction = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
58
59 $message =
60 "An installation already seems to exist in this location. Using this command\n" .
61 "might change your installation in unexpected ways. Are you sure that you\n" .
62 "want to proceed?";
63
64 if (!$admin_interaction->confirmOrDeny($message)) {
66 }
67
68 return $environment;
69 }
70
71 public function iniExists()
72 {
73 return file_exists(dirname(__DIR__, 2) . "/ilias.ini.php");
74 }
75
76 public function clientIniExists()
77 {
78 return file_exists($this->getClientDir() . "/client.ini.php");
79 }
80
81 protected function getClientDir() : string
82 {
83 return dirname(__DIR__, 2) . "/data/" . $this->config->getClientId();
84 }
85}
An exception for terminatinating execution or to throw for unit testing.
Signals that a necessary confirmation from the admin is missing.
There seems to already exist an ILIAS installation, an interaction with it should be confirmed.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$message
Definition: xapiexit.php:14