$identifier cannot be empty, when creating class scope #13

Closed
mailaneel opened this Issue Feb 24, 2012 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

mailaneel commented Feb 24, 2012

$aclManager = $this->get('problematic.acl_manager');
$aclManager->setClassPermission('Entity\Subscriber', MaskBuilder::MASK_OWNER, 'ROLE_CLIENT');

internally setClassPermission is using $oid = ObjectIdentity::fromDomainObject($domainObject); instead i think we should check the type and then get the oid because for class type we should use new ObjectIdentity($identifier, $type)

Contributor

mailaneel commented Feb 24, 2012

This is fix that i have added

 $oid = ($type == 'object')? ObjectIdentity::fromDomainObject($domainObject) : new ObjectIdentity('class',$domainObject);
Owner

Problematic commented Feb 24, 2012

Thanks for the help! If you can submit a pull request, I'll look it over and get it merged.

Contributor

mailaneel commented Feb 24, 2012

Implemented this instead, ignore my pull

<?php

namespace WSL\BaseBundle\Entity;

use Doctrine\ORM\Mapping as ORM,
    Symfony\Component\Security\Acl\Model\DomainObjectInterface;

/**
 * WSL\BaseBundle\Entity\DomainObject
 * @MappedSuperclass
 */
class DomainObject implements DomainObjectInterface
{

    public function getObjectIdentifier()
    {
        $identifier = $this->getId();
        return (!empty($identifier)) ? $identifier : 'class';
    }

}
Owner

Problematic commented Feb 24, 2012

I still think there's value in being able to handle class-level ACLs without requiring extra code. I'm going to leave this open for now while I think it over.

Contributor

mailaneel commented Feb 25, 2012

sure

@mailaneel mailaneel added a commit to mailaneel/ProblematicAclManagerBundle that referenced this issue Feb 25, 2012

@mailaneel mailaneel Reverted added fix for #13 1f0b9b4

sudent commented Dec 5, 2012

I think the first fix is the right one, since our entity might extend from another base class and thus can't use the second @mailaneel fix. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment