最近看的项目cakephp

总是想弄清楚从index到页面显示的所有流程,但是还是没有搞清楚,现在卡在了set('date',$this->Post->findAll())这个语句,因为我不知道Post是如何出现的(我现在用官方的那个blog_tutorial来判断流程),然后找到了controller的构造函数,之后就没有发现如何装载model类。

下面还是直接看tutorial,搞清楚Model View Controller三个类的一些API,能迅速开发,整个框架的源代码还是以后再看吧。

下面是测试一下代码框,就拿controller的构造函数吧
 

None.gif     function  __construct ()
None.gif    {     
None.gif        
if ( $this -> name  ===   null )
None.gif        {         
None.gif            
$r   =   null ;
None.gif            
if  ( ! preg_match ( ' /(.*)Controller/i ' ,   get_class ( $this ) ,   $r ))
None.gif            {
None.gif                
die ( " Controller::__construct() : Can't get or parse my own class name, exiting. " );
None.gif            }            
None.gif            
$this -> name  =   $r [ 1 ];
None.gif        }
None.gif        
if  ( $this -> viewPath  ==   null )
None.gif        {
None.gif            
$this -> viewPath  =  Inflector :: underscore( $this -> name);
None.gif        }
None.gif
None.gif        
$this -> modelClass  =  Inflector :: singularize( $this -> name);
None.gif        
$this -> modelKey   =  Inflector :: underscore( $this -> modelClass);        
None.gif          
None.gif        
if ( ! defined ( ' AUTO_SESSION ' ||  AUTO_SESSION  ==   true )
None.gif        {
None.gif            
$this -> components[]  =   ' Session ' ;
None.gif        }
None.gif
None.gif        
if  ( is_subclass_of ( $this ,   ' AppController ' ))
None.gif        {
None.gif            
$appVars   =   get_class_vars ( ' AppController ' );             
None.gif            
foreach ( array ( ' components ' ,   ' helpers ' ,   ' uses ' as   $var )
None.gif            {
None.gif                
if  ( isset ( $appVars [ $var ])  &&   ! empty ( $appVars [ $var ]))
None.gif                {
None.gif                 
$diff   =   array_diff ( $appVars [ $var ] ,   $this -> { $var });
None.gif                    
$this -> { $var =   array_merge ( $this -> { $var } ,   $diff );
None.gif                }
None.gif            }                             
None.gif        }
None.gif        
if  ( ! empty ( $this -> components))
None.gif        {
None.gif            
$component   =&   new  Component( $this );
None.gif        }
None.gif        parent
:: __construct();             
None.gif    }
None.gif
posted on 2006-03-17 13:02  liuchen 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liuchen/archive/2006/03/17/352094.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值