ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 

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

214 : bool
215 {
216 if ($this->needsUpdate() && !$this->update()) {
217 return false;
218 }
219
220 if (!$this->beforeActivation()) {
221 return false;
222 }
223
224 $this->component_repository->setActivation($this->getId(), true);
225 $this->afterActivation();
226
227 return true;
228 }
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 396 of file class.ilPlugin.php.

396 : void
397 {
398 $a_tpl->addBlockFile(
399 $a_var,
400 $a_block,
401 $this->getDirectory() . "/templates/" . $a_tplname
402 );
403 }
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 251 of file class.ilPlugin.php.

251 : void
252 {
253 }

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

259 : void
260 {
261 }

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

185 : void
186 {
187 }

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

202 : void
203 {
204 }

Referenced by uninstall().

+ Here is the caller graph for this function:

◆ afterUpdate()

ilPlugin::afterUpdate ( )
protected

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

321 : void
322 {
323 }

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

242 : bool
243 {
244 return true;
245 }

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

193 : bool
194 {
195 return true;
196 }

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

315 : bool
316 {
317 return true;
318 }

Referenced by update().

+ Here is the caller graph for this function:

◆ buildLanguageHandler()

ilPlugin::buildLanguageHandler ( )
protected

Definition at line 338 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 230 of file class.ilPlugin.php.

230 : bool
231 {
232 $this->component_repository->setActivation($this->getId(), false);
233 $this->afterDeactivation();
234
235 return true;
236 }
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 451 of file class.ilPlugin.php.

451 : Closure
452 {
453 //This returns the callable of $c[$key] without executing it.
454 return $dic->raw($dic_key);
455 }
$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 431 of file class.ilPlugin.php.

431 : Closure
432 {
433 //This returns the callable of $c['ui.renderer'] without executing it.
434 return $dic->raw('ui.renderer');
435 }

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 getStyleSheetLocation().

+ 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:

  • Services/COPage/classes/class.ilPCPlugged.php
  • Modules/DataCollection/classes/Fields/class.ilDclFieldFactory.php

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

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

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

411 {
413 }
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 330 of file class.ilPlugin.php.

331 {
332 if ($this->language_handler === null) {
333 $this->language_handler = $this->buildLanguageHandler();
334 }
336 }
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(), getComponentInfo(), getDirectory(), getId(), getPluginName(), getPluginSlotInfo(), 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 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 getStyleSheetLocation().

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

379 : string
380 {
381 $d2 = $this->getComponentInfo()->getId() . "_" . $this->getPluginSlotInfo()->getId() . "_" . $this->getPluginInfo()->getId();
382
383 $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
384 if (is_int(strpos($css, "Customizing"))) {
385 return $css;
386 }
387
388 return $this->getDirectory() . "/templates/" . $a_css_file;
389 }
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 370 of file class.ilPlugin.php.

370 : ilTemplate
371 {
372 return new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
373 }
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 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 348 of file class.ilPlugin.php.

348 : void
349 {
350 $this->getLanguageHandler()->loadLanguageModule();
351 }

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:

◆ txt()

ilPlugin::txt ( string  $a_var)

Get Language Variable (prefix will be prepended automatically)

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

356 : string
357 {
358 return $this->getLanguageHandler()->txt($a_var);
359 }

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

169 : bool
170 {
171 if (!$this->beforeUninstall()) {
172 return false;
173 }
174
175 $this->getLanguageHandler()->uninstall();
176 $this->component_repository->removeStateInformationOf($this->getId());
177 $this->afterUninstall();
178 return true;
179 }
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 268 of file class.ilPlugin.php.

268 : bool
269 {
270 global $DIC;
271 $ilDB = $DIC->database();
272
273 $result = $this->beforeUpdate();
274 if ($result === false) {
275 return false;
276 }
277
278 // Load language files
279 $this->getLanguageHandler()->updateLanguages();
280
281 // DB update
282 $db_version = $this->updateDatabase();
283
284 // set last update version to current version
285 $this->component_repository->setCurrentPluginVersion(
286 $this->getPluginInfo()->getId(),
287 $this->getPluginInfo()->getAvailableVersion(),
288 $db_version
289 );
290 $this->afterUpdate();
291
292 return true;
293 }
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 295 of file class.ilPlugin.php.

295 : int
296 {
297 global $DIC;
298 $ilDB = $DIC->database();
299 $lng = $DIC->language();
300
301 $dbupdate = new ilPluginDBUpdate(
302 $ilDB,
303 $this->getPluginInfo()
304 );
305
306 $dbupdate->applyUpdate();
307
308 return $dbupdate->getCurrentVersion();
309 }
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: