dongpu1879 2015-08-28 12:39
浏览 87
已采纳

修改请求路径信息

Now, let me guess what y'all may be thinking... "It's a bad idea to modify the path info before it's processed. Why would you ever want to do that? This is malicious behavior!!!"

I am trying to get a controller/action representation of my previous URL; gotten through Yii::app()->getRequest()->getUrlReferrer().

From Yii 2 issues, it's possible to set the path info for a new request and parse that request. However, from the Yii 1 source, the only methods which deals with the path info are getPathInfo() and decodePathInfo(). If there was a setPathInfo(), I could have used that and the urlManager->parseUrl() to achieve this. But we aren't allowed to set the path info.

How can I arrive at a controller/action representation of my previous URL?

  • 写回答

2条回答 默认 最新

  • douhao3562 2016-03-21 11:32
    关注

    Yii does not allow the CHttpRequest object live past the parsing of the routes. And creating a new CHttpRequest is impossible after the app is created.

    I realized the only way to go about this is the vanilla Yii::app()->controller->action object. From this, I could get the module, controller and action ID for the specific URL.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?