From ea47793dc3dfabc4517e16133a409815c866d7cc Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 9 Jul 2016 10:23:40 +0200 Subject: [PATCH] Corrected EA autoload function. --- src/autoload.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/autoload.php b/src/autoload.php index ed9b710b..01a254aa 100644 --- a/src/autoload.php +++ b/src/autoload.php @@ -12,13 +12,10 @@ * ---------------------------------------------------------------------------- */ function register($namespace, $path) { - spl_autoload_register(function ($class) { + spl_autoload_register(function ($class) use ($namespace, $path) { // project-specific namespace prefix $prefix = 'EA\\' . $namespace . '\\'; - // base directory for the namespace prefix - $base_dir = __DIR__ . '/' . $path; - // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { @@ -32,7 +29,7 @@ function register($namespace, $path) { // replace the namespace prefix with the base directory, replace namespace // separators with directory separators in the relative class name, append // with .php - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; + $file = $path . '/' . str_replace('\\', '/', $relative_class) . '.php'; // if the file exists, require it if (file_exists($file)) {