Zend 框架 - 从当前动作向 Controller 中的另一个动作发送消息
问题描述:
在 Zend 框架中:如何将消息从当前操作发送到 Controller 中的另一个操作?
In Zend framework: how can I send a message from the current action to another action in Controller?
答
这是使用 FlashMessenger 的一个非常简单的示例,因此您可以在代码中使用它:
This is a very simple example of using FlashMessenger, so you can use it on your code:
public function indexAction()
{
$messages = $this->_helper->FlashMessenger->getMessages('actions');
echo $messages[0];
}
public function redirectAction()
{
$this->_helper->FlashMessenger->addMessage("Your message", 'actions');
$this->_redirect('index/index');
}
如果您在浏览器中指向重定向"操作,您应该会收到带有消息的 indexAction.
If you point in browser at 'redirect' action, you should get indexAction with the message.