Changeset 450
- Timestamp:
- 04/02/07 21:57:09 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/stubClassLoader.php
r448 r450 7 7 /** 8 8 * Interface for class loaders that load classes from foreign namespaces. 9 * 9 * 10 10 * This interface must reside here because the stubClassLoader uses it as type hint. 11 11 * … … 20 20 */ 21 21 public function setNamespace($namespace); 22 22 23 23 /** 24 24 * returns the namespace where this classloader is responsible for … … 27 27 */ 28 28 public function getNamespace(); 29 29 30 30 /** 31 31 * loads the given class … … 62 62 */ 63 63 private static $foreignClassLoaders = array(); 64 64 65 65 /** 66 66 * method to load files from source path … … 83 83 return; 84 84 } 85 85 86 86 $files = array(); 87 87 $dirName = self::getSourcePath(); … … 91 91 continue; 92 92 } 93 93 94 94 self::$classNames[$nqClassName] = $fqClassName; 95 95 $foreignNamespace = self::getForeignNamespace($fqClassName); 96 96 if (null != $foreignNamespace) { 97 self::$foreignClassLoaders[$foreignNamespace] ->load($fqClassName);97 self::$foreignClassLoaders[$foreignNamespace][0]->load($fqClassName); 98 98 return; 99 99 } 100 100 101 101 $uri = null; 102 102 if (stubConfig::useStar() == true && class_exists('StarClassRegistry', false) == true) { … … 107 107 } 108 108 require $uri; 109 109 110 110 if (method_exists($nqClassName, '__static') == true) { 111 111 call_user_func(array($nqClassName, '__static')); … … 113 113 } 114 114 } 115 115 116 116 /** 117 117 * returns the non qualified class name from a full qualified class name … … 125 125 return $classNameParts[count($classNameParts) - 1]; 126 126 } 127 127 128 128 /** 129 129 * returns the full qualified class name of a non qualified class name … … 137 137 return self::$classNames[$nqClassName]; 138 138 } 139 139 140 140 return null; 141 141 } 142 142 143 143 /** 144 144 * returns the path to the source files … … 154 154 } 155 155 } 156 156 157 157 /** 158 158 * registers a foreign class loader … … 162 162 public static function registerForeignClassLoader(stubForeignClassLoader $foreignClassLoader) 163 163 { 164 self::$foreignClassLoaders[$foreignClassLoader->getNamespace()] = $foreignClassLoader;164 self::$foreignClassLoaders[$foreignClassLoader->getNamespace()] = array($foreignClassLoader, strlen($foreignClassLoader->getNamespace())); 165 165 } 166 166 167 167 /** 168 168 * checks whether a class resides in a foreign namespace … … 174 174 { 175 175 foreach (self::$foreignClassLoaders as $foreignNamespace => $foreignClassLoader) { 176 if (substr($fqClassName, 0, strlen($foreignNamespace)) == $foreignNamespace) {177 return $foreignNamespace;178 }176 if (strncmp($fqClassName, $foreignNamespace, $foreignClassLoader[1]) === 0) { 177 return $foreignNamespace; 178 } 179 179 } 180 181 180 return null; 182 181 } 183 182 184 183 /** 185 184 * maps a classname to corresponding file name
