0,先按照官网上的脚本upgrade(http://book.cakephp.org/2.0/en/console- ... rade-shell)方式把现有的project给该咯,童稚们会看到目录结构有比较大的变化。
1,没有AppModel了,得自己手工在“app/Model”目录下面添加一个extends自Model类的AppModel类即可。
2,controller的入口:非得把原来自己的(比如“trans”)改为“accounts”?反正现在是改了就ok了,晕,稍后再研究。
3,paginator helper,sort的key和title参数掉转顺序了,晕,还好extends了一个expaginator,对应改改就好了。而且,现在paginator在render之后貌似在$this->passedArgs数组里面如果是排序的时候就不是'page'这个key了,取而代之的是'sort',晕哦,当然选页部分还是'page'的,卡卡。
4,html helper的link,参数只有4个了,如果要显示html,比如“<font>menu</fon>”之类的,得在第三个参数数组里面加上“'escape' => false”,代替原来的第四个参数“false”。
5,import部分,必须得放到“app/Vendor”目录下了,参数也有变化了,比如“app/Vendor/kits.php”,得用App:import("Vender", "kits")来替代原来的,而且,如果你想把"kits.php"改名为"kits.inc.php",对不起,没门。
6,form helper的select,参数也改成4个了,“selected value”得改,否则说你调用了未知函数,晕。
7,session component得手工加到controllers的$components数组变量里了(var $components = array('Session',...)),。
8,auth component的log in机制也改了,登录之后原来的$this->Auth->user("id")得变成...->user("Account.id")了,其他字段以此类推。
9,session helper里如果想通过$this->Session->read("Auth.Account")得变成...->read("Auth.User.Account")了。在view里面直接$this->Session->flash()不行了,得在前面加个“echo”,“echo $this->Session->flash()”。
10,类似array("controller" => "con", "action" => "list", "id" => 1),再传递给list($id)时,$id不能直接用了,id值现在放在了$this->request->params['named']['id']里面了,得自行取用。
11,ajax helper没了,取而代之是js helper,几点需要注意:
(1)必须在</body>前加入echo $this->Js->writeBuffer();
(2)为了避免使用"$"而是“jQuery”,必须加入下面的代码段——
$this->Js->JqueryEngine->jQueryObject = 'jQuery';
echo $this->Html->scriptBlock(
array('inline' => false)
);
(3)$components必须包括RequestHandler;
(4)原来下面的代码段A,必须被代码段B取代——
A:echo $ajax->observeField('Comid',
array(
'url' => array('controller' => 'con', 'action' => 'act'),
'update' => 'Agid',
'loading' => 'Element.hide(\'divAgid\');Element.show(\'divAgLoading\');',
'complete' => 'Element.show(\'divAgid\');Element.hide(\'divAgidLoading\');',
'frequency' => 0.2
)
);
B:$this->Js->get("#Comid")->event("change", $this->Js->request(
array(
'controller' => 'con', 'action' => 'act'
),
array(
'update' => '#Agid',
'before' => 'Element.hide(\'divAgid\');Element.show(\'divAgLoading\');',
'complete' => 'Element.show(\'divAgid\');Element.hide(\'divAgidLoading\');',
'async' => true,
'dataExpression' => true,
'method' => 'post',
'data' => $this->Js->serializeForm(array('isForm' => false, 'inline' => true))
)
));
12,$this->Form->create(null, array("controller" => "con", "action" => "act", "id" => "frm")应该被$this->Form->create(null, "url" => array("controller" => "con", "action" => "act"), "id" => "frm")替代。
13,cakephp不会将post给服务器的password字段自动hash了,好吧,就是说如果要和repeated password对比的话,就不用hash后对比了。
14,email component不能用了,晕……,不过取而代之的CakeEmail貌似很强大,跟着cookbook改掉原来的代码就成了:
(1)得用App::uses('CakeEmail', 'Network/Email');替代掉原来的$components = array(...,'Emai',...)了;
(2)其它的跟着cookbook来吧,一应俱全。
15,The attribute $pageTitle no longer exists, use set() to set the title:$this->set('title_for_layout', 'This is the page title'),你懂的。
已有项目内核cakephp框架从版本1.3.8升至2.4.2手记
-
- 帖子: 49
- 注册时间: 2008-07-01 23:07
- lhw828
- 帖子: 2797
- 注册时间: 2007-03-15 16:58
- 来自: 湖北武汉
- 联系:
Re: 已有项目内核cakephp框架从版本1.3.8升至2.4.2手记
再好好排个版,不错的!
.
Linux下安装QQ的各种办法——2017年3月7日更新——QQ8.8
Linux/Ubuntu学习笔记——用前人的经验,让你快速进入Linux的怀抱
科学上网的姿势,无痛穿越长城
Ubuntu交流QQ群:16308991(500人群)和10993386(500人群)疯狂招人!大家速来!
.