Fix target-dir autoloader
parent
6a50dbd46d
commit
aff7745231
|
@ -88,12 +88,12 @@ EOF;
|
||||||
$prefixes = implode(', ', array_map(function ($prefix) {
|
$prefixes = implode(', ', array_map(function ($prefix) {
|
||||||
return var_export($prefix, true);
|
return var_export($prefix, true);
|
||||||
}, array_keys($mainAutoload['psr-0'])));
|
}, array_keys($mainAutoload['psr-0'])));
|
||||||
$baseDirFromTargetDirCode = $filesystem->findShortestPathCode(realpath($targetDir), getcwd(), true);
|
$baseDirFromVendorDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
|
||||||
|
|
||||||
$targetDirLoader = <<<EOF
|
$targetDirLoader = <<<EOF
|
||||||
spl_autoload_register(function(\$class) {
|
spl_autoload_register(function(\$class) {
|
||||||
static \$dir = $baseDirFromTargetDirCode . '/';
|
\$dir = $baseDirFromVendorDirCode . '/';
|
||||||
static \$prefixes = array($prefixes);
|
\$prefixes = array($prefixes);
|
||||||
foreach (\$prefixes as \$prefix) {
|
foreach (\$prefixes as \$prefix) {
|
||||||
if (0 !== strpos(\$class, \$prefix)) {
|
if (0 !== strpos(\$class, \$prefix)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -20,8 +20,8 @@ return call_user_func(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(function($class) {
|
spl_autoload_register(function($class) {
|
||||||
static $dir = dirname(dirname(__DIR__)) . '/';
|
$dir = dirname(__DIR__) . '/';
|
||||||
static $prefixes = array('Main\\Foo', 'Main\\Bar');
|
$prefixes = array('Main\\Foo', 'Main\\Bar');
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($prefixes as $prefix) {
|
||||||
if (0 !== strpos($class, $prefix)) {
|
if (0 !== strpos($class, $prefix)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue