Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Inheritance: implements Symfony\Component\Security\Authorization\AccessDecisionManagerInterface
 /**
  * Constructor.
  *
  * @param VoterInterface[] $voters                     An array of VoterInterface instances
  * @param string           $strategy                   The vote strategy
  * @param Boolean          $allowIfAllAbstainDecisions Whether to grant access if all voters abstained or not
  */
 public function __construct(ContainerInterface $container, $strategy = 'affirmative', $allowIfAllAbstainDecisions = false, $allowIfEqualGrantedDeniedDecisions = true)
 {
     parent::__construct(array(), $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
     $this->voters = array();
     foreach ($container->findTaggedServiceIds('security.voter') as $id => $attributes) {
         $this->voters[] = $container->get($id);
     }
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider getStrategyTests
  */
 public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
 {
     $token = $this->getMock('Symfony\\Component\\Security\\Authentication\\Token\\TokenInterface');
     $manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
     $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO')));
 }