将数据从一个控制器动作转发到Yii2中的另一个动作 [英] Forward data from one controller action to other in Yii2

查看:68
本文介绍了将数据从一个控制器动作转发到Yii2中的另一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在渲染之前将数据从一个控制器动作转发到其他控制器动作?基本上,我现在想知道Zend _forward是否具备的功能吗?

Is it possible to forward data from one controller action to other before the render? Basically, I want to now if we have something that Zend _forward does?

这是我的情况.我有一个付款网关,可将数据返回到控制器操作,我想要的是在单独的控制器/操作上处理数据,但呈现主页(不重定向).是否可以将控制权从一个控制器/动作转发到另一个?

Here is my scenario. I have a payment gateway that returns data back to my controller action, what I want is to handle data on separate controller/action but render the home page (without redirection). Is it possible to forward control from one controller/action to other ?

有人可以建议我去吗?

推荐答案

在Yii 2中,您可以使用它产生与forward()相同的结果:

In Yii 2, you can use this which yields the same result of forward():

Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);

这篇关于将数据从一个控制器动作转发到Yii2中的另一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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