ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSettingsFactoryExistsObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8{
9 public function getHash() : string
10 {
11 return hash("sha256", self::class);
12 }
13
14 public function getLabel() : string
15 {
16 return "Initialize factory for ilSetting";
17 }
18
19 public function isNotable() : bool
20 {
21 return false;
22 }
23
24 public function getPreconditions(Setup\Environment $environment) : array
25 {
26 return [
28 ];
29 }
30
31 public function achieve(Setup\Environment $environment) : Setup\Environment
32 {
33 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
34
35 if (!($db instanceof \ilDBInterface)) {
36 throw new Setup\UnachievableException("Database does not exist.");
37 }
38
39 return $environment
40 ->withResource(
41 Setup\Environment::RESOURCE_SETTINGS_FACTORY,
42 new \ilSettingsFactory($db)
43 );
44 }
45
49 public function isApplicable(Setup\Environment $environment) : bool
50 {
51 $resource = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
52
53 return !($resource instanceof ilSettingsFactory);
54 }
55}
An exception for terminatinating execution or to throw for unit testing.
Signals that some goal won't be achievable by actions of the system ever.
isApplicable(Setup\Environment $environment)
@inheritDoc
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:12
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:15
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...