Voter 似乎适用于我的整个应用程序......除了在这个控制器上:
$entity = $em->getReference('AppBundle:Offer',$id);
$this->denyAccessUnlessGranted('overview', $entity);
此 Voter 方法收到错误参数的地方....
支持($属性,$主题)
dump($attribute)-> ROLE_USER // instead 'overview'
dump($subject)-> Request Object // instead $entity
选民配置是:
app_voter:
class: AppBundle\Security\Authorization\AppVoter
public: true
strategy: affirmative
arguments: ['@role_hierarchy', '@security.token_storage']
tags:
- { name: security.voter }
如果我在控制器代码上写“视图”而不是“概述”,问题就会消失。