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

Public Member Functions

 getMessage ()
 
 __construct (\ilDBInterface $db, \ilComponentRepositoryWrite $component_repository, string $id)
 
 getPluginName ()
 
 getId ()
 
 getVersion ()
 Only very little classes seem to care about this: More...
 
 getDirectory ()
 Only very little classes seem to care about this: More...
 
 isActive ()
 Only very little classes seem to care about this: More...
 
 needsUpdate ()
 
 install ()
 
 uninstall ()
 
 activate ()
 This will update (if required) and activate the plugin. More...
 
 deactivate ()
 
 update ()
 
 loadLanguageModule ()
 Load language module for plugin. More...
 
 txt (string $a_var)
 Get Language Variable (prefix will be prepended automatically) More...
 
 getTemplate (string $a_template, bool $a_par1=true, bool $a_par2=true)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getStyleSheetLocation (string $a_css_file)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 @deprecate ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getGlobalScreenProviderCollection ()
 
 exchangeUIRendererAfterInitialization (\ILIAS\DI\Container $dic)
 This methods allows to replace the UI Renderer (see src/UI) of ILIAS after initialization by returning a closure returning a custom renderer. More...
 
 exchangeUIFactoryAfterInitialization (string $dic_key, \ILIAS\DI\Container $dic)
 This methods allows to replace some factory for UI Components (see src/UI) of ILIAS after initialization by returning a closure returning a custom factory. More...
 

Protected Member Functions

 init ()
 Object initialization. More...
 
 getPluginInfo ()
 
 getComponentInfo ()
 
 getPluginSlotInfo ()
 
 afterInstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead. More...
 
 beforeUninstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 afterUninstall ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 beforeActivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterActivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterDeactivation ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 updateDatabase ()
 
 beforeUpdate ()
 @deprecate If you cannot get rid of the requirement to use this, adjust the update method in your subclass instead. More...
 
 afterUpdate ()
 
 getLanguageHandler ()
 
 buildLanguageHandler ()
 
 readEventListening ()
 
 clearEventListening ()
 

Protected Attributes

ilDBInterface $db
 
ilComponentRepositoryWrite $component_repository
 
string $id
 
ilPluginLanguage $language_handler = null
 
bool $lang_initialised = false
 
ProviderCollection $provider_collection
 
string $message = ''
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPlugin::__construct ( \ilDBInterface  $db,
\ilComponentRepositoryWrite  $component_repository,
string  $id 
)

Reimplemented in ilTestExportPlugin.

Definition at line 53 of file class.ilPlugin.php.

57 {
59 throw new \LogicException(
60 "You tried to instantiate a plugin with an inexisting id '$id'." .
61 "This is odd... Please use ilComponentFactory to instantiate plugins."
62 );
63 }
64
65 $this->db = $db;
66 $this->component_repository = $component_repository;
67 $this->id = $id;
68
69 $this->provider_collection = new PluginProviderCollection();
70
71 // Fix for authentication plugins
72 $this->loadLanguageModule();
73
74 // Custom initialisation for plugin.
75 $this->init();
76 }
ilDBInterface $db
init()
Object initialization.
string $id
loadLanguageModule()
Load language module for plugin.
ilComponentRepositoryWrite $component_repository
hasPluginId(string $id)
Check if a plugin exists.

References $component_repository, $db, $id, ilComponentRepository\hasPluginId(), init(), and loadLanguageModule().

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilPlugin::activate ( )

This will update (if required) and activate the plugin.

Definition at line 215 of file class.ilPlugin.php.

215 : bool
216 {
217 if ($this->needsUpdate() && !$this->update()) {
218 return false;
219 }
220
221 if (!$this->beforeActivation()) {
222 return false;
223 }
224
225 $this->component_repository->setActivation($this->getId(), true);
226 $this->afterActivation();
227
228 return true;
229 }
afterActivation()
@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your s...
beforeActivation()
@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your s...

References afterActivation(), beforeActivation(), getId(), needsUpdate(), and update().

+ Here is the call graph for this function:

◆ addBlockFile()

ilPlugin::addBlockFile (   $a_tpl,
  $a_var,
  $a_block,
  $a_tplname 
)

@deprecate ILIAS is moving towards UI components and plugins are expected to use these components.

Hence, this method will be removed.

Definition at line 399 of file class.ilPlugin.php.

399 : void
400 {
401 $a_tpl->addBlockFile(
402 $a_var,
403 $a_block,
404 $this->getDirectory() . "/templates/" . $a_tplname
405 );
406 }
getDirectory()
Only very little classes seem to care about this:

References getDirectory().

+ Here is the call graph for this function:

◆ afterActivation()

ilPlugin::afterActivation ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead.

Definition at line 252 of file class.ilPlugin.php.

252 : void
253 {
254 }

Referenced by activate().

+ Here is the caller graph for this function:

◆ afterDeactivation()

ilPlugin::afterDeactivation ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead.

Definition at line 260 of file class.ilPlugin.php.

260 : void
261 {
262 }

Referenced by deactivate().

+ Here is the caller graph for this function:

◆ afterInstall()

ilPlugin::afterInstall ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead.

Definition at line 186 of file class.ilPlugin.php.

186 : void
187 {
188 }

Referenced by install().

+ Here is the caller graph for this function:

◆ afterUninstall()

ilPlugin::afterUninstall ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead.

Definition at line 203 of file class.ilPlugin.php.

203 : void
204 {
205 }

Referenced by uninstall().

+ Here is the caller graph for this function:

◆ afterUpdate()

ilPlugin::afterUpdate ( )
protected

Definition at line 324 of file class.ilPlugin.php.

324 : void
325 {
326 }

Referenced by update().

+ Here is the caller graph for this function:

◆ beforeActivation()

ilPlugin::beforeActivation ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead.

Reimplemented in ilRepositoryObjectPlugin.

Definition at line 243 of file class.ilPlugin.php.

243 : bool
244 {
245 return true;
246 }

Referenced by activate().

+ Here is the caller graph for this function:

◆ beforeUninstall()

ilPlugin::beforeUninstall ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead.

Reimplemented in ilRepositoryObjectPlugin.

Definition at line 194 of file class.ilPlugin.php.

194 : bool
195 {
196 return true;
197 }

Referenced by uninstall().

+ Here is the caller graph for this function:

◆ beforeUpdate()

ilPlugin::beforeUpdate ( )
protected

@deprecate If you cannot get rid of the requirement to use this, adjust the update method in your subclass instead.

Definition at line 318 of file class.ilPlugin.php.

318 : bool
319 {
320 return true;
321 }

Referenced by update().

+ Here is the caller graph for this function:

◆ buildLanguageHandler()

ilPlugin::buildLanguageHandler ( )
protected

Definition at line 341 of file class.ilPlugin.php.

