ILIAS  release_7 Revision v7.30-3-g800a261c036
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.";
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. Also, the command might not\n".
62 "work as expected. Are you sure that you want to proceed anyway?";
63
64 if (!$admin_interaction->confirmOrDeny($message)) {
66 }
67
68 return $environment;
69 }
70
74 public function isApplicable(Setup\Environment $environment) : bool
75 {
76 return $this->iniExists() || $this->clientIniExists();
77 }
78
79 public function iniExists()
80 {
81 return file_exists(dirname(__DIR__, 2) . "/ilias.ini.php");
82 }
83
84 public function clientIniExists()
85 {
86 return file_exists($this->getClientDir() . "/client.ini.php");
87 }
88
89 protected function getClientDir() : string
90 {
91 return dirname(__DIR__, 2) . "/data/" . $this->config->getClientId();
92 }
93}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$message
Definition: xapiexit.php:14