ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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 ()
 @description Return the directory provided by ilPluginInfo, please note that this is a absolute path. More...
 
 getRelativeDirectory ()
 
 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 ()
 

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 221 of file class.ilPlugin.php.

221 : bool
222 {
223 if ($this->needsUpdate() && !$this->update()) {
224 return false;
225 }
226
227 if (!$this->beforeActivation()) {
228 return false;
229 }
230
231 $this->component_repository->setActivation($this->getId(), true);
232 $this->afterActivation();
233
234 return true;
235 }
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 403 of file class.ilPlugin.php.

403 : void
404 {
405 $a_tpl->addBlockFile(
406 $a_var,
407 $a_block,
408 $this->getDirectory() . "/templates/" . $a_tplname
409 );
410 }
getDirectory()
@description Return the directory provided by ilPluginInfo, please note that this is a absolute path.

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 258 of file class.ilPlugin.php.

258 : void
259 {
260 }

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 266 of file class.ilPlugin.php.

266 : void
267 {
268 }

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 192 of file class.ilPlugin.php.

192 : void
193 {
194 }

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 209 of file class.ilPlugin.php.

209 : void
210 {
211 }

Referenced by uninstall().

+ Here is the caller graph for this function:

◆ afterUpdate()

ilPlugin::afterUpdate ( )
protected

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

328 : void
329 {
330 }

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 249 of file class.ilPlugin.php.

249 : bool
250 {
251 return true;
252 }

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 200 of file class.ilPlugin.php.

200 : bool
201 {
202 return true;
203 }

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 322 of file class.ilPlugin.php.

322 : bool
323 {
324 return true;
325 }

Referenced by update().

+ Here is the caller graph for this function:

◆ buildLanguageHandler()

ilPlugin::buildLanguageHandler ( )
protected

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

References getPluginInfo().

Referenced by getLanguageHandler().

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

◆ deactivate()

ilPlugin::deactivate ( )

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

237 : bool
238 {
239 $this->component_repository->setActivation($this->getId(), false);
240 $this->afterDeactivation();
241
242 return true;
243 }
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 458 of file class.ilPlugin.php.

458 : Closure
459 {
460 //This returns the callable of $c[$key] without executing it.
461 return $dic->raw($dic_key);
462 }
$dic
Definition: ltiresult.php:33

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 438 of file class.ilPlugin.php.

438 : Closure
439 {
440 //This returns the callable of $c['ui.renderer'] without executing it.
441 return $dic->raw('ui.renderer');
442 }

References $dic.

◆ getComponentInfo()

ilPlugin::getComponentInfo ( )
protected

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

157 {
158 return $this->getPluginInfo()->getComponent();
159 }
Simple value class for basic information about a component.

References getPluginInfo().

Referenced by getStyleSheetLocation().

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

◆ getDirectory()

ilPlugin::getDirectory ( )

@description Return the directory provided by ilPluginInfo, please note that this is a absolute path.

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

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

References getPluginInfo().

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

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

◆ getGlobalScreenProviderCollection()

ilPlugin::getGlobalScreenProviderCollection ( )
final

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

418 {
420 }
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(), ilTestExportPlugin\createExportFile(), deactivate(), ilDclFieldTypePlugin\install(), 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 337 of file class.ilPlugin.php.

338 {
339 if ($this->language_handler === null) {
340 $this->language_handler = $this->buildLanguageHandler();
341 }
343 }
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 148 of file class.ilPlugin.php.

149 {
150 return $this->component_repository
151 ->getPluginById(
152 $this->id
153 );
154 }
Simple value class for information about a plugin.

Referenced by buildLanguageHandler(), getComponentInfo(), getDirectory(), getId(), getPluginName(), getPluginSlotInfo(), getRelativeDirectory(), getStyleSheetLocation(), getVersion(), isActive(), needsUpdate(), 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 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 161 of file class.ilPlugin.php.

162 {
163 return $this->getPluginInfo()->getPluginSlot();
164 }
Simple value class for basic information about a pluginslot.

References getPluginInfo().

Referenced by getStyleSheetLocation().

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

◆ getRelativeDirectory()

ilPlugin::getRelativeDirectory ( )

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

124 : string
125 {
126 return str_replace(
127 ILIAS_ABSOLUTE_PATH . "/public/",
128 "",
129 realpath($this->getPluginInfo()->getPath())
130 );
131 }

References getPluginInfo().

+ Here is the call 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 386 of file class.ilPlugin.php.

386 : string
387 {
388 $d2 = $this->getComponentInfo()->getId() . "_" . $this->getPluginSlotInfo()->getId() . "_" . $this->getPluginInfo()->getId();
389
390 $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
391 if (is_int(strpos($css, "Customizing"))) {
392 return $css;
393 }
394
395 return $this->getDirectory() . "/templates/" . $a_css_file;
396 }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
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 377 of file class.ilPlugin.php.

377 : ilTemplate
378 {
379 return new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
380 }
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:

  • Services/COPage/classes/class.ilPCPluggedGUI.php
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 171 of file class.ilPlugin.php.

171 : void
172 {
173 $this->afterInstall();
174 }
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 138 of file class.ilPlugin.php.

138 : bool
139 {
140 return $this->getPluginInfo()->isActive();
141 }

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 355 of file class.ilPlugin.php.

355 : void
356 {
357 $this->getLanguageHandler()->loadLanguageModule();
358 }

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 143 of file class.ilPlugin.php.

143 : bool
144 {
145 return $this->getPluginInfo()->isUpdateRequired();
146 }

References getPluginInfo().

Referenced by activate().

+ 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 363 of file class.ilPlugin.php.

363 : string
364 {
365 return $this->getLanguageHandler()->txt($a_var);
366 }

References getLanguageHandler().

Referenced by ilTestExportPlugin\createExportFile().

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

◆ uninstall()

ilPlugin::uninstall ( )

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

176 : bool
177 {
178 if (!$this->beforeUninstall()) {
179 return false;
180 }
181
182 $this->getLanguageHandler()->uninstall();
183 $this->component_repository->removeStateInformationOf($this->getId());
184 $this->afterUninstall();
185 return true;
186 }
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(), getId(), and getLanguageHandler().

+ Here is the call graph for this function:

◆ update()

ilPlugin::update ( )

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

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

References $DIC, $ilDB, afterUpdate(), beforeUpdate(), getId(), getLanguageHandler(), getPluginInfo(), 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 302 of file class.ilPlugin.php.

302 : int
303 {
304 global $DIC;
305 $ilDB = $DIC->database();
306 $lng = $DIC->language();
307
308 $dbupdate = new ilPluginDBUpdate(
309 $ilDB,
310 $this->getPluginInfo()
311 );
312
313 $dbupdate->applyUpdate();
314
315 return $dbupdate->getCurrentVersion();
316 }
Database Update class.
global $lng
Definition: privfeed.php:31

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 __construct(), and ilTestExportPlugin\__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: