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銆