ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDatabaseInitializedObjective.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", self::class);
12 }
13
14 public function getLabel() : string
15 {
16 return "The database object is initialized.";
17 }
18
19 public function isNotable() : bool
20 {
21 return true;
22 }
23
24 public function getPreconditions(Setup\Environment $environment) : array
25 {
26 // If there is no config for the database the existing config seems
27 // to be ok, and we can just connect.
28 if (!$environment->hasConfigFor("database")) {
29 return [
31 ];
32 }
33
34 $config = $environment->getConfigFor("database");
35 return [
38 ];
39 }
40
41 public function achieve(Setup\Environment $environment) : Setup\Environment
42 {
43 if ($environment->getResource(Setup\Environment::RESOURCE_DATABASE)) {
44 return $environment;
45 }
46
47 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
48
49 $type = $client_ini->readVariable("db", "type");
50 if ($type == "") {
51 $type = "mysql";
52 }
53
55 $db->initFromIniFile($client_ini);
56 $connect = $db->connect(true);
57 if (!$connect) {
59 "Database cannot be connected."
60 );
61 }
62 return $environment->withResource(Setup\Environment::RESOURCE_DATABASE, $db);
63 }
64
68 public function isApplicable(Setup\Environment $environment) : bool
69 {
70 return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI) !== null;
71 }
72}
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.
isApplicable(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
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.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$type