Open Drachenkaetzchen opened 7 years ago
Hi @felicitus,
SF 3.3 implements autowiring from the work that has been done on DunglasActionBundle. This means it should do exactly what you expect: having services injected into class constructors, without having to define them.
However, DunglasActionBundle was not imported as-is, thus the configuration node dunglas_action
in config.yml
becomes irrelevant.
To configure which directories should be included or excluded from autowiring, everything is now in your new services.yml
.
If you already had a running app under SF <= 3.3 and then upgraded to 3.3, your app/config/services.yml
has not been overwritten (of course). When you download or clone a fresh SF 3.3 install, the default app/config/services.yml
is now full of comments on how the new DI works.
You should better have a look at The new Symfony 3.3 Service Configuration Changes Explained, which shows a new app/config/services.yml
sample.
Personnally, autowiring now totally works on my app without DunglasActionBundle. the most touchy part was about services that are now private
by default.
However, I'm poking @dunglas now because there's still something missing in the port: with DunglasActionBundle, one could associate a specific interface or base class to a set of tags:
# app/config/config.yml
dunglas_action:
directories: ...
tags:
'My\Custom\Interface\To\Auto\Tag':
- 'my_custom.tag'
- [ 'my_custom.tag_with_attributes', { attribute: 'value' } ]
How can we now achieve this without the bundle? SF docs correctly mention auto-tagging for built-in tags (console.command, kernel.event_subscriber, etc) but nothing for custom ones. Any ideas?
Thanks, Ben
@bpolaszek you can use the autoconfigure
feature: https://symfony.com/blog/new-in-symfony-3-3-service-autoconfiguration
Magical. Didn't notice the _instanceof
part. :tada: :confetti_ball: :thumbsup:
The README.md file states:
However, I find this not to be true. When upgrading to Sf3.3 and removing this bundle, any actions I have defined now stopped working, even with
autowiring
enabled. The root cause is that no services are passed to the class constructors anymore, whilst with this bundle, they do.Unfortunately, both the blog and documentation links in that section do not provide information on how to upgrade.
I have 2 questions: