ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSettingsFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 {
28  protected ilDBInterface $db;
29 
30  public function __construct(\ilDBInterface $db)
31  {
32  $this->db = $db;
33  }
34 
38  public function settingsFor(string $a_module = "common"): 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  }
68 }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $DIC
Definition: feed.php:28
__construct(\ilDBInterface $db)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
settingsFor(string $a_module="common")
Get setting instance for module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...