ILIAS  release_8 Revision v8.24
ilComponentInstallPluginObjective Class Reference
+ Inheritance diagram for ilComponentInstallPluginObjective:
+ Collaboration diagram for ilComponentInstallPluginObjective:

Public Member Functions

 __construct (string $plugin_name)
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 

Protected Member Functions

 initEnvironment (Setup\Environment $environment, \ilComponentRepository $component_repository, \ilComponentFactory $component_factory)
 

Protected Attributes

 $plugin_name
 

Detailed Description

Definition at line 26 of file class.ilComponentInstallPluginObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilComponentInstallPluginObjective::__construct ( string  $plugin_name)

Definition at line 33 of file class.ilComponentInstallPluginObjective.php.

References $plugin_name.

Referenced by initEnvironment().

+ Here is the caller graph for this function:

Member Function Documentation

◆ achieve()

ilComponentInstallPluginObjective::achieve ( Setup\Environment  $environment)

Definition at line 80 of file class.ilComponentInstallPluginObjective.php.

80 : Setup\Environment
81 {
82 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
83 $component_factory = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_FACTORY);
84 $info = $component_repository->getPluginByName($this->plugin_name);
85
86 if (!$info->supportsCLISetup()) {
87 throw new \RuntimeException(
88 "Plugin $this->plugin_name does not support command line setup."
89 );
90 }
91
92 if ($info->isInstalled()) {
93 throw new \RuntimeException(
94 "Plugin $this->plugin_name is already installed."
95 );
96 }
97
98 $ORIG_DIC = $this->initEnvironment($environment, $component_repository, $component_factory);
99 $plugin = $component_factory->getPlugin($info->getId());
100 $plugin->install();
101 $plugin->update();
102 $GLOBALS["DIC"] = $ORIG_DIC;
103
104 return $environment;
105 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
initEnvironment(Setup\Environment $environment, \ilComponentRepository $component_repository, \ilComponentFactory $component_factory)

References $GLOBALS, XapiProxy\$plugin, ILIAS\Setup\Environment\getResource(), and initEnvironment().

+ Here is the call graph for this function:

◆ getHash()

ilComponentInstallPluginObjective::getHash ( )

Definition at line 41 of file class.ilComponentInstallPluginObjective.php.

41 : string
42 {
43 return hash("sha256", self::class . $this->plugin_name);
44 }

◆ getLabel()

ilComponentInstallPluginObjective::getLabel ( )

Definition at line 49 of file class.ilComponentInstallPluginObjective.php.

49 : string
50 {
51 return "Install plugin $this->plugin_name.";
52 }

◆ getPreconditions()

ilComponentInstallPluginObjective::getPreconditions ( Setup\Environment  $environment)

Definition at line 65 of file class.ilComponentInstallPluginObjective.php.

65 : array
66 {
67 return [
69 new \ilIniFilesPopulatedObjective(),
70 new \ilDatabaseUpdatedObjective(),
71 new \ilComponentPluginAdminInitObjective(),
72 new \ilComponentRepositoryExistsObjective(),
73 new \ilComponentFactoryExistsObjective()
74 ];
75 }
Read the client id of the installation from the data directory.

◆ initEnvironment()

ilComponentInstallPluginObjective::initEnvironment ( Setup\Environment  $environment,
\ilComponentRepository  $component_repository,
\ilComponentFactory  $component_factory 
)
protected

Definition at line 118 of file class.ilComponentInstallPluginObjective.php.

122 {
123 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
124 $plugin_admin = $environment->getResource(Setup\Environment::RESOURCE_PLUGIN_ADMIN);
125 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
126 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
127
128 // ATTENTION: This is a total abomination. It only exists to allow various
129 // sub components of the various readers to run. This is a memento to the
130 // fact, that dependency injection is something we want. Currently, every
131 // component could just service locate the whole world via the global $DIC.
132 $DIC = $GLOBALS["DIC"];
133 $GLOBALS["DIC"] = new DI\Container();
134 $GLOBALS["DIC"]["ilDB"] = $db;
135 $GLOBALS["DIC"]["ilIliasIniFile"] = $ini;
136 $GLOBALS["DIC"]["ilClientIniFile"] = $client_ini;
137 $GLOBALS["DIC"]["ilLog"] = new class () extends ilLogger {
138 public function __construct()
139 {
140 }
141 public function write(string $a_message, $a_level = ilLogLevel::INFO): void
142 {
143 }
144 public function info(string $a_message): void
145 {
146 }
147 public function warning(string $a_message): void
148 {
149 }
150 public function error(string $a_message): void
151 {
152 }
153 public function debug(string $a_message, array $a_context = []): void
154 {
155 }
156 public function dump($a_variable, int $a_level = ilLogLevel::INFO): void
157 {
158 }
159 };
160 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () extends ilLoggerFactory {
161 public function __construct()
162 {
163 }
164 public static function getRootLogger(): ilLogger
165 {
166 return $GLOBALS["DIC"]["ilLog"];
167 }
168 public static function getLogger(string $a_component_id): ilLogger
169 {
170 return $GLOBALS["DIC"]["ilLog"];
171 }
172 };
173 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
174 $GLOBALS["DIC"]["ilBench"] = null;
175 $GLOBALS["DIC"]["lng"] = new ilLanguage('en');
176 $GLOBALS["DIC"]["lng"]->lang_user = 'en';
177 $GLOBALS["DIC"]["ilPluginAdmin"] = $plugin_admin;
178 $GLOBALS["DIC"]["ilias"] = null;
179 $GLOBALS["DIC"]["ilErr"] = null;
180 $GLOBALS["DIC"]["tree"] = null;
181 $GLOBALS["DIC"]["ilAppEventHandler"] = null;
182 $GLOBALS["DIC"]["ilSetting"] = new ilSetting();
183 $GLOBALS["DIC"]["component.repository"] = $component_repository;
184 $GLOBALS["DIC"]["component.factory"] = $component_factory;
185 $GLOBALS["DIC"]["ilUser"] = new class () extends ilObjUser {
186 public array $prefs = [];
187
188 public function __construct()
189 {
190 $this->prefs["language"] = "en";
191 }
192 };
193 $GLOBALS["DIC"]["tree"] = new class () extends ilTree {
194 public function __construct()
195 {
196 }
197 };
198
199 if (!defined('DEBUG')) {
200 define('DEBUG', false);
201 }
202
203 if (!defined('SYSTEM_ROLE_ID')) {
204 define('SYSTEM_ROLE_ID', '2');
205 }
206
207 if (!defined("ILIAS_ABSOLUTE_PATH")) {
208 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
209 }
210
211 if (!defined("CLIENT_ID")) {
212 define('CLIENT_ID', $client_ini->readVariable('client', 'name'));
213 }
214
215 if (!defined("ILIAS_WEB_DIR")) {
216 define('ILIAS_WEB_DIR', dirname(__DIR__, 4) . "/data/");
217 }
218
219 // initialise this last to make sure the environment defined here
220 // will be available for plugins, ilObjectDefinition will create
221 // plugin instances, see https://mantis.ilias.de/view.php?id=40890
222 $GLOBALS["DIC"]["objDefinition"] = new ilObjectDefinition();
223
224 return $DIC;
225 }
error(string $a_errmsg)
language handling
Component logger with individual log levels by component id.
User class.
parses the objects.xml it handles the xml-description of all ilias objects
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...
global $DIC
Definition: feed.php:28
$ini
Definition: raiseError.php:4

References $DIC, $GLOBALS, $ini, __construct(), error(), ilLogLevel\INFO, and ILIAS\UI\examples\MessageBox\Info\info().

Referenced by achieve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isApplicable()

ilComponentInstallPluginObjective::isApplicable ( Setup\Environment  $environment)

@inheritDoc

Definition at line 110 of file class.ilComponentInstallPluginObjective.php.

110 : bool
111 {
112 $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
113 $plugin = $component_repository->getPluginByName($this->plugin_name);
114
115 return !$plugin->isInstalled();
116 }

References XapiProxy\$plugin.

◆ isNotable()

ilComponentInstallPluginObjective::isNotable ( )

Definition at line 57 of file class.ilComponentInstallPluginObjective.php.

57 : bool
58 {
59 return true;
60 }

Field Documentation

◆ $plugin_name

ilComponentInstallPluginObjective::$plugin_name
protected

Definition at line 31 of file class.ilComponentInstallPluginObjective.php.

Referenced by __construct().


The documentation for this class was generated from the following file: