-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
TaggedLocator attribute does not work in controller constructor #49082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey, thanks for your report! |
Yes, it's still relevant. I experienced this problem as well, it was very weird to suddenly have other services in my locator. |
Yes, v6.3.4 #[\Symfony\Component\HttpKernel\Attribute\AsController]
final class MyController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
{
public function __construct(
#[\Symfony\Component\DependencyInjection\Attribute\TaggedLocator(SomeType::class)]
private \Symfony\Contracts\Service\ServiceProviderInterface $provider,
) {
dd($this->provider->getProvidedServices());
} This gives:
|
Oh, this happens in the constructor, sorry I've missed that part. |
nicolas-grekas
added a commit
that referenced
this issue
Jan 30, 2024
…precedence over bindings (HypeMC) This PR was merged into the 6.3 branch. Discussion ---------- [DependencyInjection] `#[Autowire]` attribute should have precedence over bindings | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #49082 | License | MIT | Doc PR | - It seems logical (I think) that the `#[Autowire]` attribute has precedence over any bindings. Commits ------- c429fe5 [DependencyInjection] #[Autowire] attribute should have precedence over bindings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected
6.2.* (and maybe other)
Description
A wrong Container is injected when using
#[TaggedLocator('XXX')]
in an argument of a controller constructorHow to reproduce
add this controller
Possible Solution
We can work-arround this issue with the following constructor:
but ...
Additional Context
I guess - there is a conflict with the "ServiceSubscriberInterface"
The text was updated successfully, but these errors were encountered: