* @link http://www.yiiframework.com/ * @copyright Copyright © 2008-2011 Yii Software LLC * @license http://www.yiiframework.com/license/ * @version $Id$ */ /** * AutoloadCommand generates the class map for {@link YiiBase}. * The class file YiiBase.php will be modified with updated class map. * * @author Qiang Xue * @version $Id$ * @package system.build * @since 1.0 */ class AutoloadCommand extends CConsoleCommand { public function getHelp() { return <<array('php'), 'exclude'=>array( '.svn', '/messages', '/views', '/cli', '/yii.php', '/yiit.php', '/yiilite.php', '/web/js', '/vendors', '/i18n/data', '/utils/mimeTypes.php', '/test', '/zii', '/gii', ), ); $files=CFileHelper::findFiles(YII_PATH,$options); $map=''; foreach($files as $file) { if(($pos=strpos($file,YII_PATH))!==0) die("Invalid file '$file' found."); $path=str_replace('\\','/',substr($file,strlen(YII_PATH))); $className=substr(basename($path),0,-4); if($className[0]==='C') $map.="\t\t'$className' => '$path',\n"; } $yiiBase=file_get_contents(YII_PATH.'/YiiBase.php'); $newYiiBase=preg_replace('/private\s+static\s+\$_coreClasses\s*=\s*array\s*\([^\)]*\)\s*;/',"private static \$_coreClasses=array(\n{$map}\t);",$yiiBase); if($yiiBase!==$newYiiBase) { file_put_contents(YII_PATH.'/YiiBase.php',$newYiiBase); echo "YiiBase.php is updated successfully.\n"; } else echo "Nothing changed.\n"; } }