ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSettingsFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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.
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}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
ILIAS Setting Class.
A factory that builds ilSettings that can be used for DI.
settingsFor(string $a_module="common")
Get setting instance for module.
__construct(\ilDBInterface $db)
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54