Yii加载配置main.php
CApplication::__construct
$this->configure($config);
CModule::configure
public function configure($config){
if(is_array($config)){
foreach($config as
$key=>$value){
//如果$this->$key未定义,会被拦截器__set执行
$this->$key=$value;}}}
CComponent::__set
public function
__set($name,$value){
//如果'set'.$name方法存在(如:setimport)则自动调用这个方法,并返回结果
CModule::setimport()
CModule::setmodules()
CModule::setcomponents()
CModule::setparams()
$setter='set'.$name;
if(method_exists($this,$setter))
return $this->$setter($value);
//strncasecmp($str1,$str2,$length)
比较$str1,2前$length个字符,0 $str1==$str2,<0
$str10
//如果方法以on开头且存在,把getEventHandlers()保存在CComponent::$_e[$name]中
else if(strncasecmp($name,'on',2)===0
&&
method_exists($this,$name)){
$name=strtolower($name);
if(!isset($this->_e[$name]))
$this->_e[$name]=new CList;//CList
实现一个整数索引的集合类,可以当作数组一样使用
return
$this->_e[$name]->add($value);}
//
else if(is_array($this->_m)){
foreach($this->_m as $object){
if($object->getEnabled()
&& (property_exists($object,$name)
|| $object->canSetProperty($name)))
return $object->$name=$value;}}
//如果'get'.$name方法存在,则抛出异常
if(method_exists($this,'get'.$name))
throw new CException(Yii::t('yii','Property "{class}.{property}" is
read only.',
array('{class}'=>get_class($this),
'{property}'=>$name)));
else
//抛出异常,类属性未定义
throw new CException(Yii::t('yii','Property "{class}.{property}" is
not defined.',
array('{class}'=>get_class($this),
'{property}'=>$name)));
}