ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSettingsFactoryExistsObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
27{
28 public function getHash(): string
29 {
30 return hash("sha256", self::class);
31 }
32
33 public function getLabel(): string
34 {
35 return "Initialize factory for ilSetting";
36 }
37
38 public function isNotable(): bool
39 {
40 return false;
41 }
42
43 public function getPreconditions(Setup\Environment $environment): array
44 {
45 return [
47 ];
48 }
49
50 public function achieve(Setup\Environment $environment): Setup\Environment
51 {
52 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
53
54 if (!($db instanceof \ilDBInterface)) {
55 throw new Setup\UnachievableException("Database does not exist.");
56 }
57
58 return $environment
59 ->withResource(
60 Setup\Environment::RESOURCE_SETTINGS_FACTORY,
61 new \ilSettingsFactory($db)
62 );
63 }
64
65 public function isApplicable(Setup\Environment $environment): bool
66 {
67 $resource = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
68
69 return !($resource instanceof ilSettingsFactory);
70 }
71}
Signals that some goal won't be achievable by actions of the system ever.
A factory that builds ilSettings that can be used for DI.
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
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...