ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
cli.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
6 
8 chdir(__DIR__ . "/..");
9 
10 require_once(__DIR__ . "/../libs/composer/vendor/autoload.php");
11 
12 require_once(__DIR__ . "/../include/inc.ilias_version.php");
13 
14 // according to ./Services/Feeds/classes/class.ilExternalFeed.php:
15 if (!defined("MAGPIE_DIR")) {
16  define("MAGPIE_DIR", "./Services/Feeds/magpierss/");
17 }
18 
19 require_once(__DIR__ . "/classes/class.ilSetupObjective.php");
20 require_once(__DIR__ . "/classes/class.ilSetupAgent.php");
21 require_once(__DIR__ . "/classes/class.ilSetupConfig.php");
22 require_once(__DIR__ . "/classes/class.ilMakeInstallationAccessibleObjective.php");
23 require_once(__DIR__ . "/classes/class.ilUseRootConfirmed.php");
24 require_once(__DIR__ . "/classes/class.ilOwnRiskConfirmedObjective.php");
25 require_once(__DIR__ . "/classes/class.ilOverwritesExistingInstallationConfirmed.php");
26 require_once(__DIR__ . "/classes/class.ilIniFilesPopulatedObjective.php");
27 require_once(__DIR__ . "/classes/class.ilIniFilesLoadedObjective.php");
28 require_once(__DIR__ . "/classes/class.ilNICKeyRegisteredObjective.php");
29 require_once(__DIR__ . "/classes/class.ilNICKeyStoredObjective.php");
30 require_once(__DIR__ . "/classes/class.ilSetupConfigStoredObjective.php");
31 require_once(__DIR__ . "/classes/class.ilSetupMetricsCollectedObjective.php");
32 
37 
39 $app = $c["app"];
40 $app->run();
41 
42 // ATTENTION: This is a hack to get around the usage of the echo/exit pattern in
43 // the setup for the command line version of the setup. Do not use this.
45 {
46  if (!defined("ILIAS_SETUP_IGNORE_DB_UPDATE_STEP_MESSAGES") || !ILIAS_SETUP_IGNORE_DB_UPDATE_STEP_MESSAGES) {
47  throw new \ILIAS\Setup\UnachievableException($message);
48  }
49 }
50 
51 function build_container_for_setup(string $executed_in_directory): \Pimple\Container
52 {
53  $c = new \Pimple\Container();
54 
55  $c["app"] = function ($c) {
56  return new \ILIAS\Setup\CLI\App(
57  $c["command.install"],
58  $c["command.update"],
59  $c["command.build-artifacts"],
60  $c["command.achieve"],
61  $c["command.status"],
62  $c["command.migrate"]
63  );
64  };
65  $c["command.install"] = function ($c) {
66  return new \ILIAS\Setup\CLI\InstallCommand(
67  $c["agent_finder"],
68  $c["config_reader"],
69  $c["common_preconditions"]
70  );
71  };
72  $c["command.update"] = function ($c) {
73  return new \ILIAS\Setup\CLI\UpdateCommand(
74  $c["agent_finder"],
75  $c["config_reader"],
76  $c["common_preconditions"]
77  );
78  };
79  $c["command.build-artifacts"] = function ($c) {
80  return new \ILIAS\Setup\CLI\BuildArtifactsCommand(
81  $c["agent_finder"]
82  );
83  };
84  $c["command.achieve"] = function ($c) {
85  return new \ILIAS\Setup\CLI\AchieveCommand(
86  $c["agent_finder"],
87  $c["config_reader"],
88  $c["common_preconditions"],
89  $c["refinery"]
90  );
91  };
92  $c["command.status"] = function ($c) {
93  return new \ILIAS\Setup\CLI\StatusCommand(
94  $c["agent_finder"]
95  );
96  };
97 
98  $c["command.migrate"] = function ($c) {
99  return new \ILIAS\Setup\CLI\MigrateCommand(
100  $c["agent_finder"],
101  $c["common_preconditions"]
102  );
103  };
104 
105  $c["common_preconditions"] = function ($c) {
106  return [
107  new \ilOwnRiskConfirmedObjective(),
108  new \ilUseRootConfirmed()
109  ];
110  };
111 
112  $c["common_agent"] = function ($c) {
113  return new \ilSetupAgent(
114  $c["refinery"],
115  $c["data_factory"]
116  );
117  };
118 
119  $c["agent_finder"] = function ($c) {
121  $c["refinery"],
122  $c["data_factory"],
123  $c["lng"],
124  $c["interface_finder"],
125  [
126  "common" => $c["common_agent"]
127  ]
128  );
129  };
130 
131  $c["refinery"] = function ($c) {
132  return new ILIAS\Refinery\Factory(
133  $c["data_factory"],
134  $c["lng"]
135  );
136  };
137 
138  $c["data_factory"] = function ($c) {
139  return new ILIAS\Data\Factory();
140  };
141 
142  $c["lng"] = function ($c) {
143  return new \ilSetupLanguage("en");
144  };
145 
146  $c["config_reader"] = function ($c) use ($executed_in_directory) {
147  return new \ILIAS\Setup\CLI\ConfigReader(
148  $c["json.parser"],
149  $executed_in_directory
150  );
151  };
152 
153  $c["interface_finder"] = function ($c) {
154  return new \ILIAS\Setup\ImplementationOfInterfaceFinder();
155  };
156 
157  $c["json.parser"] = function ($c) {
158  return new \Seld\JsonLint\JsonParser();
159  };
160 
161  return $c;
162 }
This is what a factory for input fields looks like.
Definition: Factory.php:28
$app
Definition: cli.php:39
$c
Definition: cli.php:38
$executed_in_directory
Definition: cli.php:7
setup_exit($message)
Definition: cli.php:44
$message
Definition: xapiexit.php:32
build_container_for_setup(string $executed_in_directory)
Definition: cli.php:51