Changeset 383387
- Timestamp:
- 05/11/2011 12:50:17 AM (15 years ago)
- File:
-
- 1 edited
-
wp-pear-debug/trunk/lib/util/wpdutil.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-pear-debug/trunk/lib/util/wpdutil.class.php
r325971 r383387 15 15 $sClass = array_pop(explode(".",$sClassPath)); 16 16 17 //Look for file first 18 if( file_exists($sFile.".class.php") ) 17 if(!class_exists($sClass)) 19 18 { 20 $sFile.= ".class.php"; 19 20 //Look for file first 21 if( file_exists($sFile.".class.php") ) 22 { 23 $sFile.= ".class.php"; 24 } 25 //We did not fine a file let us look for it in a director with the same name 26 elseif( file_exists($sFile) && is_dir($sFile) ) 27 { 28 $sFile.= "/".$sClass.".class.php"; 29 } 30 31 if(!file_exists($sFile) || !class_exists($sClass)) 32 { 33 Throw new Exception("Unable to load class: ". $sFile); 34 } 35 36 require_once($sFile); 21 37 } 22 //We did not fine a file let us look for it in a director with the same name23 elseif( file_exists($sFile) && is_dir($sFile) )24 {25 $sFile.= "/".$sClass.".class.php";26 }27 28 if(!file_exists($sFile))29 {30 Throw new Exception("Unable to load class: ". $sFile);31 }32 33 require_once($sFile);34 38 } 35 39 //return instance of class from file 36 40 public static function getClass($sClassPath) 37 41 { 38 $aParts = explode(".",$sClassPath); 39 $sClass = $aParts[count($aParts)-1]; 40 41 //No need to call loader despite_include once 42 if(!class_exists($sClass)) 43 { 44 self::loadClass($sClassPath); 45 } 46 42 //Include file if not already included 43 self::loadClass($sClassPath); 44 45 //New instance of class 47 46 $oClass = new $sClass; 48 47 //Use exisiting instance if possible
Note: See TracChangeset
for help on using the changeset viewer.