Skip to content

Commit

Permalink
[Security] Add setVoters() on AccessDecisionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed May 23, 2015
1 parent 1a38ad3 commit d7c60fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion DependencyInjection/Compiler/AddSecurityVotersPass.php
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Exception\LogicException;

/**
* Adds all configured security voters to the access decision manager.
Expand All @@ -40,6 +41,10 @@ public function process(ContainerBuilder $container)
$voters = iterator_to_array($voters);
ksort($voters);

$container->getDefinition('security.access.decision_manager')->replaceArgument(0, array_values($voters));
if (!$voters) {
throw new LogicException('No security voters found. You need to tag at least one with "security.voter"');
}

$container->getDefinition('security.access.decision_manager')->addMethodCall('setVoters', array(array_values($voters)));
}
}
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.9",
"symfony/security": "~2.7|~3.0.0",
"symfony/security": "~2.8|~3.0.0",
"symfony/http-kernel": "~2.2|~3.0.0"
},
"require-dev": {
Expand Down

0 comments on commit d7c60fc

Please sign in to comment.