Skip to content
Browse files

JLoader : Files located at the root path, where the prefix is registe…

…red, cannot be autoloaded.
  • Loading branch information...
1 parent ba640b7 commit 06659f7240154ae580e0fb5ec00daf826a2acb6b @florianv florianv committed
Showing with 24 additions and 2 deletions.
  1. +24 −2 libraries/loader.php
View
26 libraries/loader.php
@@ -318,8 +318,17 @@ private static function _load($class, $lookup)
// Split the class name into parts separated by camelCase.
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class);
- // If there is only one part we want to duplicate that part for generating the path.
- $parts = (count($parts) === 1) ? array($parts[0], $parts[0]) : $parts;
+ $fileName = false;
+
+ // If there is only one part.
+ if (count($parts) == 1)
+ {
+ // Keep the possible file name.
+ $fileName = $parts[0];
+
+ // Duplicate that part for generating the path.
+ $parts = array($parts[0], $parts[0]);
+ }
foreach ($lookup as $base)
{
@@ -331,6 +340,19 @@ private static function _load($class, $lookup)
{
return include $path;
}
+
+ // If there is only one part.
+ if ($fileName)
+ {
+ // Try to include the class that might be located in the root folder.
+ $path = $base . '/' . strtolower($fileName) . '.php';
+
+ // Load the file if it exists.
+ if (file_exists($path))
+ {
+ return include $path;
+ }
+ }
}
}
}

0 comments on commit 06659f7

Please sign in to comment.
Something went wrong with that request. Please try again.