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();             
        }
  • 相关阅读:
    Jzoj4822 完美标号
    Jzoj4822 完美标号
    Jzoj4792 整除
    Jzoj4792 整除
    Educational Codeforces Round 79 A. New Year Garland
    Good Bye 2019 C. Make Good
    ?Good Bye 2019 B. Interesting Subarray
    Good Bye 2019 A. Card Game
    力扣算法题—088扰乱字符串【二叉树】
    力扣算法题—086分隔链表
  • 原文地址:https://www.cnblogs.com/liuchen/p/352094.html
Copyright © 2011-2022 走看看