ILIAS  release_8 Revision v8.24
class.ilDatabaseExistsObjective.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", implode("-", [
28 self::class,
29 $this->config->getHost(),
30 $this->config->getPort(),
31 $this->config->getDatabase()
32 ]));
33 }
34
35 public function getLabel(): string
36 {
37 return "The database exists on the server.";
38 }
39
40 public function isNotable(): bool
41 {
42 return true;
43 }
44
48 public function getPreconditions(Setup\Environment $environment): array
49 {
50 $preconditions = [
51 new \ilDatabaseServerIsConnectableObjective($this->config)
52 ];
53 if ($this->config->getCreateDatabase()) {
54 $preconditions[] = new \ilDatabaseCreatedObjective($this->config);
55 }
56 return $preconditions;
57 }
58
59 public function achieve(Setup\Environment $environment): Setup\Environment
60 {
61 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
62 $db->initFromIniFile($this->config->toMockIniFile());
63 $connect = $db->connect(true);
64 if (!$connect) {
66 "Database cannot be connected. Please check the credentials."
67 );
68 }
69
70 return $environment->withResource(Setup\Environment::RESOURCE_DATABASE, $db);
71 }
72
76 public function isApplicable(Setup\Environment $environment): bool
77 {
78 return true;
79 }
80}
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
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:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...