简体   繁体   中英

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?

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:

$this->forward("new_controller/new_action");

I'm sure something similar could be working in Yii2 too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM