diff --git a/src/mibew/libs/classes/Mibew/Autoloader.php b/src/mibew/libs/classes/Mibew/Autoloader.php new file mode 100644 index 00000000..db11527e --- /dev/null +++ b/src/mibew/libs/classes/Mibew/Autoloader.php @@ -0,0 +1,82 @@ +basePath . DIRECTORY_SEPARATOR . $file_name + . str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php'; + + if (is_file($file_name)) { + include_once($file_name); + } + } + + /** + * Register a new instance as an SPL autoloader. + * + * @param string $base_path Base path for classes-to-files mapping. + * + * @return \Mibew\Autoloader Registered autoloader instance. + */ + public static function register($base_path) + { + $loader = new self($base_path); + spl_autoload_register(array($loader, 'autoload')); + + return $loader; + } + + /** + * Class constructor. + * + * @param string $base_path Base path for classes-to-files mapping. + */ + protected function __construct($base_path) + { + $this->basePath = rtrim($base_path, '/\\'); + } +} diff --git a/src/mibew/libs/common/autoload.php b/src/mibew/libs/common/autoload.php deleted file mode 100644 index 848cff76..00000000 --- a/src/mibew/libs/common/autoload.php +++ /dev/null @@ -1,39 +0,0 @@ -