1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Oledrion; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* oledrion |
17
|
|
|
* |
18
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
19
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
20
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com/) |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use XoopsModules\Oledrion; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Chargement des handlers utilisés par le module |
27
|
|
|
*/ |
28
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
29
|
|
|
|
30
|
|
|
class HandlerManager |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Contient la liste des handlers disponibles |
34
|
|
|
* |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private $handlersNames = [ |
38
|
|
|
'oledrion_manufacturer', |
39
|
|
|
'oledrion_products', |
40
|
|
|
'oledrion_productsmanu', |
41
|
|
|
'oledrion_caddy', |
42
|
|
|
'oledrion_cat', |
43
|
|
|
'oledrion_commands', |
44
|
|
|
'oledrion_related', |
45
|
|
|
'oledrion_vat', |
46
|
|
|
'oledrion_votedata', |
47
|
|
|
'oledrion_discounts', |
48
|
|
|
'oledrion_vendors', |
49
|
|
|
'oledrion_files', |
50
|
|
|
'oledrion_persistent_cart', |
51
|
|
|
'oledrion_gateways_options', |
52
|
|
|
'oledrion_attributes', |
53
|
|
|
'oledrion_caddy_attributes', |
54
|
|
|
'oledrion_products_list', |
55
|
|
|
'oledrion_lists', |
56
|
|
|
'oledrion_delivery', |
57
|
|
|
'oledrion_location', |
58
|
|
|
'oledrion_packing', |
59
|
|
|
'oledrion_payment', |
60
|
|
|
'oledrion_location_delivery', |
61
|
|
|
'oledrion_delivery_payment', |
62
|
|
|
'oledrion_payment_log', |
63
|
|
|
]; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Contient l'unique instance de l'objet |
67
|
|
|
* @var HandlerManager |
68
|
|
|
*/ |
69
|
|
|
private static $instance = false; |
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Réceptacle des handlers |
73
|
|
|
* |
74
|
|
|
* @var array |
75
|
|
|
*/ |
76
|
|
|
public $handlers; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Méthode chargée de renvoyer les handlers de données en les chargeant à la volée |
80
|
|
|
* |
81
|
|
|
* @param string $name |
82
|
|
|
* @return mixed Null si on échoue, sinon l'objet demandé |
83
|
|
|
*/ |
84
|
|
|
public function __get($name) |
85
|
|
|
{ |
86
|
|
|
// if (0 !== strpos($name, 'h_')) { |
87
|
|
|
// return null; |
88
|
|
|
// } |
89
|
|
|
|
90
|
|
|
if (!in_array(mb_substr($name, 2), $this->handlersNames)) { |
91
|
|
|
return null; |
92
|
|
|
} |
93
|
|
|
if (!isset($this->handlersNames[$name])) { |
94
|
|
|
// $this->handlers[$name] = xoops_getModuleHandler(substr($name, 2), OLEDRION_DIRNAME); |
95
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
96
|
|
|
$class = 'Oledrion\\' . $name; |
97
|
|
|
$this->handlers[$name] = new $class($db); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
return $this->handlers[$name]; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* HandlerManager constructor. |
105
|
|
|
*/ |
106
|
|
|
private function __construct() |
107
|
|
|
{ |
108
|
|
|
$this->handlers = []; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Retourne l'instance unique de la classe |
113
|
|
|
* |
114
|
|
|
* @return HandlerManager |
115
|
|
|
*/ |
116
|
|
|
public static function getInstance() |
117
|
|
|
{ |
118
|
|
|
static $instance; |
119
|
|
|
if (null === $instance) { |
120
|
|
|
$instance = new static(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $instance; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|