ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDatabaseExistsObjective.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
8{
9 public function getHash() : string
10 {
11 return hash("sha256", implode("-", [
12 self::class,
13 $this->config->getHost(),
14 $this->config->getPort(),
15 $this->config->getDatabase()
16 ]));
17 }
18
19 public function getLabel() : string
20 {
21 return "The database exists on the server.";
22 }
23
24 public function isNotable() : bool
25 {
26 return true;
27 }
28
29 public function getPreconditions(Setup\Environment $environment) : array
30 {
31 $preconditions = [
32 new \ilDatabaseServerIsConnectableObjective($this->config)
33 ];
34 if ($this->config->getCreateDatabase()) {
35 $preconditions[] = new \ilDatabaseCreatedObjective($this->config);
36 }
37 return $preconditions;
38 }
39
40 public function achieve(Setup\Environment $environment) : Setup\Environment
41 {
42 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
43 $db->initFromIniFile($this->config->toMockIniFile());
44 $connect = $db->connect(true);
45 if (!$connect) {
47 "Database cannot be connected. Please check the credentials."
48 );
49 }
50 return $environment->withResource(Setup\Environment::RESOURCE_DATABASE, $db);
51 }
52
56 public function isApplicable(Setup\Environment $environment) : bool
57 {
58 return true;
59 }
60}
An exception for terminatinating execution or to throw for unit testing.
Signals that some goal won't be achievable by actions of the system ever.
achieve(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...