ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDatabaseCreatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
25{
26 public function getHash(): string
27 {
28 return hash("sha256", implode("-", [
29 self::class,
30 $this->config->getHost(),
31 $this->config->getPort(),
32 $this->config->getDatabase()
33 ]));
34 }
35
36 public function getLabel(): string
37 {
38 return "The database is created on the server.";
39 }
40
41 public function isNotable(): bool
42 {
43 return true;
44 }
45
49 public function getPreconditions(Environment $environment): array
50 {
51 return [
52 new \ilDatabaseServerIsConnectableObjective($this->config)
53 ];
54 }
55
56 public function achieve(Environment $environment): Environment
57 {
58 $c = $this->config;
59 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
60 $db->initFromIniFile($c->toMockIniFile());
61
62 if (!$db->createDatabase($c->getDatabase(), "utf8", $c->getCollation())) {
63 throw new UnachievableException(
64 "Database cannot be created."
65 );
66 }
67
68 return $environment;
69 }
70
74 public function isApplicable(Environment $environment): bool
75 {
76 $c = $this->config;
77 $db = \ilDBWrapperFactory::getWrapper($this->config->getType());
78 $db->initFromIniFile($c->toMockIniFile());
79
80 $connect = $db->connect(true);
81 return !$connect;
82 }
83}
Signals that some goal won't be achievable by actions of the system ever.
static getWrapper(string $a_type)
achieve(Environment $environment)
Objectives can be achieved.
isApplicable(Environment $environment)
@inheritDoc
getLabel()
Get a label that describes this objective.
getHash()
Get a hash for this objective.
isNotable()
Get to know if this is an interesting objective for a human.
$c
Definition: deliver.php:25
An environment holds resources to be used in the setup process.
Definition: Environment.php:28