From f5537bdea468275bf171e20b7869e6d8356da143 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 21 May 2012 14:49:33 -0400 Subject: [PATCH] Autoload system libraries --- sys/common.php | 28 +++++++++++++++---- .../{controller.php => MM_Controller.php} | 0 sys/core/{model.php => MM_Model.php} | 0 sys/core/{output.php => MM_Output.php} | 0 sys/core/{page.php => MM_Page.php} | 0 5 files changed, 23 insertions(+), 5 deletions(-) rename sys/core/{controller.php => MM_Controller.php} (100%) rename sys/core/{model.php => MM_Model.php} (100%) rename sys/core/{output.php => MM_Output.php} (100%) rename sys/core/{page.php => MM_Page.php} (100%) diff --git a/sys/common.php b/sys/common.php index 7f767e3..3d9436c 100644 --- a/sys/common.php +++ b/sys/common.php @@ -21,11 +21,29 @@ */ // -------------------------------------------------------------------------- -// ! Error handling / messages +// ! Autoloading // -------------------------------------------------------------------------- /** - * Function to autoload libraries + * Function to autoload system libraries + * + * @param string + */ +function sys_autoload($name) +{ + + $path = MM_SYS_PATH . "/core/{$name}.php"; + + if (is_file($path)) + { + require_once($path); + } +} + +// -------------------------------------------------------------------------- + +/** + * Function to autoload libraries/classes * * @param string */ @@ -57,6 +75,8 @@ function autoload($name) } } +// -------------------------------------------------------------------------- +// ! Error handling / messages // -------------------------------------------------------------------------- /** @@ -303,9 +323,7 @@ function init() // Load system libraries require_once(MM_SYS_PATH . 'core/traits.php'); - require_once(MM_SYS_PATH . 'core/MM.php'); - require_once(MM_SYS_PATH . 'core/miniMVC.php'); - array_map('do_include', glob(MM_SYS_PATH . 'core/*.php')); + spl_autoload_register('sys_autoload'); // Start the library autoloader spl_autoload_register('autoload'); diff --git a/sys/core/controller.php b/sys/core/MM_Controller.php similarity index 100% rename from sys/core/controller.php rename to sys/core/MM_Controller.php diff --git a/sys/core/model.php b/sys/core/MM_Model.php similarity index 100% rename from sys/core/model.php rename to sys/core/MM_Model.php diff --git a/sys/core/output.php b/sys/core/MM_Output.php similarity index 100% rename from sys/core/output.php rename to sys/core/MM_Output.php diff --git a/sys/core/page.php b/sys/core/MM_Page.php similarity index 100% rename from sys/core/page.php rename to sys/core/MM_Page.php