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