2012-04-29 53 views

回答

0

听起来像是一个正常的行为,因为选民必须检查课程。

这里是一个解决方案,以检查类:

function vote(TokenInterface $token, $object, array $attributes) 
{ 
    $user = $token->getUser(); 

    //sometime the object is a class or a instance of Request 
    if($object instanceOf \Symfony\Component\HttpFoundation\Request){ 
     return VoterInterface::ACCESS_ABSTAIN; 
    }else{ 
     $class = $object->getType(); 
     if($class == 'Vendor\\MyBundle\\Entity\\MyEntity'){ 
      return VoterInterface::ACCESS_GRANTED; 
     } 
    } 

    return VoterInterface::ACCESS_DENIED; 
} 
相关问题