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