Zend 框架 - 从当前动作向 Controller 中的另一个动作发送消息 [英] Zend framework - send a message from the current action to another action in Controller

查看:28
本文介绍了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.

这篇关于Zend 框架 - 从当前动作向 Controller 中的另一个动作发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