Symfony\Component\Security\Authorization\AccessDecisionManager::setVoters PHP Method

setVoters() public method

Sets voters.
public setVoters ( array $voters )
$voters array An array of VoterInterface instances
    public function setVoters(array $voters)
    {
        if (!count($voters)) {
            throw new \LogicException('You must have at least one voter.');
        }

        $this->voters = array();
        foreach ($voters as $voter) {
            $this->addVoter($voter);
        }
    }

Usage Example

コード例 #1
0
 public function testSetVoters()
 {
     $manager = new AccessDecisionManager();
     $manager->setVoters(array($voter = $this->getVoterSupportsAttribute(true)));
     $this->assertSame(array($voter), $manager->getVoters());
 }