2016-07-08 22:35:07 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2020-03-11 12:10:59 +03:00
|
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
2016-07-08 22:35:07 +03:00
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.2.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
function register($namespace, $path) {
|
2016-07-09 11:23:40 +03:00
|
|
|
spl_autoload_register(function ($class) use ($namespace, $path) {
|
2016-07-08 22:35:07 +03:00
|
|
|
// project-specific namespace prefix
|
|
|
|
$prefix = 'EA\\' . $namespace . '\\';
|
|
|
|
|
|
|
|
// does the class use the namespace prefix?
|
|
|
|
$len = strlen($prefix);
|
|
|
|
if (strncmp($prefix, $class, $len) !== 0) {
|
|
|
|
// no, move to the next registered autoloader
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the relative class name
|
|
|
|
$relative_class = substr($class, $len);
|
|
|
|
|
|
|
|
// replace the namespace prefix with the base directory, replace namespace
|
|
|
|
// separators with directory separators in the relative class name, append
|
|
|
|
// with .php
|
2016-07-09 11:23:40 +03:00
|
|
|
$file = $path . '/' . str_replace('\\', '/', $relative_class) . '.php';
|
2016-07-08 22:35:07 +03:00
|
|
|
|
|
|
|
// if the file exists, require it
|
|
|
|
if (file_exists($file)) {
|
|
|
|
require $file;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
register('Engine', __DIR__ . '/engine');
|
2019-06-08 17:20:14 +03:00
|
|
|
register('Themes', __DIR__ . '/themes');
|
|
|
|
register('Plugins', __DIR__ . '/plugins');
|