342 {
343 return new ilPluginLanguage($this->getPluginInfo());
344 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getPluginInfo().

Referenced by getLanguageHandler().

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

◆ clearEventListening()

ilPlugin::clearEventListening ( )
protected

Definition at line 426 of file class.ilPlugin.php.

426 : void
427 {
428 $reader = new ilPluginReader(
429 $this->getDirectory() . '/plugin.xml',
430 $this->getComponentInfo()->getType(),
431 $this->getComponentInfo()->getName(),
432 $this->getPluginSlotInfo()->getId(),
433 $this->getPluginInfo()->getName()
434 );
435 $reader->clearEvents();
436 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getComponentInfo(), getDirectory(), getId(), getPluginInfo(), and getPluginSlotInfo().

Referenced by uninstall().

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

◆ deactivate()

ilPlugin::deactivate ( )

Definition at line 231 of file class.ilPlugin.php.

231 : bool
232 {
233 $this->component_repository->setActivation($this->getId(), false);
234 $this->afterDeactivation();
235
236 return true;
237 }
afterDeactivation()
@deprecate If you cannot get rid of the requirement to use this, adjust the activate method in your s...

References afterDeactivation(), and getId().

+ Here is the call graph for this function:

◆ exchangeUIFactoryAfterInitialization()

ilPlugin::exchangeUIFactoryAfterInitialization ( string  $dic_key,
\ILIAS\DI\Container  $dic 
)

This methods allows to replace some factory for UI Components (see src/UI) of ILIAS after initialization by returning a closure returning a custom factory.

E.g:

if($key == "ui.factory.nameOfFactory"){ return function(\ILIAS\DI\Container $c){ return new CustomFactory($c['ui.signal_generator'],$c['ui.factory.maincontrols.slate']); }; }

Note: Note that plugins might conflict by replacing the same factory, so only use if you are sure, that no other plugin will do this for a given context.

Definition at line 484 of file class.ilPlugin.php.

484 : Closure
485 {
486 //This returns the callable of $c[$key] without executing it.
487 return $dic->raw($dic_key);
488 }
$dic
Definition: result.php:32

References $dic.

◆ exchangeUIRendererAfterInitialization()

ilPlugin::exchangeUIRendererAfterInitialization ( \ILIAS\DI\Container  $dic)

This methods allows to replace the UI Renderer (see src/UI) of ILIAS after initialization by returning a closure returning a custom renderer.

E.g:

return function(\ILIAS\DI\Container $c){ return new CustomRenderer(); };

Note: Note that plugins might conflict by replacing the renderer, so only use if you are sure, that no other plugin will do this for a given context.

Definition at line 464 of file class.ilPlugin.php.

464 : Closure
465 {
466 //This returns the callable of $c['ui.renderer'] without executing it.
467 return $dic->raw('ui.renderer');
468 }

References $dic.

◆ getComponentInfo()

ilPlugin::getComponentInfo ( )
protected

Definition at line 149 of file class.ilPlugin.php.

150 {
151 return $this->getPluginInfo()->getComponent();
152 }
Simple value class for basic information about a component.

References getPluginInfo().

Referenced by clearEventListening(), getStyleSheetLocation(), and readEventListening().

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

◆ getDirectory()

ilPlugin::getDirectory ( )

Only very little classes seem to care about this:

Definition at line 121 of file class.ilPlugin.php.

121 : string
122 {
123 return $this->getPluginInfo()->getPath();
124 }

References getPluginInfo().

Referenced by addBlockFile(), clearEventListening(), getStyleSheetLocation(), getTemplate(), and readEventListening().

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

◆ getGlobalScreenProviderCollection()

ilPlugin::getGlobalScreenProviderCollection ( )
final

Definition at line 443 of file class.ilPlugin.php.

444 {
446 }
ProviderCollection $provider_collection

References $provider_collection.

◆ getId()

ilPlugin::getId ( )

Definition at line 100 of file class.ilPlugin.php.

100 : string
101 {
102 return $this->getPluginInfo()->getId();
103 }

References getPluginInfo().

Referenced by ILIAS\GlobalScreen\Provider\__construct(), activate(), ilRepositoryObjectPlugin\beforeActivation(), ilRepositoryObjectPlugin\beforeUninstall(), clearEventListening(), deactivate(), ilTestSignaturePlugin\handInFileForArchiving(), ilDclFieldTypePlugin\install(), readEventListening(), uninstall(), and update().

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

◆ getLanguageHandler()

ilPlugin::getLanguageHandler ( )
protected

Definition at line 333 of file class.ilPlugin.php.

334 {
335 if ($this->language_handler === null) {
336 $this->language_handler = $this->buildLanguageHandler();
337 }
339 }
ilPluginLanguage $language_handler
buildLanguageHandler()

References $language_handler, and buildLanguageHandler().

Referenced by ilRepositoryObjectPlugin\getPrefix(), loadLanguageModule(), txt(), uninstall(), and update().

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

◆ getMessage()

ilPlugin::getMessage ( )
Returns
string

Definition at line 44 of file class.ilPlugin.php.

44 : string
45 {
46 return $this->message;
47 }
string $message

References $message.

◆ getPluginInfo()

ilPlugin::getPluginInfo ( )
protected

Definition at line 141 of file class.ilPlugin.php.

142 {
143 return $this->component_repository
144 ->getPluginById(
145 $this->id
146 );
147 }
Simple value class for information about a plugin.

Referenced by buildLanguageHandler(), clearEventListening(), getComponentInfo(), getDirectory(), getId(), getPluginName(), getPluginSlotInfo(), getStyleSheetLocation(), getVersion(), isActive(), needsUpdate(), readEventListening(), update(), and updateDatabase().

+ Here is the caller graph for this function:

◆ getPluginName()

ilPlugin::getPluginName ( )

Reimplemented in ExamplePlugin, and ExamplePlugin.

Definition at line 95 of file class.ilPlugin.php.

95 : string
96 {
97 return $this->getPluginInfo()->getName();
98 }

References getPluginInfo().

Referenced by ilPreviewRendererPlugin\getRendererClassInstance(), ilPageComponentPlugin\getUIClassInstance(), and ilDclFieldTypePlugin\install().

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

◆ getPluginSlotInfo()

ilPlugin::getPluginSlotInfo ( )
protected

Definition at line 154 of file class.ilPlugin.php.

155 {
156 return $this->getPluginInfo()->getPluginSlot();
157 }
Simple value class for basic information about a pluginslot.

References getPluginInfo().

Referenced by clearEventListening(), getStyleSheetLocation(), and readEventListening().

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

◆ getStyleSheetLocation()

ilPlugin::getStyleSheetLocation ( string  $a_css_file)

@deprecate ILIAS is moving towards UI components and plugins are expected to use these components.

Hence, this method will be removed.

Definition at line 382 of file class.ilPlugin.php.

382 : string
383 {
384 $d2 = $this->getComponentInfo()->getId() . "_" . $this->getPluginSlotInfo()->getId() . "_" . $this->getPluginInfo()->getId();
385
386 $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
387 if (is_int(strpos($css, "Customizing"))) {
388 return $css;
389 }
390
391 return $this->getDirectory() . "/templates/" . $a_css_file;
392 }
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user

References getComponentInfo(), getDirectory(), getPluginInfo(), getPluginSlotInfo(), and ilUtil\getStyleSheetLocation().

+ Here is the call graph for this function:

◆ getTemplate()

ilPlugin::getTemplate ( string  $a_template,
bool  $a_par1 = true,
bool  $a_par2 = true 
)

@deprecate ILIAS is moving towards UI components and plugins are expected to use these components.

Hence, this method will be removed.

Definition at line 373 of file class.ilPlugin.php.

373 : ilTemplate
374 {
375 return new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
376 }
special template class to simplify handling of ITX/PEAR

References getDirectory().

+ Here is the call graph for this function:

◆ getVersion()

ilPlugin::getVersion ( )

Only very little classes seem to care about this:

Returns
string

Definition at line 111 of file class.ilPlugin.php.

111 : string
112 {
113 return (string) $this->getPluginInfo()->getAvailableVersion();
114 }

References getPluginInfo().

+ Here is the call graph for this function:

◆ init()

ilPlugin::init ( )
protected

Object initialization.

Can be overwritten by plugin class (and should be made protected)

TODO: Maybe this should be removed or be documented better. This is called during __construct. If this contains expensive stuff this will be bad for overall system performance, because Plugins tend to be constructed a lot.

Definition at line 86 of file class.ilPlugin.php.

86 : void
87 {
88 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ install()

ilPlugin::install ( )

Reimplemented in ilDclFieldTypePlugin.

Definition at line 164 of file class.ilPlugin.php.

164 : void
165 {
166 $this->afterInstall();
167 }
afterInstall()
@deprecate If you cannot get rid of the requirement to use this, adjust the install method in your su...

References afterInstall().

+ Here is the call graph for this function:

◆ isActive()

ilPlugin::isActive ( )

Only very little classes seem to care about this:

  • Services/Component/classes/class.ilObjComponentSettingsGUI.php
  • Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php

Definition at line 131 of file class.ilPlugin.php.

131 : bool
132 {
133 return $this->getPluginInfo()->isActive();
134 }

References getPluginInfo().

+ Here is the call graph for this function:

◆ loadLanguageModule()

ilPlugin::loadLanguageModule ( )

Load language module for plugin.

@deprecate Just use txt, this will automatically load the language module.

Definition at line 351 of file class.ilPlugin.php.

351 : void
352 {
353 $this->getLanguageHandler()->loadLanguageModule();
354 }

References getLanguageHandler().

Referenced by __construct().

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

◆ needsUpdate()

ilPlugin::needsUpdate ( )

Definition at line 136 of file class.ilPlugin.php.

136 : bool
137 {
138 return $this->getPluginInfo()->isUpdateRequired();
139 }

References getPluginInfo().

Referenced by activate().

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

◆ readEventListening()

ilPlugin::readEventListening ( )
protected

Definition at line 413 of file class.ilPlugin.php.

413 : void
414 {
415 $reader = new ilPluginReader(
416 $this->getDirectory() . '/plugin.xml',
417 $this->getComponentInfo()->getType(),
418 $this->getComponentInfo()->getName(),
419 $this->getPluginSlotInfo()->getId(),
420 $this->getPluginInfo()->getName()
421 );
422 $reader->clearEvents();
423 $reader->startParsing();
424 }

References getComponentInfo(), getDirectory(), getId(), getPluginInfo(), and getPluginSlotInfo().

Referenced by update().

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

◆ txt()

ilPlugin::txt ( string  $a_var)

Get Language Variable (prefix will be prepended automatically)

Definition at line 359 of file class.ilPlugin.php.

359 : string
360 {
361 return $this->getLanguageHandler()->txt($a_var);
362 }

References getLanguageHandler().

+ Here is the call graph for this function:

◆ uninstall()

ilPlugin::uninstall ( )

Definition at line 169 of file class.ilPlugin.php.

169 : bool
170 {
171 if (!$this->beforeUninstall()) {
172 return false;
173 }
174
175 $this->getLanguageHandler()->uninstall();
176 $this->clearEventListening();
177 $this->component_repository->removeStateInformationOf($this->getId());
178 $this->afterUninstall();
179 return true;
180 }
afterUninstall()
@deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your ...
beforeUninstall()
@deprecate If you cannot get rid of the requirement to use this, adjust the uninstall method in your ...

References afterUninstall(), beforeUninstall(), clearEventListening(), getId(), and getLanguageHandler().

+ Here is the call graph for this function:

◆ update()

ilPlugin::update ( )

Definition at line 269 of file class.ilPlugin.php.

269 : bool
270 {
271 global $DIC;
272 $ilDB = $DIC->database();
273
274 $result = $this->beforeUpdate();
275 if ($result === false) {
276 return false;
277 }
278
279 // Load language files
280 $this->getLanguageHandler()->updateLanguages();
281
282 // DB update
283 $db_version = $this->updateDatabase();
284
285 $this->readEventListening();
286
287 // set last update version to current version
288 $this->component_repository->setCurrentPluginVersion(
289 $this->getPluginInfo()->getId(),
290 $this->getPluginInfo()->getAvailableVersion(),
291 $db_version
292 );
293 $this->afterUpdate();
294
295 return true;
296 }
beforeUpdate()
@deprecate If you cannot get rid of the requirement to use this, adjust the update method in your sub...
global $DIC
Definition: feed.php:28

References $DIC, $ilDB, afterUpdate(), beforeUpdate(), getId(), getLanguageHandler(), getPluginInfo(), readEventListening(), and updateDatabase().

Referenced by activate().

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

◆ updateDatabase()

ilPlugin::updateDatabase ( )
protected

Definition at line 298 of file class.ilPlugin.php.

298 : int
299 {
300 global $DIC;
301 $ilDB = $DIC->database();
302 $lng = $DIC->language();
303
304 $dbupdate = new ilPluginDBUpdate(
305 $this->db,
306 $this->getPluginInfo()
307 );
308
309 $dbupdate->applyUpdate();
310
311 return $dbupdate->getCurrentVersion();
312 }
Database Update class.
$lng

References $DIC, $ilDB, $lng, and getPluginInfo().

Referenced by update().

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

Field Documentation

◆ $component_repository

◆ $db

◆ $id

string ilPlugin::$id
protected

Definition at line 35 of file class.ilPlugin.php.

Referenced by ilTestExportPlugin\__construct(), and __construct().

◆ $lang_initialised

bool ilPlugin::$lang_initialised = false
protected

Definition at line 37 of file class.ilPlugin.php.

◆ $language_handler

ilPluginLanguage ilPlugin::$language_handler = null
protected

Definition at line 36 of file class.ilPlugin.php.

Referenced by getLanguageHandler().

◆ $message

string ilPlugin::$message = ''
protected

Definition at line 39 of file class.ilPlugin.php.

Referenced by getMessage().

◆ $provider_collection

ProviderCollection ilPlugin::$provider_collection
protected

Definition at line 38 of file class.ilPlugin.php.

Referenced by getGlobalScreenProviderCollection().


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