I want to force all users to log in before accessing pages of my site. I have followed Larry Ullman's tutorial Forcing Login for All Pages in Yii.

我想强制所有用户在访问我的网站页面之前登录。我已经关注了Larry Ullman的教程强制登录Yii中的所有页面。

According to the tutorial you can make an exception for some pages to avoid redirecting to the log in page. In order to check the current controller it has checked $_GET value. My problem is that I have used urlManager to rewrite the URL and $_GET gives me a null value. Is there any method I can use to get the current controller and action in the score of my class?

根据教程,您可以为某些页面设置例外,以避免重定向到登录页面。为了检查当前控制器,它检查了$ _GET值。我的问题是我使用urlManager重写URL,$ _GET给我一个空值。有没有什么方法可以用来获得当前控制器和我班级成绩的动作?

I tried the following but it is not accessible in the scope of my component class:

我尝试了以下内容,但在组件类的范围内无法访问它:

Yii::app()->controller->getId

8 个解决方案

#1


44

Yes you can get the current controller/action route, by reversing urlManager rule:

是的,您可以通过反转urlManager规则获取当前控制器/操作路径:

Yii::app()->urlManager->parseUrl(Yii::app()->request)

更多相关文章

  1. mySQL库编码,PHP页面编码和mysql_query("set names 'GBK'")编码问
  2. 从模型到控制器并返回到模型的数据
  3. 我需要PHP页面显示mysql数据库中的BLOB图像
  4. InnoDB辅助索引页面的物理结构是什么样子的
  5. MySQL内核解析:Innodb页面存储结构-1
  6. 有没有办法阻止使用类似Firebug的工具在页面中编辑HTML和CSS内容
  7. 将JSON ID键插入到ng-click指令中,然后将其传递到另一个控制器
  8. 与同一页面上的两个jquery datepickers冲突
  9. 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什

随机推荐

  1. xml入门:XML是什么,它可以做什么?
  2. 教你怎么样快速通过XSL转换XML文件
  3. 基于XML的购物车的实例代码详情
  4. linq to xml操作XML的方法
  5. 使用XMLHTTP发送超长XML表单数据的详情
  6. XML数据库中几个容易混淆的概念详细介绍
  7. 使用正则表达式进行xml数据验证的代码实
  8. 用XSL翻译Web服务应用程序
  9. 用XML和SQL 2000来管理存储过程调用
  10. 对XML数据使用XMLConvert