ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 getStyleSheetLocation (string $a_css_file)
 ILIAS is moving towards UI components and plugins are expected to use these components. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 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 ()
 If you cannot get rid of the requirement to use this, adjust the install method in your subclass instead. More...
 
 beforeUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 afterUninstall ()
 If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass instead. More...
 
 beforeActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterActivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 afterDeactivation ()
 If you cannot get rid of the requirement to use this, adjust the activate method in your subclass instead. More...
 
 updateDatabase ()
 
 beforeUpdate ()
 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 
)

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

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

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  }
loadLanguageModule()
Load language module for plugin.
hasPluginId(string $id)
Check if a plugin exists.
string $id
ilComponentRepositoryWrite $component_repository
init()
Object initialization.
ilDBInterface $db
+ 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.

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

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  }
beforeActivation()
If you cannot get rid of the requirement to use this, adjust the activate method in your subclass ins...
afterActivation()
If you cannot get rid of the requirement to use this, adjust the activate method in your subclass ins...
+ Here is the call graph for this function:

◆ addBlockFile()

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

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.

References getDirectory().

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:
+ Here is the call graph for this function:

◆ afterActivation()

ilPlugin::afterActivation ( )
protected

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.

Referenced by activate().

251  : void
252  {
253  }
+ Here is the caller graph for this function:

◆ afterDeactivation()

ilPlugin::afterDeactivation ( )
protected

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.

Referenced by deactivate().

259  : void
260  {
261  }
+ Here is the caller graph for this function:

◆ afterInstall()

ilPlugin::afterInstall ( )
protected

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.

Referenced by install().

185  : void
186  {
187  }
+ Here is the caller graph for this function:

◆ afterUninstall()

ilPlugin::afterUninstall ( )
protected

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.

Referenced by uninstall().

202  : void
203  {
204  }
+ Here is the caller graph for this function:

◆ afterUpdate()

ilPlugin::afterUpdate ( )
protected

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

Referenced by update().

321  : void
322  {
323  }
+ Here is the caller graph for this function:

◆ beforeActivation()

ilPlugin::beforeActivation ( )
protected

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

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

Referenced by activate().

242  : bool
243  {
244  return true;
245  }
+ Here is the caller graph for this function:

◆ beforeUninstall()

ilPlugin::beforeUninstall ( )
protected

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

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

Referenced by uninstall().

193  : bool
194  {
195  return true;
196  }
+ Here is the caller graph for this function:

◆ beforeUpdate()

ilPlugin::beforeUpdate ( )
protected

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.

Referenced by update().

315  : bool
316  {
317  return true;
318  }
+ 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().

339  {
340  return new ilPluginLanguage($this->getPluginInfo());
341  }
+ 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.

References afterDeactivation(), and getId().

230  : bool
231  {
232  $this->component_repository->setActivation($this->getId(), false);
233  $this->afterDeactivation();
234 
235  return true;
236  }
afterDeactivation()
If you cannot get rid of the requirement to use this, adjust the activate method in your subclass ins...
+ 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( $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: result.php:31

◆ 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( $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  }
$dic
Definition: result.php:31

◆ getComponentInfo()

ilPlugin::getComponentInfo ( )
protected

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

References getPluginInfo().

Referenced by getStyleSheetLocation().

150  {
151  return $this->getPluginInfo()->getComponent();
152  }
Simple value class for basic information about a component.
+ 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.

References getPluginInfo().

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

121  : string
122  {
123  return $this->getPluginInfo()->getPath();
124  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGlobalScreenProviderCollection()

ilPlugin::getGlobalScreenProviderCollection ( )
final

◆ getId()

ilPlugin::getId ( )

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

References getPluginInfo().

Referenced by ilOrgUnitExtension\__construct(), ILIAS\GlobalScreen\Provider\__construct(), activate(), ilRepositoryObjectPlugin\beforeActivation(), ilRepositoryObjectPlugin\beforeUninstall(), ilTestExportPlugin\createExportFile(), deactivate(), ilDclFieldTypePlugin\install(), uninstall(), and update().

100  : string
101  {
102  return $this->getPluginInfo()->getId();
103  }
+ 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.

References $language_handler, buildLanguageHandler(), and null.

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

331  {
332  if ($this->language_handler === null) {
333  $this->language_handler = $this->buildLanguageHandler();
334  }
336  }
ilPluginLanguage $language_handler
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildLanguageHandler()
+ 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.

References $message.

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

◆ getPluginInfo()

ilPlugin::getPluginInfo ( )
protected

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

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

141  : ilPluginInfo
142  {
143  return $this->component_repository
144  ->getPluginById(
145  $this->id
146  );
147  }
Simple value class for information about a plugin.
+ Here is the caller graph for this function:

◆ getPluginName()

ilPlugin::getPluginName ( )

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

References getPluginInfo().

Referenced by ilRepositoryObjectPlugin\beforeActivation(), ilPageComponentPlugin\getUIClassInstance(), and ilDclFieldTypePlugin\install().

95  : string
96  {
97  return $this->getPluginInfo()->getName();
98  }
+ 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.

References getPluginInfo().

Referenced by getStyleSheetLocation().

155  {
156  return $this->getPluginInfo()->getPluginSlot();
157  }
Simple value class for basic information about a pluginslot.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStyleSheetLocation()

ilPlugin::getStyleSheetLocation ( string  $a_css_file)

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.

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

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
getDirectory()
Only very little classes seem to care about this:
+ Here is the call graph for this function:

◆ getTemplate()

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

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.

References getDirectory().

370  : ilTemplate
371  {
372  return new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
373  }
getDirectory()
Only very little classes seem to care about this:
+ 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.

References getPluginInfo().

111  : string
112  {
113  return (string) $this->getPluginInfo()->getAvailableVersion();
114  }
+ 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.

Referenced by __construct().

86  : void
87  {
88  }
+ Here is the caller graph for this function:

◆ install()

ilPlugin::install ( )

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

References afterInstall().

164  : void
165  {
166  $this->afterInstall();
167  }
afterInstall()
If you cannot get rid of the requirement to use this, adjust the install method in your subclass inst...
+ 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.

References getPluginInfo().

131  : bool
132  {
133  return $this->getPluginInfo()->isActive();
134  }
+ Here is the call graph for this function:

◆ loadLanguageModule()

ilPlugin::loadLanguageModule ( )

Load language module for plugin.

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

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

References getLanguageHandler().

Referenced by __construct().

348  : void
349  {
350  $this->getLanguageHandler()->loadLanguageModule();
351  }
+ 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.

References getPluginInfo().

Referenced by activate().

136  : bool
137  {
138  return $this->getPluginInfo()->isUpdateRequired();
139  }
+ 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.

References getLanguageHandler().

Referenced by ilTestExportPlugin\createExportFile().

356  : string
357  {
358  return $this->getLanguageHandler()->txt($a_var);
359  }
+ 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.

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

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  }
beforeUninstall()
If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass in...
afterUninstall()
If you cannot get rid of the requirement to use this, adjust the uninstall method in your subclass in...
+ Here is the call graph for this function:

◆ update()

ilPlugin::update ( )

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

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

Referenced by activate(), and ilObjComponentSettingsGUI\update().

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  }
global $DIC
Definition: shib_login.php:22
beforeUpdate()
If you cannot get rid of the requirement to use this, adjust the update method in your subclass inste...
+ 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.

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

Referenced by update().

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 $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $component_repository

◆ $db

ilDBInterface ilPlugin::$db
protected

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

Referenced by __construct(), and ilRepositoryObjectPlugin\beforeActivation().

◆ $id

string ilPlugin::$id
protected

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

Referenced by __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: