|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Vendor manage in factory |
|
5
|
|
|
* |
|
6
|
|
|
* @category lib |
|
7
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
8
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
9
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
10
|
|
|
* @version Release: 2.0.0 |
|
11
|
|
|
* @filesource https://github.com/las93/venus2 |
|
12
|
|
|
* @link https://github.com/las93 |
|
13
|
|
|
* @since 2.0.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
namespace Venus\lib; |
|
16
|
|
|
|
|
17
|
|
|
use \Venus\core\Config as Config; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This class manage the vendor class |
|
21
|
|
|
* |
|
22
|
|
|
* @category lib |
|
23
|
|
|
* @author Judicaël Paquet <[email protected]> |
|
24
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
|
25
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
|
26
|
|
|
* @version Release: 2.0.0 |
|
27
|
|
|
* @filesource https://github.com/las93/venus2 |
|
28
|
|
|
* @link https://github.com/las93 |
|
29
|
|
|
* @since 2.0.0 |
|
30
|
|
|
*/ |
|
31
|
|
|
class Vendor |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* cache of the vendor available |
|
35
|
|
|
* |
|
36
|
|
|
* @access private |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
private static $_aCache = null; |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* constructor - factory |
|
43
|
|
|
* To call a specific vendor, you have to call this class like this : |
|
44
|
|
|
* new \Venus\lib\Vendor('Apollina\Template'); |
|
45
|
|
|
* new \Venus\lib\Vendor('Attila\Orm'); |
|
46
|
|
|
* new \Venus\lib\Vendor('Mobile_Detect'); |
|
47
|
|
|
* |
|
48
|
|
|
* @access public |
|
49
|
|
|
* @param string $sVendorName |
|
50
|
|
|
* @param mixed $mParam |
|
51
|
|
|
* @param mixed $mParam2 |
|
52
|
|
|
* @return bool|object |
|
53
|
|
|
*/ |
|
54
|
|
|
|
|
55
|
|
|
public static function getVendor(string $sVendorName, $mParam = null, $mParam2 = null) |
|
56
|
|
|
{ |
|
57
|
|
|
if ($sVendorName === 'Apollina\Template') { |
|
58
|
|
|
|
|
59
|
|
|
$oApollina = new $sVendorName($mParam, str_replace('lib', '', __DIR__), |
|
60
|
|
|
str_replace('bundles'.DIRECTORY_SEPARATOR.'lib', CACHE_DIR, __DIR__), $mParam2); |
|
61
|
|
|
|
|
62
|
|
|
return $oApollina->addFunctionPath(__DIR__.DIRECTORY_SEPARATOR.'Functions', '\Venus\lib\Functions\\'); |
|
63
|
|
|
} |
|
64
|
|
|
else if ($sVendorName === 'Attila\Orm') { |
|
65
|
|
|
|
|
66
|
|
|
$oDbConfig = Config::get('Db')->configuration; |
|
67
|
|
|
|
|
68
|
|
|
return new $sVendorName($oDbConfig->db, $oDbConfig->type, $oDbConfig->host, $oDbConfig->user, $oDbConfig->password, |
|
69
|
|
|
$oDbConfig->db); |
|
70
|
|
|
} |
|
71
|
|
|
else if (isset($mParam) && isset($mParam2)) { |
|
72
|
|
|
|
|
73
|
|
|
return new $sVendorName($mParam, $mParam2); |
|
74
|
|
|
} |
|
75
|
|
|
else if (isset($mParam)) { |
|
76
|
|
|
|
|
77
|
|
|
return new $sVendorName($mParam); |
|
78
|
|
|
} |
|
79
|
|
|
else { |
|
80
|
|
|
|
|
81
|
|
|
return new $sVendorName; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.