ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDatabaseCreatedObjective.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 is created 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 return [
32 new \ilDatabaseServerIsConnectableObjective($this->config)
33 ];
34 }
35
36 public function achieve(Setup\Environment $environment) : Setup\Environment
37 {
39 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
40 $db->initFromIniFile($c->toMockIniFile());
41
42 if (!$db->createDatabase($c->getDatabase(), "utf8", $c->getCollation())) {
44 "Database cannot be created."
45 );
46 }
47
48 return $environment;
49 }
50
54 public function isApplicable(Setup\Environment $environment) : bool
55 {
57 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
58 $db->initFromIniFile($c->toMockIniFile());
59
60 $connect = $db->connect(true);
61
62 if ($connect) {
63 return false;
64 }
65
66 return true;
67 }
68}
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)
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
$c
Definition: cli.php:37
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...