ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 currernt module. More...
 

Protected Attributes

 $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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSettingsFactory::__construct ( \ilDBInterface  $db)

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

References $db.

40  {
41  $this->db = $db;
42  }

Member Function Documentation

◆ settingsFor()

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

Get currernt module.

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

References $db, $DIC, and $GLOBALS.

48  {
49  $tmp_dic = $GLOBALS["DIC"] ?? null;
50  try {
51  // ilSetting pulls the database once in the constructor, we force it to
52  // use ours.
54  $DIC["ilDB"] = $this->db;
55  $DIC["ilBench"] = null;
56  $GLOBALS["DIC"] = $DIC;
57 
58  // Always load from db, as caching could be implemented as a
59  // decorator to this.
60  $settings = new ilSetting($a_module, true);
61 
62  // Provoke a setting to populate the value_type in ilSettings,
63  // use a field that is likely to exist.
64  $settings->set(
65  "common",
66  "system_user_id",
67  $settings->get("common", "system_user_id")
68  );
69  } finally {
70  $GLOBALS["DIC"] = $tmp_dic;
71  }
72 
73  return $settings;
74  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$DIC
Definition: xapitoken.php:46

Field Documentation

◆ $db

ilSettingsFactory::$db
protected

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

Referenced by __construct(), and settingsFor().


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