你如何构建Zend Framework中的Zend_Auth和Zend_Acl以服从瘦控制器?

时间:2021-06-27 11:28:07

There has been a fair bit of talk/debate lately in the Zend Framework community about thin controllers. Apparently there is a tendency of ZF users to view the Model as nothing more than the gateway to the database.

最近在Zend Framework社区中有关于瘦控制器的讨论/辩论。显然,ZF用户倾向于将模型视为数据库的网关。

The argument is that Models should be "fat" and do more of the work and Controllers shouldn't be chaining methods and doing much work beyond conveying the meaning of the UI to the model.

这个论点是模型应该是“胖”并且做更多的工作,控制器不应该链接方法,并且除了将UI的含义传达给模型之外还要做很多工作。

For some references follow the links in this post:

对于一些参考,请点击此帖子中的链接:

http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html

Along the same lines, I think it's easy to let Zend_Acl and Zend_Auth overtake your controllers and turn them into a complex mess.

同样,我认为很容易让Zend_Acl和Zend_Auth超越你的控制器并将它们变成一个复杂的混乱。

I'm building a site right now that requires an admin section and before writing that code, I thought I'd try to get a good discussion/debate started on how best to structure authorization and access control, with a particular eye to well tested methodologies from the OOP world.

我现在正在建立一个需要管理部门的网站,在编写代码之前,我想我会尝试就如何最好地构建授权和访问控制进行良好的讨论/辩论,特别注意经过充分测试OOP世界的方法论。

Thank you.

1 个解决方案

#1


Best solution is Front Controller Plugin. In routeShutdown() method (i.e. first moment when you have the request object) you check the ACL and / or redirect to login controller.

最佳解决方案是Front Controller Plugin。在routeShutdown()方法中(即您拥有请求对象的第一时刻),您检查ACL和/或重定向到登录控制器。

#1


Best solution is Front Controller Plugin. In routeShutdown() method (i.e. first moment when you have the request object) you check the ACL and / or redirect to login controller.

最佳解决方案是Front Controller Plugin。在routeShutdown()方法中(即您拥有请求对象的第一时刻),您检查ACL和/或重定向到登录控制器。