|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by Gorlum 29.07.2016 13:18 |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace V2Unit; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class V2UnitModel |
|
10
|
|
|
* |
|
11
|
|
|
* Second iteration of revised Unit |
|
12
|
|
|
* |
|
13
|
|
|
* @property int $playerOwnerId |
|
14
|
|
|
* @property int $locationType |
|
15
|
|
|
* @property int $locationId |
|
16
|
|
|
* @property int $type |
|
17
|
|
|
* @property int $snId |
|
18
|
|
|
* @property int $dbLevel - level of unit for DB: $count for stackable units, $level - fon unstackable units |
|
19
|
|
|
* @property int $level // TODO |
|
20
|
|
|
* property int $count // TODO |
|
21
|
|
|
* property \DateTime $timeStart // TODO |
|
22
|
|
|
* property \DateTime $timeFinish // TODO |
|
23
|
|
|
* |
|
24
|
|
|
* @package V2Unit |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
class V2UnitModel extends \Entity { |
|
28
|
|
|
|
|
29
|
|
|
protected static $tableName = 'unit'; |
|
30
|
|
|
protected static $idField = 'unit_id'; |
|
31
|
|
|
|
|
32
|
|
|
protected static $_properties = array( |
|
33
|
|
|
'dbId' => array( |
|
34
|
|
|
P_DB_FIELD => 'unit_id', |
|
35
|
|
|
), |
|
36
|
|
|
'playerOwnerId' => array( |
|
37
|
|
|
P_DB_FIELD => 'unit_player_id', |
|
38
|
|
|
), |
|
39
|
|
|
'locationType' => array( |
|
40
|
|
|
P_DB_FIELD => 'unit_location_type', |
|
41
|
|
|
), |
|
42
|
|
|
'locationId' => array( |
|
43
|
|
|
P_DB_FIELD => 'unit_location_id', |
|
44
|
|
|
), |
|
45
|
|
|
'type' => array( |
|
46
|
|
|
P_DB_FIELD => 'unit_type', |
|
47
|
|
|
), |
|
48
|
|
|
'snId' => array( |
|
49
|
|
|
P_DB_FIELD => 'unit_snid', |
|
50
|
|
|
), |
|
51
|
|
|
// Order is important! |
|
52
|
|
|
'dbLevel' => array( |
|
53
|
|
|
// TODO - aggregate function from Level/Count |
|
54
|
|
|
P_DB_FIELD => 'unit_level', |
|
55
|
|
|
), |
|
56
|
|
|
|
|
57
|
|
|
// TODO - split dbLevel to level and count |
|
58
|
|
|
'level' => array(), |
|
59
|
|
|
'count' => array(), |
|
60
|
|
|
|
|
61
|
|
|
// TODO - move to child class |
|
62
|
|
|
'timeStart' => array( |
|
63
|
|
|
P_DB_FIELD => 'unit_time_start', |
|
64
|
|
|
), |
|
65
|
|
|
'timeFinish' => array( |
|
66
|
|
|
P_DB_FIELD => 'unit_time_finish', |
|
67
|
|
|
), |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
public function __construct(\Common\GlobalContainer $gc) { |
|
71
|
|
|
parent::__construct($gc); |
|
72
|
|
|
|
|
73
|
|
|
// TODO - remove and check how it's works |
|
74
|
|
|
$this->_container = new static::$_containerName(); |
|
75
|
|
|
$this->_container->setProperties(static::$_properties); |
|
76
|
|
|
|
|
77
|
|
|
$that = $this; |
|
78
|
|
|
$this->_container->assignAccessor( |
|
79
|
|
|
'type', |
|
80
|
|
|
P_CONTAINER_SETTER, |
|
81
|
|
|
function ($value) use ($that) { |
|
82
|
|
|
$that->type = $value; |
|
83
|
|
|
} |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
$this->_container->assignAccessor( |
|
87
|
|
|
'level', |
|
88
|
|
|
P_CONTAINER_IMPORTER, |
|
89
|
|
|
function (&$row) use ($that) { |
|
90
|
|
|
$that->level = $row['unit_level']; |
|
91
|
|
|
} |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
$this->_container->assignAccessor( |
|
95
|
|
|
'dbLevel', |
|
96
|
|
|
P_CONTAINER_EXPORTER, |
|
97
|
|
|
function (&$row) use ($that) { |
|
98
|
|
|
$row['unit_level'] = $that->dbLevel; |
|
99
|
|
|
} |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|