|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package midcom.db |
|
4
|
|
|
* @author The Midgard Project, http://www.midgard-project.org |
|
5
|
|
|
* @copyright The Midgard Project, http://www.midgard-project.org |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* MidCOM level replacement for the Midgard Parameter record with framework support. |
|
11
|
|
|
* |
|
12
|
|
|
* The uplink is the parentguid parameter. |
|
13
|
|
|
* |
|
14
|
|
|
* @property string $domain Namespace of the parameter |
|
15
|
|
|
* @property string $name Key of the parameter |
|
16
|
|
|
* @property string $value Value of the parameter |
|
17
|
|
|
* @property string $parentguid GUID of the object the parameter extends |
|
18
|
|
|
* @package midcom.db |
|
19
|
|
|
*/ |
|
20
|
|
|
class midcom_db_parameter extends midcom_core_dbaobject |
|
21
|
|
|
{ |
|
22
|
|
|
public $__midcom_class_name__ = __CLASS__; |
|
23
|
|
|
public $__mgdschema_class_name__ = 'midgard_parameter'; |
|
24
|
|
|
|
|
25
|
|
|
public $_use_rcs = false; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Read a parameter without loading the corresponding object. |
|
29
|
|
|
* This is primarily for improving performance, so the function does not check |
|
30
|
|
|
* for privileges. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $objectguid The object's GUID |
|
33
|
|
|
* @param string $domain The parameter's domain |
|
34
|
|
|
* @param string $name The parameter to look for |
|
35
|
|
|
*/ |
|
36
|
7 |
|
public static function get_by_objectguid(string $objectguid, string $domain, string $name) |
|
37
|
|
|
{ |
|
38
|
7 |
|
static $parameter_cache = []; |
|
39
|
7 |
|
$cache_key = $objectguid . '::' . $domain . '::' . $name; |
|
40
|
|
|
|
|
41
|
7 |
|
if (!array_key_exists($cache_key, $parameter_cache)) { |
|
42
|
|
|
|
|
43
|
2 |
|
$mc = midgard_parameter::new_collector('parentguid', $objectguid); |
|
44
|
2 |
|
$mc->set_key_property('value'); |
|
45
|
2 |
|
$mc->add_constraint('name', '=', $name); |
|
46
|
2 |
|
$mc->add_constraint('domain', '=', $domain); |
|
47
|
2 |
|
$mc->set_limit(1); |
|
48
|
2 |
|
$mc->execute(); |
|
49
|
|
|
|
|
50
|
2 |
|
$parameter_cache[$cache_key] = key($mc->list_keys()); |
|
51
|
|
|
} |
|
52
|
7 |
|
return $parameter_cache[$cache_key]; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function get_label() : string |
|
56
|
|
|
{ |
|
57
|
|
|
return "{$this->domain} {$this->name}"; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|