Yii Framework v1.1.10 绫诲弬鑰

CCodeFile

system.gii
缁ф壙 class CCodeFile » CComponent
婧愯嚜 1.1.2
鐗堟湰 $Id: CCodeFile.php 3426 2011-10-25 00:01:09Z alexander.makarow $
婧愮爜 framework/gii/CCodeFile.php
CCodeFile琛ㄧず鐢熸垚鐨勪竴涓唬鐮佹枃浠躲

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
content mixed 鏂扮敓鎴愮殑浠g爜銆傚鏋滄鍊间负null锛岃〃绀path 灏嗚褰撲綔鏄竴涓洰褰曘 CCodeFile
error string 灏嗕唬鐮佷繚瀛樺埌鏂囦欢鏃跺彂鐢熺殑閿欒 CCodeFile
operation string 灏嗘墽琛岀殑鎿嶄綔 CCodeFile
path string 鐢熸垚鐨勪唬鐮佸瓨鏀剧殑鏂囦欢璺緞銆 CCodeFile
relativePath string 姝や唬鐮佹枃浠剁殑鐩稿璺緞锛堝熀浜庡簲鐢ㄧ殑鍩烘湰璺緞锛夈 CCodeFile
type string 姝や唬鐮佹枃浠剁殑鎵╁睍鍚嶏紙渚嬪锛歱hp锛宼xt锛夈 CCodeFile

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犳柟娉曘 CCodeFile
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getRelativePath() 杩斿洖姝や唬鐮佹枃浠剁殑鐩稿璺緞锛堝熀浜庡簲鐢ㄧ殑鍩烘湰璺緞锛夈 CCodeFile
getType() 杩斿洖姝や唬鐮佹枃浠剁殑鎵╁睍鍚嶏紙渚嬪锛歱hp锛宼xt锛夈 CCodeFile
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
save() 灏嗙敓鎴愮殑浠g爜淇濆瓨鍒版枃浠path CCodeFile

灞炴ц缁

content 灞炴
public mixed $content;

鏂扮敓鎴愮殑浠g爜銆傚鏋滄鍊间负null锛岃〃绀path 灏嗚褰撲綔鏄竴涓洰褰曘

error 灞炴
public string $error;

灏嗕唬鐮佷繚瀛樺埌鏂囦欢鏃跺彂鐢熺殑閿欒

operation 灞炴
public string $operation;

灏嗘墽琛岀殑鎿嶄綔

path 灞炴
public string $path;

鐢熸垚鐨勪唬鐮佸瓨鏀剧殑鏂囦欢璺緞銆

relativePath 灞炴 鍙
public string getRelativePath()

姝や唬鐮佹枃浠剁殑鐩稿璺緞锛堝熀浜庡簲鐢ㄧ殑鍩烘湰璺緞锛夈

type 灞炴 鍙
public string getType()

姝や唬鐮佹枃浠剁殑鎵╁睍鍚嶏紙渚嬪锛歱hp锛宼xt锛夈

鏂规硶璇︾粏

__construct() 鏂规硶
public void __construct(string $path, string $content)
$path string 鐢熸垚鐨勪唬鐮佸瓨鏀剧殑鏂囦欢璺緞銆
$content string 鏂扮敓鎴愮殑浠g爜
婧愮爜锛 framework/gii/CCodeFile.php#51 (鏄剧ず)
public function __construct($path,$content)
{
    
$this->path=strtr($path,array('/'=>DIRECTORY_SEPARATOR,'\\'=>DIRECTORY_SEPARATOR));
    
$this->content=$content;
    if(
is_file($path))
        
$this->operation=file_get_contents($path)===$content self::OP_SKIP self::OP_OVERWRITE;
    else if(
$content===null)  // is dir
        
$this->operation=is_dir($path) ? self::OP_SKIP self::OP_NEW;
    else
        
$this->operation=self::OP_NEW;
}

鏋勯犳柟娉曘

getRelativePath() 鏂规硶
public string getRelativePath()
{return} string 姝や唬鐮佹枃浠剁殑鐩稿璺緞锛堝熀浜庡簲鐢ㄧ殑鍩烘湰璺緞锛夈
婧愮爜锛 framework/gii/CCodeFile.php#117 (鏄剧ず)
public function getRelativePath()
{
    if(
strpos($this->path,Yii::app()->basePath)===0)
        return 
substr($this->path,strlen(Yii::app()->basePath)+1);
    else
        return 
$this->path;
}

getType() 鏂规硶
public string getType()
{return} string 姝や唬鐮佹枃浠剁殑鎵╁睍鍚嶏紙渚嬪锛歱hp锛宼xt锛夈
婧愮爜锛 framework/gii/CCodeFile.php#128 (鏄剧ず)
public function getType()
{
    if((
$pos=strrpos($this->path,'.'))!==false)
        return 
substr($this->path,$pos+1);
    else
        return 
'unknown';
}

save() 鏂规硶
public void save()
婧愮爜锛 framework/gii/CCodeFile.php#66 (鏄剧ず)
public function save()
{
    
$module=Yii::app()->controller->module;
    if(
$this->content===null)  // a directory
    
{
        if(!
is_dir($this->path))
        {
            
$oldmask=@umask(0);
            
$result=@mkdir($this->path,$module->newDirMode,true);
            @
umask($oldmask);
            if(!
$result)
            {
                
$this->error="Unable to create the directory '{$this->path}'.";
                return 
false;
            }
        }
        return 
true;
    }

    if(
$this->operation===self::OP_NEW)
    {
        
$dir=dirname($this->path);
        if(!
is_dir($dir))
        {
            
$oldmask=@umask(0);
            
$result=@mkdir($dir,$module->newDirMode,true);
            @
umask($oldmask);
            if(!
$result)
            {
                
$this->error="Unable to create the directory '$dir'.";
                return 
false;
            }
        }
    }
    if(@
file_put_contents($this->path,$this->content)===false)
    {
        
$this->error="Unable to write the file '{$this->path}'.";
        return 
false;
    }
    else
    {
        
$oldmask=@umask(0);
        @
chmod($this->path,$module->newFileMode);
        @
umask($oldmask);
    }
    return 
true;
}

灏嗙敓鎴愮殑浠g爜淇濆瓨鍒版枃浠path

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.