|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Common; |
|
4
|
|
|
|
|
5
|
|
|
use \classSupernova; |
|
6
|
|
|
use V2Fleet\V2FleetModel; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class GlobalContainer |
|
10
|
|
|
* |
|
11
|
|
|
* Used to describe internal structures of container |
|
12
|
|
|
* |
|
13
|
|
|
* @property \debug $debug |
|
14
|
|
|
* @property \Common\Types $types |
|
15
|
|
|
* |
|
16
|
|
|
* @property \db_mysql $db |
|
17
|
|
|
* @property \DbQueryConstructor $query |
|
18
|
|
|
* @property \DbRowDirectOperator $dbGlobalRowOperator |
|
19
|
|
|
* @property \SnDbCachedOperator $cacheOperator - really DB record operator. But let it be |
|
20
|
|
|
* |
|
21
|
|
|
* @property \classCache $cache |
|
22
|
|
|
* @property \classConfig $config |
|
23
|
|
|
* @property \classLocale $localePlayer |
|
24
|
|
|
* |
|
25
|
|
|
* @property string $snCacheClass |
|
26
|
|
|
* @property \SnCache $snCache |
|
27
|
|
|
* |
|
28
|
|
|
* @property string $buddyClass |
|
29
|
|
|
* @property \Buddy\BuddyModel $buddyModel |
|
30
|
|
|
* |
|
31
|
|
|
* @property \V2Unit\V2UnitModel $unitModel |
|
32
|
|
|
* @property \V2Unit\V2UnitList $unitList |
|
33
|
|
|
* |
|
34
|
|
|
* @property V2FleetModel $fleetModel |
|
35
|
|
|
* |
|
36
|
|
|
* |
|
37
|
|
|
* @property array $groupFleet |
|
38
|
|
|
* @property array $groupFleetAndMissiles |
|
39
|
|
|
* @property array $groupRecyclers |
|
40
|
|
|
* |
|
41
|
|
|
* @package Common |
|
42
|
|
|
*/ |
|
43
|
|
|
class GlobalContainer extends ContainerPlus { |
|
44
|
|
|
|
|
45
|
|
|
public function __construct(array $values = array()) { |
|
46
|
|
|
parent::__construct($values); |
|
47
|
|
|
|
|
48
|
|
|
$gc = $this; |
|
49
|
|
|
|
|
50
|
|
|
// Default db |
|
51
|
|
|
$gc->db = function ($c) { |
|
52
|
|
|
classSupernova::$db = $db = new \db_mysql($c); |
|
53
|
|
|
|
|
54
|
|
|
return $db; |
|
55
|
|
|
}; |
|
56
|
|
|
|
|
57
|
|
|
$gc->debug = function ($c) { |
|
|
|
|
|
|
58
|
|
|
return new \debug(); |
|
59
|
|
|
}; |
|
60
|
|
|
|
|
61
|
|
|
$gc->types = function ($c) { |
|
|
|
|
|
|
62
|
|
|
return new \Common\Types(); |
|
63
|
|
|
}; |
|
64
|
|
|
|
|
65
|
|
|
$gc->cache = function ($c) { |
|
|
|
|
|
|
66
|
|
|
return new \classCache(classSupernova::$cache_prefix); |
|
67
|
|
|
}; |
|
68
|
|
|
|
|
69
|
|
|
$gc->config = function ($c) { |
|
|
|
|
|
|
70
|
|
|
return new \classConfig(classSupernova::$cache_prefix); |
|
71
|
|
|
}; |
|
72
|
|
|
|
|
73
|
|
|
$gc->localePlayer = function (GlobalContainer $c) { |
|
74
|
|
|
return new \classLocale($c->config->server_locale_log_usage); |
|
75
|
|
|
}; |
|
76
|
|
|
|
|
77
|
|
|
$gc->dbGlobalRowOperator = function (GlobalContainer $c) { |
|
78
|
|
|
return new \DbRowDirectOperator($c->db); |
|
|
|
|
|
|
79
|
|
|
}; |
|
80
|
|
|
|
|
81
|
|
|
$gc->query = $gc->factory(function (GlobalContainer $c) { |
|
82
|
|
|
return new \DbQueryConstructor($c->db); |
|
|
|
|
|
|
83
|
|
|
}); |
|
84
|
|
|
|
|
85
|
|
|
$gc->cacheOperator = function (GlobalContainer $gc) { |
|
86
|
|
|
return new \SnDbCachedOperator($gc); |
|
87
|
|
|
}; |
|
88
|
|
|
|
|
89
|
|
|
$gc->snCacheClass = 'SnCache'; |
|
90
|
|
|
$gc->snCache = function (GlobalContainer $gc) { |
|
91
|
|
|
return $gc->db->snCache; |
|
92
|
|
|
}; |
|
93
|
|
|
|
|
94
|
|
|
$gc->buddyClass = 'Buddy\BuddyModel'; |
|
95
|
|
|
$gc->buddyModel = function (GlobalContainer $c) { |
|
96
|
|
|
return new $c->buddyClass($c); |
|
97
|
|
|
}; |
|
98
|
|
|
|
|
99
|
|
|
$gc->unitModel = function (GlobalContainer $c) { |
|
100
|
|
|
return new \V2Unit\V2UnitModel($c); |
|
101
|
|
|
}; |
|
102
|
|
|
$gc->unitList = $this->factory(function (GlobalContainer $c) { |
|
103
|
|
|
return new \V2Unit\V2UnitList($c); |
|
104
|
|
|
}); |
|
105
|
|
|
|
|
106
|
|
|
$gc->fleetModel = function (GlobalContainer $c) { |
|
107
|
|
|
return new V2FleetModel($c); |
|
108
|
|
|
}; |
|
109
|
|
|
|
|
110
|
|
|
$gc->groupFleet = function (GlobalContainer $c) { |
|
|
|
|
|
|
111
|
|
|
return sn_get_groups('fleet'); |
|
112
|
|
|
}; |
|
113
|
|
|
|
|
114
|
|
|
$gc->groupFleetAndMissiles = function (GlobalContainer $c) { |
|
|
|
|
|
|
115
|
|
|
return sn_get_groups(array('fleet', GROUP_STR_MISSILES)); |
|
116
|
|
|
}; |
|
117
|
|
|
|
|
118
|
|
|
$gc->groupRecyclers = function (GlobalContainer $c) { |
|
|
|
|
|
|
119
|
|
|
return sn_get_groups('flt_recyclers'); |
|
120
|
|
|
}; |
|
121
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.