From a5dfb6257daf19270982d8c8c061504cf2d6db64 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 8 Oct 2010 23:04:26 +0000 Subject: [PATCH] ENHACENEMENT: Change behaviour of the MenufestBuilder to use spl_autoload_register instead of traditional __autoload. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@111831 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Core.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/core/Core.php b/core/Core.php index 3bf3e883a..b5eba9816 100755 --- a/core/Core.php +++ b/core/Core.php @@ -131,6 +131,21 @@ define('PR_LOW',10); increase_memory_limit_to('64M'); +/** + * Sapphire class autoloader. Requires the ManifestBuilder to work. + * $_CLASS_MANIFEST must have been loaded up by ManifestBuilder for this to successfully load + * classes. Classes will be loaded from any PHP file within the application. + * If your class contains an underscore, for example, Page_Controller, then the filename is + * expected to be the stuff before the underscore. In this case, Page.php. + */ +function sapphire_autoload($className) { + global $_CLASS_MANIFEST; + if(($pos = strpos($className,'_')) !== false) $className = substr($className,0,$pos); + if(isset($_CLASS_MANIFEST[$className])) include_once($_CLASS_MANIFEST[$className]); +} + +spl_autoload_register('sapphire_autoload'); + /////////////////////////////////////////////////////////////////////////////// // INCLUDES @@ -219,19 +234,6 @@ function getTempFolder() { return $ssTmp; } -/** - * Sapphire class autoloader. Requires the ManifestBuilder to work. - * $_CLASS_MANIFEST must have been loaded up by ManifestBuilder for this to successfully load - * classes. Classes will be loaded from any PHP file within the application. - * If your class contains an underscore, for example, Page_Controller, then the filename is - * expected to be the stuff before the underscore. In this case, Page.php. - */ -function __autoload($className) { - global $_CLASS_MANIFEST; - if(($pos = strpos($className,'_')) !== false) $className = substr($className,0,$pos); - if(isset($_CLASS_MANIFEST[$className])) include_once($_CLASS_MANIFEST[$className]); -} - /** * Return the file where that class is stored */ @@ -331,4 +333,4 @@ function increase_time_limit_to($timeLimit = null) { } -?> +?> \ No newline at end of file