ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilDatabaseInitializedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
25 public function getHash(): string
26 {
27 return hash("sha256", self::class);
28 }
29
30 public function getLabel(): string
31 {
32 return "The database object is initialized.";
33 }
34
35 public function isNotable(): bool
36 {
37 return true;
38 }
39
43 public function getPreconditions(Setup\Environment $environment): array
44 {
45 // If there is no config for the database the existing config seems
46 // to be ok, and we can just connect.
47 if (!$environment->hasConfigFor("database")) {
48 return [
50 ];
51 }
52
53 $config = $environment->getConfigFor("database");
54 return [
57 ];
58 }
59
60 public function achieve(Setup\Environment $environment): Setup\Environment
61 {
62 if ($environment->getResource(Setup\Environment::RESOURCE_DATABASE)) {
63 return $environment;
64 }
65
66 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
67
68 $type = $client_ini->readVariable("db", "type");
69 if ($type === "") {
71 }
72
74 $db->initFromIniFile($client_ini);
75 $connect = $db->connect(true);
76 if (!$connect) {
78 "Database cannot be connected."
79 );
80 }
81
82 return $environment->withResource(Setup\Environment::RESOURCE_DATABASE, $db);
83 }
84
88 public function isApplicable(Setup\Environment $environment): bool
89 {
90 return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI) !== null;
91 }
92}
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
isApplicable(Setup\Environment $environment)
@inheritDoc
getPreconditions(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
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:31
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$type