我正面临有关会话的问题。当我的控制器中有我的自定义 Helper 时, debug($this->Session->read()) 给了我false
. 自定义助手:
<?php
App::uses('AppHelper', 'View/Helper');
class customFunctionsHelper extends AppHelper {
public function FormatAddress($address)
{
$addr = "";
if($address['street_name_1'] != "")
$addr .= $address['street_name_1']."<br />";
if($address['street_name_2'] != "")
$addr .= $address['street_name_2']."<br />";
if($address['street_name_3'] != "")
$addr .= $address['street_name_3']."<br />";
if($address['city'] != "")
$addr .= $address['city'].", ";
if($address['zipcode'] != "" && $address['state'] != "")
$addr .= $address['state']." ".$address['zipcode']."<br />";
else
$addr .= $address['zipcode']."<br />";
if($address['country'] != "")
$addr .= $address['country'];
if($addr != "")
return $addr;
else
return "<i>Not specified</i>";
}
public function EchoInfo($info)
{
if($info != "" && $info != 0)
return $info;
else
return "<i>Not specified</i>";
}
}
?>
在我的控制器中,当我在 $helpers 变量中有 CustomFonctions 时,我遇到了这个会话问题:
class AgendaController extends AppController {
public $helpers = array('Html', 'Form','CustomFunctions');
......
评估 :
debug($this->Session->read());
这给我:
false
因此,$this-Session-setFlash() 不适用于我的自定义助手 CustomFunctions。当我删除自定义助手时,效果很好......有人有想法吗?