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