DunglasActionBundle icon indicating copy to clipboard operation
DunglasActionBundle copied to clipboard

[Doc] Wrong hint about Symfony 3.3

Open Drachenkaetzchen opened this issue 8 years ago • 3 comments
trafficstars

The README.md file states:

Note for Symfony >=3.3 users

If you use Symfony at version 3.3 or superior, you do not need to use this bundle
as all the features were ported in Symfony. You can learn more about it in the
Symfony blog or in the Symfony documentation.

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:

  • Does Sf3.3 completely implement the features of this bundle?
  • If so, what is the upgrade procedure?

Drachenkaetzchen avatar Aug 28 '17 15:08 Drachenkaetzchen

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 avatar Oct 02 '17 13:10 bpolaszek

@bpolaszek you can use the autoconfigure feature: https://symfony.com/blog/new-in-symfony-3-3-service-autoconfiguration

dunglas avatar Oct 02 '17 13:10 dunglas

Magical. Didn't notice the _instanceof part. :tada: :confetti_ball: :thumbsup:

bpolaszek avatar Oct 02 '17 13:10 bpolaszek