我已经实施了以下选民
服务定义
security.access.company_voter:
class: Application\...\CompanyVoter
public: false
tags:
- { name: security.voter }
选民 申请/.../CompanyVoter.php
#...
public function vote(TokenInterface $token, $object, array $attributes)
{
if ( !($this->supportsClass(get_class($object))) ) { # <- Problem here
return VoterInterface::ACCESS_ABSTAIN;
}
foreach ($attributes as $attribute) {
if ( !$this->supportsAttribute($attribute) ) {
return VoterInterface::ACCESS_ABSTAIN;
}
}
$user = $token->getUser();
if ( !($user instanceof UserInterface) ) {
return VoterInterface::ACCESS_DENIED;
}
if ( $user->getCompany() == $object->getCompany() ) {
return VoterInterface::ACCESS_GRANTED;
}
return VoterInterface::ACCESS_ABSTAIN;
}
#...
但是对投票者的每一个小调用(除了第一个Symfony\Component\HttpFoundation\Request
)都给出了一个Application\...\CompanyVoter
as的实例$object
(第二个参数vote()
)。
可能是什么原因?