0

私のプロジェクトで Symfony の ACL を機能させるためにすでに数時間を費やしましたが、解決策を見つけることができません。これは私のテスト例です:

$competition = $this->getDoctrine()->getManager()
    ->getRepository('MyBundle:Competition')->find(158);

$objectIdentity = ObjectIdentity::fromDomainObject($competition);
$aclProvider = $this->get('security.acl.provider');
try {
    $acl = $aclProvider->findAcl($objectIdentity);
} catch (\Symfony\Component\Security\Acl\Exception\AclNotFoundException $e) {
    $acl = $aclProvider->createAcl($objectIdentity);
}

// retrieving the security identity of the currently logged-in user
$securityIdentity = UserSecurityIdentity::fromAccount(
        $this->get('security.context')->getToken()->getUser());

// grant owner access
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_EDIT);
$aclProvider->updateAcl($acl);

.

$competition = $this->getDoctrine()->getManager()
    ->getRepository('MyBundle:Competition')->find(158);

$foo = $this->get('security.context')->isGranted(MaskBuilder::MASK_EDIT, $competition);

var_dump($foo); // always bool(false)

テーブルにデータが表示されているのを確認できますが、isGranted常に false が返されます。私は何が間違っているのですか?

acl_classes :

id  class_type
2   Me\MyBundle\Entity\Competition

acl_entries :

id  class_id    object_identity_id  security_identity_id    field_name  ace_order   mask    granting    granting_strategy   audit_success   audit_failure
1   2           3                   2                       NULL        0           4       1           all                 0               0

acl_object_identities :

id  parent_object_identity_id   class_id    object_identifier   entries_inheriting
3   NULL                        2           158                 1

acl_object_identity_ancestors :

object_identity_id  ancestor_id
3                   3

acl_security_identities :

id  identifier                  username
2   Me\MyBundle\Entity\User-Me  1
4

1 に答える 1