Skip to content

Commit d7c60fc

Browse files
[Security] Add setVoters() on AccessDecisionManager
1 parent 1a38ad3 commit d7c60fc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

DependencyInjection/Compiler/AddSecurityVotersPass.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\DependencyInjection\Reference;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1718

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

43-
$container->getDefinition('security.access.decision_manager')->replaceArgument(0, array_values($voters));
44+
if (!$voters) {
45+
throw new LogicException('No security voters found. You need to tag at least one with "security.voter"');
46+
}
47+
48+
$container->getDefinition('security.access.decision_manager')->addMethodCall('setVoters', array(array_values($voters)));
4449
}
4550
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.9",
20-
"symfony/security": "~2.7|~3.0.0",
20+
"symfony/security": "~2.8|~3.0.0",
2121
"symfony/http-kernel": "~2.2|~3.0.0"
2222
},
2323
"require-dev": {

0 commit comments

Comments
 (0)