Tất nhiên. Đây là một mẫu mã từ Action Helpers documentation (xem phần Redirector
, khoảng 2/3 đường xuống trang.) Bạn có thể cần lấy một tham chiếu đến trình trợ giúp redirector và gọi một trong các phương thức goto*
như mã này đang làm.
class ForwardController extends Zend_Controller_Action
{
/**
* Redirector - defined for code completion
*
* @var Zend_Controller_Action_Helper_Redirector
*/
protected $_redirector = null;
public function init()
{
$this->_redirector = $this->_helper->getHelper('Redirector');
}
public function myAction()
{
/* do some stuff */
// Redirect to 'my-action' of 'my-controller' in the current
// module, using the params param1 => test and param2 => test2
$this->_redirector->gotoSimple('my-action',
'my-controller',
null,
array('param1' => 'test', 'param2' => 'test2'));
}
}
Nguồn
2010-03-31 10:48:16
@Andy Shellam // ah! Làm thế nào tôi có thể bỏ lỡ điều đó! Cảm ơn bạn rất nhiều! – Moon
Tài liệu về Trình trợ giúp hành động được tham chiếu ở trên là trả lại 404 dùng thử thay cho phiên bản 1.12 - https://framework.zend.com/manual/1.12/en/zend.controller.actionhelpers.html – PiggyMacPigPig
Tôi sử dụng Zend 3.0.0 và thứ tự param của tôi là redirector (module, action, controller, params) –