-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathAgentFactory.class.php
More file actions
82 lines (72 loc) · 1.84 KB
/
AgentFactory.class.php
File metadata and controls
82 lines (72 loc) · 1.84 KB
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
<?php
namespace DBA;
class AgentFactory extends AbstractModelFactory {
function getModelName() {
return "Agent";
}
function getModelTable() {
return "Agent";
}
function isCachable() {
return false;
}
function getCacheValidTime() {
return -1;
}
/**
* @return Agent
*/
function getNullObject() {
$o = new Agent(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
return $o;
}
/**
* @param string $pk
* @param array $dict
* @return Agent
*/
function createObjectFromDict($pk, $dict) {
$o = new Agent($dict['agentId'], $dict['agentName'], $dict['uid'], $dict['os'], $dict['hardwareGroupId'], $dict['cmdPars'], $dict['ignoreErrors'], $dict['isActive'], $dict['isTrusted'], $dict['token'], $dict['lastAct'], $dict['lastTime'], $dict['lastIp'], $dict['userId'], $dict['cpuOnly'], $dict['clientSignature']);
return $o;
}
/**
* @param array $options
* @param bool $single
* @return Agent|Agent[]
*/
function filter($options, $single = false) {
$join = false;
if (array_key_exists('join', $options)) {
$join = true;
}
if ($single) {
if ($join) {
return parent::filter($options, $single);
}
return Util::cast(parent::filter($options, $single), Agent::class);
}
$objects = parent::filter($options, $single);
if ($join) {
return $objects;
}
$models = array();
foreach ($objects as $object) {
$models[] = Util::cast($object, Agent::class);
}
return $models;
}
/**
* @param string $pk
* @return Agent
*/
function get($pk) {
return Util::cast(parent::get($pk), Agent::class);
}
/**
* @param Agent $model
* @return Agent
*/
function save($model) {
return Util::cast(parent::save($model), Agent::class);
}
}