1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* autoload of the framework |
5
|
|
|
* use the PSR-0 |
6
|
|
|
* |
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/venus3/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
10
|
|
|
* @version Release: 2.0.0.0 |
11
|
|
|
* @filesource https://github.com/las93/venus3 |
12
|
|
|
* @link https://github.com/las93 |
13
|
|
|
* @since 3.0.0.0 |
14
|
|
|
* |
15
|
|
|
* new version with SPL to have the capacity to add external autoload |
16
|
|
|
*/ |
17
|
|
|
spl_autoload_register(function (string $sClassName) |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
$sClassName = ltrim($sClassName, '\\'); |
21
|
|
|
$sFileName = ''; |
22
|
|
|
$iLastNsPos = strrpos($sClassName, '\\'); |
23
|
|
|
|
24
|
|
|
if ($iLastNsPos) { |
25
|
|
|
|
26
|
|
|
$sNamespace = substr($sClassName, 0, $iLastNsPos); |
27
|
|
|
$sClassName = substr($sClassName, $iLastNsPos + 1); |
28
|
|
|
$sFileName = str_replace('\\', DIRECTORY_SEPARATOR, $sNamespace).DIRECTORY_SEPARATOR; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$sFileName = str_replace('/', '\\', $sFileName); |
32
|
|
|
|
33
|
|
|
$sFileName .= $sClassName.'.php'; |
34
|
|
|
|
35
|
|
|
if (defined('PORTAL')) { |
36
|
|
|
|
37
|
|
|
$sFileClassName = str_replace(PORTAL, PORTAL.DIRECTORY_SEPARATOR.'app', str_replace(['\\', '/'], DIRECTORY_SEPARATOR, str_replace('conf', DIRECTORY_SEPARATOR, __DIR__).str_replace('Venus\\', '', $sFileName))); |
38
|
|
|
$sFileClassName = preg_replace('/(tests\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
39
|
|
|
$sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName); |
40
|
|
|
$sFileClassName = str_replace('\\\\', '\\', $sFileClassName); |
41
|
|
|
$sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName); |
42
|
|
|
$sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName); |
43
|
|
|
$sFileClassName = str_replace('app\\app', 'app', $sFileClassName); |
44
|
|
|
$sFileClassName = str_replace('app/app', 'app', $sFileClassName); |
45
|
|
|
|
46
|
|
|
if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) { |
47
|
|
|
|
48
|
|
|
require $sFileClassName; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
else { |
52
|
|
|
|
53
|
|
|
if (strstr($sFileName, 'Venus\\') && file_exists(preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))))) { |
54
|
|
|
|
55
|
|
|
require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__).str_replace('Venus\\', '', $sFileName))); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Load the composer autoload |
62
|
|
|
*/ |
63
|
|
|
|
64
|
|
|
if (file_exists(preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php')) { |
65
|
|
|
|
66
|
|
|
include preg_replace('#bundles[/\\\\]conf#', '', __DIR__).'vendor/autoload.php'; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Load the autoload file (or simple files) defined in the Const.conf |
71
|
|
|
*/ |
72
|
|
|
|
73
|
|
|
$oConfig = \Venus\core\Config::get('Const'); |
|
|
|
|
74
|
|
|
|
75
|
|
|
if (isset($oConfig) && isset($oConfig->autoload)) { |
76
|
|
|
|
77
|
|
|
$oAutoloadConf = $oConfig->autoload; |
78
|
|
|
|
79
|
|
|
foreach ($oAutoloadConf as $sFile) { |
80
|
|
|
|
81
|
|
|
require __DIR__.'/../'.$sFile; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.