[英]Forward data from one controller action to other in Yii2
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? 基本上,如果我们有Zend _forward的功能,我现在想要吗?
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 ? 是否可以将控制从一个控制器/动作转发到另一个?
Can anybody suggest me can I go for ? 任何人都可以建议我可以去吗?
在Yii 2中,你可以使用它产生相同的forward()结果:
Yii::$app->runAction('new_controller/new_action', ['param1'=>'value1', 'param2'=>'value2']);
As far as I know Yii 1 had forward method in controller that allowed you to forward to different controller/action with simply: 据我所知,Yii 1在控制器中有前向方法,只需简单地转发到不同的控制器/动作:
$this->forward("new_controller/new_action");
I'm sure something similar could be working in Yii2 too. 我确信类似的东西也可以在Yii2中运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.