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.

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

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?