Changeset 258

Show
Ignore:
Timestamp:
02/12/07 23:33:57 (2 years ago)
Author:
schst
Message:

Bugfix: reset $initDone when adding a new lib path
Better solution would be storing more than one $initDone (one per lib path)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/star/StarClassRegistry.php

    r235 r258  
    22/** 
    33 * Class registry for mapping of classes to star files. 
    4  *  
     4 * 
    55 * @author   Frank Kleine <mikey@stubbles.net> 
    66 * @package  star 
     
    88/** 
    99 * Class registry for mapping of classes to star files. 
    10  *  
     10 * 
    1111 * @package  star 
    1212 */ 
     
    3737     */ 
    3838    protected static $files     = array(); 
    39      
     39 
    4040    /** 
    4141     * set the path to the star files 
     
    4747    { 
    4848        self::$libPathes[$libPath] = $recursive; 
     49        self::$initDone = false; 
    4950    } 
    50      
     51 
    5152    /** 
    5253     * returns the file where the given classes is stored in 
     
    6162            return self::$classes[$fqClassName]; 
    6263        } 
    63          
     64 
    6465        return null; 
    6566    } 
    66      
     67 
    6768    /** 
    6869     * returns the uri for the given class 
     
    7778            return 'star://' . self::$classes[$fqClassName] . '?' . $fqClassName; 
    7879        } 
    79          
     80 
    8081        return null; 
    8182    } 
    82      
     83 
    8384    /** 
    8485     * returns a list of all classes within given file 
     
    9394            return self::$files[$file]; 
    9495        } 
    95          
     96 
    9697        return array(); 
    9798    } 
    98      
     99 
    99100    /** 
    100101     * initialize the class registry 
     
    105106            return; 
    106107        } 
    107          
     108 
    108109        if (count(self::$libPathes) == 0) { 
    109110            if (substr(__FILE__, 0, 7) == 'star://') { 
     
    114115            } 
    115116        } 
    116          
     117 
    117118        foreach (self::$libPathes as $libPath => $recursive) { 
    118119            if (file_exists($libPath . '/.cache') == true) { 
     
    123124                continue; 
    124125            } 
    125              
     126 
    126127            if (true === $recursive) { 
    127128                $dirIt = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($libPath)); 
     
    129130                $dirIt = new DirectoryIterator($libPath); 
    130131            } 
    131              
     132 
    132133            $cache['files']   = array(); 
    133134            $cache['classes'] = array(); 
     
    136137                    continue; 
    137138                } 
    138                  
     139 
    139140                $archiveData = StarStreamWrapper::acquire($file->getPathname()); 
    140141                if (empty($archiveData) == true) { 
    141142                    continue; 
    142143                } 
    143                  
     144 
    144145                $classes = array_keys($archiveData['index']); 
    145146                self::$files[$file->getPathname()]    = $classes; 
    146147                $cache['files'][$file->getPathname()] = $classes; 
    147                  
     148 
    148149                foreach ($archiveData['index'] as $fqClassName => $storeData) { 
    149150                    self::$classes[$fqClassName]    = $file->getPathname(); 
     
    151152                } 
    152153            } 
    153              
     154 
    154155            file_put_contents($libPath . '/.cache', serialize($cache)); 
    155156            self::$initDone = true;