zoukankan      html  css  js  c++  java
  • 最近看的项目cakephp

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

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

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

       function __construct ()
        {     
            
    if($this->name === null)
            {         
                
    $r = null;
                
    if (!preg_match('/(.*)Controller/i', get_class($this), $r))
                {
                    
    die("Controller::__construct() : Can't get or parse my own class name, exiting.");
                }            
                
    $this->name = $r[1];
            }
            
    if ($this->viewPath == null)
            {
                
    $this->viewPath = Inflector::underscore($this->name);
            }

            
    $this->modelClass = Inflector::singularize($this->name);
            
    $this->modelKey  = Inflector::underscore($this->modelClass);        
              
            
    if(!defined('AUTO_SESSION'|| AUTO_SESSION == true)
            {
                
    $this->components[] = 'Session';
            }

            
    if (is_subclass_of($this, 'AppController'))
            {
                
    $appVars = get_class_vars('AppController');             
                
    foreach(array('components', 'helpers', 'uses'as $var)
                {
                    
    if (isset($appVars[$var]) && !empty($appVars[$var]))
                    {
                     
    $diff = array_diff($appVars[$var], $this->{$var});
                        
    $this->{$var= array_merge($this->{$var}, $diff);
                    }
                }                             
            }
            
    if (!empty($this->components))
            {
                
    $component =& new Component($this);
            }
            parent
    ::__construct();             
        }
  • 相关阅读:
    JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、jinfo、jconsole使用详解
    Spark入Hbase的四种方式效率对比
    redis的三种集群方式
    记Springcloud Config Service整合gitlab一坑
    移动开发day2_css预处理器_flex布局
    移动开发day1_过渡_2d转换_3d立体
    3月26-3月27号
    3月24号
    3月25号
    3月23日
  • 原文地址:https://www.cnblogs.com/liuchen/p/352094.html
Copyright © 2011-2022 走看看