我在Zend_Navigation_Page_Mvc
遇到了一个奇怪的问题。当我尝试渲染锚标记时,URL似乎是从页面上的另一个实例缓存的,因此href
不正确。
要在我想要返回的操作中创建实例:
$request = $this->getRequest();
$back = new Zend_Navigation_Page_Mvc(
array(
'module' => $request->getModuleName(),
'controller' => $request->getControllerName(),
'action' => $request->getActionName(),
'params' => $params, // an array of params to pass
'label' => 'Back to listings',
'class' => 'back'
)
);
然后我将其存储在会话中,然后检索它以提供back
按钮。因此,在操作中,我从会话中获取实例并将其分配给视图。在视图中,我使用echo $this->navigation(new Zend_Navigation(array($this->back)));
var_dump
$this->back
生成此内容:
object(Zend_Navigation_Page_Mvc)[132]
protected '_action' => string 'index' (length=5)
protected '_controller' => string 'specialcall' (length=11)
protected '_module' => string 'admin' (length=5)
protected '_params' =>
array (size=0)
empty
protected '_route' => null
protected '_resetParams' => boolean true
protected '_encodeUrl' => boolean true
protected '_active' => boolean false
protected '_scheme' => null
protected '_hrefCache' => string '/digitallearning/admin/specialcall/view' (length=39)
protected '_label' => string 'Back to listings' (length=16)
protected '_fragment' => null
protected '_id' => null
protected '_class' => string 'back' (length=4)
protected '_title' => null
protected '_target' => null
protected '_accesskey' => null
protected '_rel' =>
array (size=0)
empty
protected '_rev' =>
array (size=0)
empty
protected '_order' => null
protected '_resource' => null
protected '_privilege' => null
protected '_visible' => boolean true
protected '_parent' =>
object(Zend_Navigation)[130]
protected '_pages' =>
array (size=1)
'00000000219cad71000000015ca8a15d' =>
&object(Zend_Navigation_Page_Mvc)[132]
protected '_index' =>
array (size=1)
'00000000219cad71000000015ca8a15d' => int 0
protected '_dirtyIndex' => boolean false
protected '_properties' =>
array (size=0)
empty
protected '_customHtmlAttribs' =>
array (size=0)
empty
protected '_pages' =>
array (size=0)
empty
protected '_index' =>
array (size=0)
empty
protected '_dirtyIndex' => boolean false
使用var_dump
调用$this->back->getHref();
会产生意外结果:
string '/digitallearning/admin/specialcall/view' (length=39)
view
是当前操作,但正如您从上面的_action
所看到的,它不是设置操作。
href
似乎是从缓存中获取的(请参阅上面的_hrefCache
)。所以我的问题是如何强制它生成href
而不是从缓存中获取它?