ILIAS  release_8 Revision v8.24
class.ilDatabaseCreatedObjective.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 is created 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 return [
51 new \ilDatabaseServerIsConnectableObjective($this->config)
52 ];
53 }
54
55 public function achieve(Setup\Environment $environment): Setup\Environment
56 {
58 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
59 $db->initFromIniFile($c->toMockIniFile());
60
61 if (!$db->createDatabase($c->getDatabase(), "utf8", $c->getCollation())) {
63 "Database cannot be created."
64 );
65 }
66
67 return $environment;
68 }
69
73 public function isApplicable(Setup\Environment $environment): bool
74 {
76 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
77 $db->initFromIniFile($c->toMockIniFile());
78
79 $connect = $db->connect(true);
80 return !$connect;
81 }
82}
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
ilDatabaseSetupConfig $config
$c
Definition: cli.php:38
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...