dongzhuang6177 2012-10-31 06: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 08: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.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部