1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
namespace Icinga\Module\Director\Objects;
use Icinga\Module\Director\Data\Db\DbObject;
use RuntimeException;
class DirectorDatalistEntry extends DbObject
{
protected $keyName = ['list_id', 'entry_name'];
protected $table = 'director_datalist_entry';
private $shouldBeRemoved = false;
protected $defaultProperties = [
'list_id' => null,
'entry_name' => null,
'entry_value' => null,
'format' => null,
'allowed_roles' => null,
];
/**
* @param DirectorDatalist $list
* @return static[]
*/
public static function loadAllForList(DirectorDatalist $list)
{
$query = $list->getDb()
->select()
->from('director_datalist_entry')
->where('list_id = ?', $list->get('id'))
->order('entry_name ASC');
return static::loadAll($list->getConnection(), $query, 'entry_name');
}
/**
* @param $roles
* @codingStandardsIgnoreStart
*/
public function setAllowed_roles($roles)
{
// @codingStandardsIgnoreEnd
$key = 'allowed_roles';
if (is_array($roles)) {
$this->reallySet($key, json_encode($roles));
} elseif (null === $roles) {
$this->reallySet($key, null);
} else {
throw new RuntimeException(
'Expected array or null for allowed_roles, got %s',
var_export($roles, 1)
);
}
}
/**
* @return array|null
* @codingStandardsIgnoreStart
*/
public function getAllowed_roles()
{
// @codingStandardsIgnoreEnd
$roles = $this->getProperty('allowed_roles');
if (is_string($roles)) {
return json_decode($roles);
} else {
return $roles;
}
}
public function replaceWith(DirectorDatalistEntry $object)
{
$this->set('entry_value', $object->get('entry_value'));
if ($object->get('format')) {
$this->set('format', $object->get('format'));
}
return $this;
}
public function merge(DirectorDatalistEntry $object)
{
return $this->replaceWith($object);
}
public function markForRemoval($remove = true)
{
$this->shouldBeRemoved = $remove;
return $this;
}
public function shouldBeRemoved()
{
return $this->shouldBeRemoved;
}
public function onInsert()
{
}
public function onUpdate()
{
}
public function onDelete()
{
}
}
|