1
|
|
|
<?php |
2
|
|
|
namespace modules\bataille\app\controller; |
3
|
|
|
|
4
|
|
|
use core\database\Database; |
5
|
|
|
|
6
|
|
|
class InitialiseClass { |
7
|
|
|
protected static $ressource; |
8
|
|
|
protected static $base; |
9
|
|
|
protected static $batiment; |
10
|
|
|
protected static $unite; |
11
|
|
|
protected static $groupe_unite; |
12
|
|
|
protected static $centre_recherche; |
13
|
|
|
protected static $missions_aleatoire; |
14
|
|
|
protected static $database; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
|
18
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
19
|
|
|
|
20
|
|
|
//initilisation of all classes of battle |
21
|
|
|
//initialisation of Ressource class |
22
|
|
|
public static function getRessource() { |
23
|
|
|
if (self::$ressource == null) { |
24
|
|
|
self::$ressource = new Ressource(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
return self::$ressource; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
//initialisation of Base class |
31
|
|
|
public static function getBase() { |
32
|
|
|
if (self::$base == null) { |
33
|
|
|
self::$base = new Base(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
return self::$base; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
//initialisation of Batiment class |
40
|
|
|
public static function getBatiment() { |
41
|
|
|
if (self::$batiment == null) { |
42
|
|
|
self::$batiment = new Batiment(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return self::$batiment; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
//initialisation of Unite class |
49
|
|
|
public static function getUnite() { |
50
|
|
|
if (self::$unite == null) { |
51
|
|
|
self::$unite = new Unite(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return self::$unite; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
//initialisation of GroupeUnite class |
58
|
|
|
public static function getGoupeUnite() { |
59
|
|
|
if (self::$groupe_unite == null) { |
60
|
|
|
self::$groupe_unite = new GroupeUnite(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return self::$groupe_unite; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
//initialisation of CentreRecherche class |
67
|
|
|
public static function getCentreRecherche() { |
68
|
|
|
if (self::$centre_recherche == null) { |
69
|
|
|
self::$centre_recherche = new CentreRecherche(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return self::$centre_recherche; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
//initialisation of MissionsAleatoire class |
76
|
|
|
public static function getMissionsAleatoire() { |
77
|
|
|
if (self::$missions_aleatoire == null) { |
78
|
|
|
self::$missions_aleatoire = new MissionsAleatoire(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return self::$missions_aleatoire; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
//initialisation of Database Core connexion |
85
|
|
|
public static function getDb() { |
86
|
|
|
require_once("config.config.php"); |
87
|
|
|
|
88
|
|
|
if (self::$database == null) { |
89
|
|
|
self::$database = new Database($type_co, $dbname, $dbuser, $dbpass, $dbhost); |
|
|
|
|
90
|
|
|
} |
91
|
|
|
return self::$database; |
92
|
|
|
} |
93
|
|
|
//-------------------------- END GETTER ----------------------------------------------------------------------------// |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
97
|
|
|
//-------------------------- END SETTER ----------------------------------------------------------------------------// |
98
|
|
|
} |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.