Created
November 26, 2010 21:58
-
-
Save treffynnon/717262 to your computer and use it in GitHub Desktop.
Legacy class code loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = 'classes/'; | |
if (is_dir($dir)) { | |
if ($dh = opendir($dir)) { | |
while (($file = readdir($dh)) !== false) { | |
if($file != '.' && $file != '..' && !is_dir($dir.$file)){ | |
require_once($dir.$file); | |
} | |
} | |
closedir($dh); | |
} | |
} | |
// SNIP | |
// some unrelated code such as DB connectors appeared here | |
// /SNIP | |
$classes = get_declared_classes(); | |
foreach($classes as $class){ | |
if(substr($class,0,3)=='SYS'){ | |
$class2 = str_replace('SYS','',$class); | |
eval('$'.strtolower($class2).' = new '.$class.'();'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = CLASS_PATH; | |
if (is_dir($dir)) { | |
if ($dh = opendir($dir)) { | |
while (($file = readdir($dh)) !== false) { | |
if('.' != $file and | |
'..' != $file and | |
!is_dir($dir.$file)){ | |
if('SYS' === substr($file,0,3)){ | |
$class_no_ext = str_replace('.php', '', $file); | |
$class_var_name = strtolower(str_replace('SYS', '', $class_no_ext)); | |
$$class_var_name = new LazyLoadingProxy($class_no_ext, $dir.$file); | |
} | |
} | |
} | |
closedir($dh); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment