Skip to content

Commit

Permalink
minor #50158 Fix registering traceable voters, argument resolvers and…
Browse files Browse the repository at this point in the history
… normalizers (nicolas-grekas)

This PR was merged into the 6.3 branch.

Discussion
----------

Fix registering traceable voters, argument resolvers and normalizers

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

By using service decoration to trace voters, resolvers and normalizers, we break the possibility to register them under several tags. We also make it harder to decorate them for end users. But adding observability to those doesn't require adding side effect to service definitions. Instead, we can and should use regular decoration.

Commits
-------

12fc94d98f Fix registering traceable voters, argument resolvers and normalizers
  • Loading branch information
nicolas-grekas committed May 2, 2023
2 parents ef30078 + c74dcff commit e198462
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/AddSecurityVotersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function process(ContainerBuilder $container)
}

if ($debug) {
$voterServices[] = new Reference($debugVoterServiceId = 'debug.security.voter.'.$voterServiceId);
$voterServices[] = new Reference($debugVoterServiceId = '.debug.security.voter.'.$voterServiceId);

$container
->register($debugVoterServiceId, TraceableVoter::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public function testThatVotersAreTraceableInDebugMode()
$compilerPass = new AddSecurityVotersPass();
$compilerPass->process($container);

$def1 = $container->getDefinition('debug.security.voter.voter1');
$def1 = $container->getDefinition('.debug.security.voter.voter1');
$this->assertNull($def1->getDecoratedService(), 'voter1: should not be decorated');
$this->assertEquals(new Reference('voter1'), $def1->getArgument(0), 'voter1: wrong argument');

$def2 = $container->getDefinition('debug.security.voter.voter2');
$def2 = $container->getDefinition('.debug.security.voter.voter2');
$this->assertNull($def2->getDecoratedService(), 'voter2: should not be decorated');
$this->assertEquals(new Reference('voter2'), $def2->getArgument(0), 'voter2: wrong argument');

Expand Down

0 comments on commit e198462

Please sign in to comment.