在 Yii2 中将数据从一个控制器动作转发到另一个控制器动作

2022-01-07 00:00:00 php 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']);

相关文章