dongmei2956
2017-08-14 06:32
浏览 149
已采纳

获取yii2中重定向请求的URL?

Sorry for my English, but what I'm trying to say is explained below.

I have a controller say ControllerCard which has an action like this.

function actionScanCard()
{
    ...
    $this->redirect('/transaction/redeem');
    ...
}

In other controllers, ControllerTransaction, I am trying to get that it comes/redirected from /card/scan-card

function actionRedeem()
{
    $redirectFrom = ????;
    if ($redirectFrom === '/card/scan-card')
    {
        // some actions
    }
    else
        throw new ForbiddenHttpException('Must scan card!');
}

How do I get this $redirectFrom value with Yii2?

图片转代码服务由CSDN问答提供 功能建议

对不起我的英语,但我想说的是下面的解释。 \ n

我有一个控制器说 ControllerCard ,它有这样的动作。

  function actionScanCard()
 {
 ...  
 $ this-> redirect('/ transaction / redeem'); 
 ... 
} 
   
 
 

在其他控制器中, ControllerTransaction ,我试图让它来自 / card / scan-card

  function actionRedeem()
 {  
 $ redirectFrom = ????; 
 if($ redirectFrom ==='/ card / scan-card')
 {
 //某些动作
} 
否则
抛出新的ForbiddenHttpException(' 必须扫描卡!'); 
} 
   
 
 

如何使用Yii2获取此 $ redirectFrom 值? \ n

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题