Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
JLoader : Files located at the root path, where the prefix is registe…
Browse files Browse the repository at this point in the history
…red, cannot be autoloaded.
  • Loading branch information
florianv committed Aug 10, 2012
1 parent ba640b7 commit 06659f7
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions libraries/loader.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -318,8 +318,17 @@ private static function _load($class, $lookup)
// Split the class name into parts separated by camelCase. // Split the class name into parts separated by camelCase.
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class); $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. $fileName = false;
$parts = (count($parts) === 1) ? array($parts[0], $parts[0]) : $parts;
// 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) foreach ($lookup as $base)
{ {
Expand All @@ -331,6 +340,19 @@ private static function _load($class, $lookup)
{ {
return include $path; 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;
}
}
} }
} }
} }
Expand Down

0 comments on commit 06659f7

Please sign in to comment.