ILIAS  release_8 Revision v8.24
class.ilSettingsFactory.php
Go to the documentation of this file.
1<?php
2
3declare(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.
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}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
settingsFor(string $a_module="common")
Get setting instance for module.
__construct(\ilDBInterface $db)
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200