ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilCtrlStructureStoredObjective.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
4use ILIAS\DI;
5
7{
8 const TABLE_CLASSFILES = "ctrl_classfile";
9 const TABLE_CALLS = "ctrl_calls";
10
14 protected $ctrl_reader;
15
20
22 {
23 $this->ctrl_reader = $ctrl_reader;
24 $this->populate_before = $populate_before;
25 }
26
30 public function getHash() : string
31 {
32 return hash("sha256", self::class);
33 }
34
38 public function getLabel() : string
39 {
40 return "ilCtrl-structure is read and stored.";
41 }
42
46 public function isNotable() : bool
47 {
48 return true;
49 }
50
54 public function getPreconditions(Setup\Environment $environment) : array
55 {
56 return [
57 new \ilDatabaseInitializedObjective()
58 ];
59 }
60
64 public function achieve(Setup\Environment $environment) : Setup\Environment
65 {
66 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
67 if (!$db) {
68 throw new Setup\UnachievableException("Need DB to store control-structure");
69 }
70
71 if (!defined("ILIAS_ABSOLUTE_PATH")) {
72 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
73 }
74
75 // ATTENTION: This is a total abomination. It only exists to allow various
76 // sub components of the various readers to run. This is a memento to the
77 // fact, that dependency injection is something we want. Currently, every
78 // component could just service locate the whole world via the global $DIC.
79 $DIC = $GLOBALS["DIC"];
80 $GLOBALS["DIC"] = new DI\Container();
81 $GLOBALS["DIC"]["ilDB"] = $db;
82
83 $reader = $this->ctrl_reader->withDB($db);
84 $reader->executed = false;
85 $reader->readStructure(true);
86
87 $GLOBALS["DIC"] = $DIC;
88
89 return $environment;
90 }
91
95 public function isApplicable(Setup\Environment $environment) : bool
96 {
97 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
98 if (!$db) {
99 throw new Setup\UnachievableException("Need DB to read control-structure");
100 }
101
102 if (!defined("ILIAS_ABSOLUTE_PATH")) {
103 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
104 }
105
106 $reader = $this->ctrl_reader->withDB($db);
107
108 return !$reader->executed;
109 }
110}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
Signals that some goal won't be achievable by actions of the system ever.
Class ilCtrlStructureReader.
isApplicable(Setup\Environment $environment)
@inheritDoc
__construct(\ilCtrlStructureReader $ctrl_reader, bool $populate_before=true)
getPreconditions(Setup\Environment $environment)
global $DIC
Definition: goto.php:24
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...