Changeset 258
- Timestamp:
- 02/12/07 23:33:57 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/star/StarClassRegistry.php
r235 r258 2 2 /** 3 3 * Class registry for mapping of classes to star files. 4 * 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> 6 6 * @package star … … 8 8 /** 9 9 * Class registry for mapping of classes to star files. 10 * 10 * 11 11 * @package star 12 12 */ … … 37 37 */ 38 38 protected static $files = array(); 39 39 40 40 /** 41 41 * set the path to the star files … … 47 47 { 48 48 self::$libPathes[$libPath] = $recursive; 49 self::$initDone = false; 49 50 } 50 51 51 52 /** 52 53 * returns the file where the given classes is stored in … … 61 62 return self::$classes[$fqClassName]; 62 63 } 63 64 64 65 return null; 65 66 } 66 67 67 68 /** 68 69 * returns the uri for the given class … … 77 78 return 'star://' . self::$classes[$fqClassName] . '?' . $fqClassName; 78 79 } 79 80 80 81 return null; 81 82 } 82 83 83 84 /** 84 85 * returns a list of all classes within given file … … 93 94 return self::$files[$file]; 94 95 } 95 96 96 97 return array(); 97 98 } 98 99 99 100 /** 100 101 * initialize the class registry … … 105 106 return; 106 107 } 107 108 108 109 if (count(self::$libPathes) == 0) { 109 110 if (substr(__FILE__, 0, 7) == 'star://') { … … 114 115 } 115 116 } 116 117 117 118 foreach (self::$libPathes as $libPath => $recursive) { 118 119 if (file_exists($libPath . '/.cache') == true) { … … 123 124 continue; 124 125 } 125 126 126 127 if (true === $recursive) { 127 128 $dirIt = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($libPath)); … … 129 130 $dirIt = new DirectoryIterator($libPath); 130 131 } 131 132 132 133 $cache['files'] = array(); 133 134 $cache['classes'] = array(); … … 136 137 continue; 137 138 } 138 139 139 140 $archiveData = StarStreamWrapper::acquire($file->getPathname()); 140 141 if (empty($archiveData) == true) { 141 142 continue; 142 143 } 143 144 144 145 $classes = array_keys($archiveData['index']); 145 146 self::$files[$file->getPathname()] = $classes; 146 147 $cache['files'][$file->getPathname()] = $classes; 147 148 148 149 foreach ($archiveData['index'] as $fqClassName => $storeData) { 149 150 self::$classes[$fqClassName] = $file->getPathname(); … … 151 152 } 152 153 } 153 154 154 155 file_put_contents($libPath . '/.cache', serialize($cache)); 155 156 self::$initDone = true;
