|
10 | 10 | * Autoload de Entidades de base de datos con Spot ORM
|
11 | 11 | */
|
12 | 12 | spl_autoload_register(function ($ClassNameWithNameSpace) {
|
13 |
| - $namespace = 'Particle\Apps\Entities\\'; |
14 | 13 |
|
15 |
| - if (substr($ClassNameWithNameSpace, 0, strlen($namespace)) === $namespace) { |
16 |
| - $nameClass = substr($ClassNameWithNameSpace, strlen($namespace)); |
| 14 | + $aNamespace = array('Particle\Apps\Entities\\', 'Particle\Apps\Entities\Mapper\\'); |
17 | 15 |
|
18 |
| - $filePath = PARTICLE_PATH_APPS.'Entities'.DS.$nameClass.'.php'; |
19 |
| - |
20 |
| - if (!is_readable($filePath)) { |
21 |
| - foreach (glob(PARTICLE_PATH_APPS.'Entities'.DS.'*', GLOB_ONLYDIR) as $dir) { |
22 |
| - $subDir= basename($dir); |
23 |
| - $filePath = PARTICLE_PATH_APPS.'Entities'.DS.$subDir.DS.$nameClass.'.php'; |
24 |
| - if (is_readable($filePath)) { |
25 |
| - require_once $filePath; |
26 |
| - break; |
| 16 | + foreach ($aNamespace as $sNamespace) { |
| 17 | + if (substr($ClassNameWithNameSpace, 0, strlen($sNamespace)) === $sNamespace) { |
| 18 | + $nameClass = substr($ClassNameWithNameSpace, strlen($namespace)); |
| 19 | + |
| 20 | + $filePath = PARTICLE_PATH_APPS.'Entities'.DS.$nameClass.'.php'; |
| 21 | + |
| 22 | + if (!is_readable($filePath)) { |
| 23 | + foreach (glob(PARTICLE_PATH_APPS.'Entities'.DS.'*', GLOB_ONLYDIR) as $dir) { |
| 24 | + $subDir= basename($dir); |
| 25 | + $filePath = PARTICLE_PATH_APPS.'Entities'.DS.$subDir.DS.$nameClass.'.php'; |
| 26 | + if (is_readable($filePath)) { |
| 27 | + require_once $filePath; |
| 28 | + break; |
| 29 | + } |
27 | 30 | }
|
| 31 | + } else { |
| 32 | + require_once $filePath; |
28 | 33 | }
|
29 |
| - } else { |
30 |
| - require_once $filePath; |
31 | 34 | }
|
32 | 35 | }
|
| 36 | + |
33 | 37 | return true;
|
34 | 38 | });
|
35 | 39 |
|
|
0 commit comments