PEIP_Autoload.php

Go to the documentation of this file.
00001 <?php
00002 require_once(__DIR__.'/PEIP_Simple_Autoload.php');
00003 
00004 /*
00005  * This file is part of the PEIP package.
00006  * (c) 2010 Timo Michna <timomichna/yahoo.de>
00007  * 
00008  * For the full copyright and license information, please view the LICENSE
00009  * file that was distributed with this source code.
00010  */
00011 
00024 class PEIP_Autoload extends PEIP_Simple_Autoload {
00025         
00032         protected function __construct(){
00033                 $this->init();
00034                 require_once(__DIR__.'/PEIP_Autoload_Paths.php');
00035                 $this->setClassPaths(PEIP_Autoload_Paths::$paths);
00036         }
00037         
00042         protected static function doGetInstance(){
00043                 return self::$instance = new PEIP_Autoload();   
00044         }               
00045 
00053         public static function make(){
00054                 $baseDir = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'));
00055                 $iterator = new RecursiveDirectoryIterator($baseDir);
00056                 $paths = self::findPaths($baseDir, $iterator);
00057                 //print_r($paths);
00058                 $pathsFile = __DIR__.'/PEIP_Autoload_Paths.php';
00059                 $content = file_get_contents($pathsFile);
00060                 echo $content = preg_replace('/public static \$paths = array *\(.*?\);/s', sprintf("public static \$paths = %s;", var_export($paths, true)), $content);
00061                 file_put_contents($pathsFile, $content);
00062         }
00063 
00074         protected static function findPaths($baseDir, RecursiveDirectoryIterator $iterator, array $paths = array()){
00075                 $iterator->rewind();
00076                 while($iterator->valid()){
00077                         if($iterator->isDir()){
00078                                 $paths = self::findPaths($baseDir, $iterator->getChildren(), $paths);
00079                         }else{
00080                                 $class = str_replace('.php', '', $iterator->getFilename());
00081                                 $paths[$class] = str_replace($baseDir, '', $iterator->getPathName());                                           
00082                         }
00083                         $iterator->next();
00084                 }
00085                 return $paths;
00086         }
00087         
00088 
00089 }

Generated on Mon Apr 12 11:39:00 2010 for PEIP by  doxygen 1.5.1