mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-25 17:33:19 +03:00
Corrected EA autoload function.
This commit is contained in:
parent
1a651fc718
commit
ea47793dc3
1 changed files with 2 additions and 5 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue