ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSettingsFactory Class Reference

A factory that builds ilSettings that can be used for DI. 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

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.

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

References $db.

Member Function Documentation

◆ settingsFor()

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

Get setting instance for module.

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

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.
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 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $db, $DIC, and $GLOBALS.

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: