ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSettingsFactory Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilSettingsFactory:

Public Member Functions

 __construct (\ilDBInterface $db)
 
 settingsFor (string $a_module="common")
 Get setting instance for module. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning A factory that builds ilSettings that can be used for DI.

Author
Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

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

Constructor & Destructor Documentation

◆ __construct()

ilSettingsFactory::__construct ( \ilDBInterface  $db)

Definition at line 30 of file class.ilSettingsFactory.php.

References $db.

31  {
32  $this->db = $db;
33  }

Member Function Documentation

◆ settingsFor()

ilSettingsFactory::settingsFor ( string  $a_module = "common")

Get setting instance for module.

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

References $db, $DIC, $GLOBALS, and ILIAS\LTI\ToolProvider\$settings.

38  : ilSetting
39  {
40  // @todo: this function contains some open review issues which might be addressed by rklees.
41  $tmp_dic = $GLOBALS["DIC"] ?? null;//PHP8Review: This may not be a critical Global but i still would recommend to use a global call here or even better to integrate it into the classes attributes
42  try {
43  // ilSetting pulls the database once in the constructor, we force it to
44  // use ours.
45  $DIC = new ILIAS\DI\Container();
46  $DIC["ilDB"] = $this->db;
47  $DIC["ilBench"] = null;
48  $GLOBALS["DIC"] = $DIC;//PHP8Review: This may not be a critical Global but i still would recommend to use a global call here
49 
50  // Always load from db, as caching could be implemented as a
51  // decorator to this.
52  $settings = new ilSetting($a_module, true);
53 
54  // Provoke a setting to populate the value_type in ilSettings,
55  // use a field that is likely to exist.
56  // ... code was strange in < ILIAS 8 (wrong parameter count, module name for keyword, ...)
57  // use dummy instead
58  $settings->set(
59  "dummy",
60  $settings->get("dummy", "dummy")
61  );
62  } finally {
63  $GLOBALS["DIC"] = $tmp_dic;//PHP8Review: This may not be a critical Global but i still would recommend to use a global call here
64  }
65 
66  return $settings;
67  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $DIC
Definition: feed.php:28
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

Field Documentation

◆ $db

ilDBInterface ilSettingsFactory::$db
protected

Definition at line 28 of file class.ilSettingsFactory.php.

Referenced by __construct(), and settingsFor().


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