dongzhuang6177 2012-10-31 14:29 采纳率: 100%
浏览 181
已采纳

在哪里写Yii authManager业务规则?

I am using Yii's authManager to deal with RBAC in my project. I'm fairly new to this concept.

My question is regarding writing and storing the Business Rules. Since I am using CDbAutManager everything is stored in the database. Which makes sense for storing which user has which role, since users are growing dynamically. However it seems that the business rules are also stored there. I'm not sure I understand.

I need to write a rule for 'updateOwnPost'. Shouldn't this be written in a PHP file somewhere so the project can be easily ported? If I start a new website with the same code, I want to keep the rules but not users...

Also, how complex can those rules be? I don't really see myself writing a 20-line rule within the database ...

My question is two-fold:

First in general, why is it implemented like this and what is the normal way of doing things?

Secondly, so I can get going, Can I make my business rules a function call to a real PHP file? If so, how?

  • 写回答

1条回答 默认 最新

  • duanfeiqu1989 2012-10-31 16:33
    关注

    Answers:

    1), Yes, biz rules are stored in the DB with CDbAuthManager. You can always create your own AuthManager ("is a" CAuthManager) and do whatever you'd like. Bizrules are simple PHP code snippets, usually. Your case is no different. For example of such an implementation see: https://stackoverflow.com/a/13110311/570009

    2) I believe that you can call a "callable" PHP code and in any case, the PHP bizrule code is run in via eval() IIRC.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本