Symfony2:ACL - 使用findAcls()

时间:2012-07-14 13:28:25

标签: php symfony acl

我在尝试为特定对象批量加载ACL时出现问题(在下面的示例中,它是Account类。)

如果我使用以下代码,即使填充了acl_object_identities,应该填充的返回数组为空。我错过了什么?

        $oids = array();
    foreach ($accounts as $account) {
        $oid = ObjectIdentity::fromDomainObject($account);
        $oids[] = $oid;
    }

    $aclProvider->findAcls($oids);

$ accounts保存使用findAll()找到的实体数组。

1 个答案:

答案 0 :(得分:0)

好吧,看起来ACL毕竟是拉动的,关键是迭代跟进,看看有什么权限。

foreach ($accounts as $account) {
    if ($securityContext->isGranted('EDIT', $account)) {
        // Granted, do something with it
    } else {
        // Not Granted
    }
}

所以,似乎一切都在设计中。

相关问题