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
|
|
|
* @package Pimple |
14
|
|
|
* |
15
|
|
|
* @property \debug $debug |
16
|
|
|
* @property \db_mysql $db |
17
|
|
|
* @property \classCache $cache |
18
|
|
|
* @property \classConfig $config |
19
|
|
|
* @property \classLocale $localePlayer |
20
|
|
|
* @property \DbQueryConstructor $query |
21
|
|
|
* @property \DbRowDirectOperator $dbGlobalRowOperator |
22
|
|
|
* @property \SnDbCachedOperator $cacheOperator - really DB record operator. But let it be |
23
|
|
|
* @property string $snCacheClass |
24
|
|
|
* @property \SnCache $snCache |
25
|
|
|
* @property \Common\Types $types |
26
|
|
|
* @property string $buddyClass |
27
|
|
|
* @property \Buddy\BuddyModel $buddyModel |
28
|
|
|
* @property \V2Unit\V2UnitModel $unitModel |
29
|
|
|
* @property V2FleetModel $fleetModel |
30
|
|
|
*/ |
31
|
|
|
class GlobalContainer extends ContainerPlus { |
32
|
|
|
|
33
|
|
|
public function __construct(array $values = array()) { |
34
|
|
|
parent::__construct($values); |
35
|
|
|
|
36
|
|
|
$gc = $this; |
37
|
|
|
|
38
|
|
|
// Default db |
39
|
|
|
$gc->db = function ($c) { |
40
|
|
|
classSupernova::$db = $db = new \db_mysql($c); |
41
|
|
|
|
42
|
|
|
return $db; |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
$gc->debug = function ($c) { |
|
|
|
|
46
|
|
|
return new \debug(); |
47
|
|
|
}; |
48
|
|
|
|
49
|
|
|
$gc->types = function ($c) { |
|
|
|
|
50
|
|
|
return new \Common\Types(); |
51
|
|
|
}; |
52
|
|
|
|
53
|
|
|
$gc->cache = function ($c) { |
|
|
|
|
54
|
|
|
return new \classCache(classSupernova::$cache_prefix); |
55
|
|
|
}; |
56
|
|
|
|
57
|
|
|
$gc->config = function ($c) { |
|
|
|
|
58
|
|
|
return new \classConfig(classSupernova::$cache_prefix); |
59
|
|
|
}; |
60
|
|
|
|
61
|
|
|
$gc->localePlayer = function (GlobalContainer $c) { |
62
|
|
|
return new \classLocale($c->config->server_locale_log_usage); |
63
|
|
|
}; |
64
|
|
|
|
65
|
|
|
$gc->dbGlobalRowOperator = function (GlobalContainer $c) { |
66
|
|
|
return new \DbRowDirectOperator($c->db); |
|
|
|
|
67
|
|
|
}; |
68
|
|
|
|
69
|
|
|
$gc->query = $gc->factory(function (GlobalContainer $c) { |
70
|
|
|
return new \DbQueryConstructor($c->db); |
|
|
|
|
71
|
|
|
}); |
72
|
|
|
|
73
|
|
|
$gc->cacheOperator = function (GlobalContainer $gc) { |
74
|
|
|
return new \SnDbCachedOperator($gc); |
75
|
|
|
}; |
76
|
|
|
|
77
|
|
|
$gc->snCacheClass = 'SnCache'; |
78
|
|
|
$gc->snCache = function (GlobalContainer $gc) { |
79
|
|
|
return $gc->db->snCache; |
80
|
|
|
}; |
81
|
|
|
|
82
|
|
|
$gc->buddyClass = 'Buddy\BuddyModel'; |
83
|
|
|
$gc->buddyModel = function (GlobalContainer $c) { |
84
|
|
|
return new $c->buddyClass($c); |
85
|
|
|
}; |
86
|
|
|
|
87
|
|
|
$gc->unitModel = function (GlobalContainer $c) { |
88
|
|
|
return new \V2Unit\V2UnitModel($c); |
89
|
|
|
}; |
90
|
|
|
|
91
|
|
|
$gc->fleetModel = function (GlobalContainer $c) { |
92
|
|
|
return new V2FleetModel($c); |
93
|
|
|
}; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
} |
97
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.