使用 Doctrine 构建通用 OO ACL

2024-08-09php开发问题
1

本文介绍了使用 Doctrine 构建通用 OO ACL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我希望设计一个由原则支持的 ACL 系统供我自己使用,尽管我在一些最初的设计考虑方面遇到了困难.

I'm looking to design a doctrine-backed ACL system for my own use, although I'm struggling with some of the initial design considerations.

现在我正在考虑根据类和唯一标识符来制作它,并将它们存储在一个表中:

Right now I'm looking at making it based on classes and unique identifiers, storing them in a table as such:

Table: ACL
    ResourceClass
    ResourceKey
    RoleClass
    RoleKey
    Permission

显然,这将要求我对正在查询的类进行内省以派生正确的 ResourceClass 值.

Obviously this is going to demand that I introspect on classes that are being queried to derive the correct ResourceClass values.

我想知道这种方法以前是否已经使用过,或者是否有人对以更好的方式进行操作有一些建议.角色之间的递归关系等其他事情也让我感到困惑,因为我不确定如何递归查询以构建资源和 ACL.

I'm wondering if this approach has been done before or if anyone has some advice with doing it in a bettery way. Other things like recursive relationships between Roles also confound me as I'm not sure how to recursively query to build and ACL for a Resource.

我不是 Zend ACL 的忠实拥护者,因此请不要提出任何建议 - 我知道!

I'm not a huge fan of Zend ACL, so please no suggestions for it - I am aware of it!

随着人们的加入,我们会进一步澄清这个问题,所以请多多包涵!这个问题本身可能需要几次迭代!;)

Further clarifications will be made to this question as people weigh in, so please bear with me! This question itself may require a few iterations! ;)

推荐答案

我使用 NestedSet 来存储 ACL 层次结构和缓存以加快速度.

I use NestedSet for storing the ACL hierarchy and cache to speed things up.

Doctrine ORM for PHP - NestedSet

这是一个可能也有用的帖子:

Here is a post which may be useful too:

Zend_Acl 部分3:创建和存储动态ACL |CodeUtopia - Jani Hartikainen 的博客

(也请看前两部分).

这篇关于使用 Doctrine 构建通用 OO ACL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17