symfony2:在类中插入ace


symfony2: insert ace in class

当我尝试在类中添加ace时出现此错误

警告:PDO::quote()要求参数1为字符串,中给定的对象/供应商/条令/dbal/lib/条令/dbal/Connection.php第568行

我的代码:

$oid = new ObjectIdentity('class', new Post());
$aclProvider = $this->get('security.acl.provider');
try {
    $acl = $aclProvider->createAcl($oid);
} catch (AclAlreadyExistsException $exists) {
    return;
}
$builder = new MaskBuilder();
$builder->add('view');
$mask = $builder->get();
$acl->insertClassAce(new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), $mask);
$aclProvider->updateAcl($acl);

知道吗?

尝试定义您的对象标识,如下所示:

$entityoid = new ObjectIdentity('class', 'YourComp''YourBundleBundle''Entity''Post');