Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Add autoconfigure tag for ParamConverterInterface #516

Merged

Conversation

B-Galati
Copy link
Contributor

@B-Galati B-Galati commented Oct 2, 2017

I tried to add the same behavior in converters.xml but it was not working..

 <instanceof id="Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface" public="true">
            <tag name="request.param_converter" />
</instanceof>

@HeahDude
Copy link

HeahDude commented Oct 2, 2017

I tried to add the same behavior in converters.xml but it was not working..

It's better to do it in the pass anyway as it allows to auto configure any other converter.

The instance_of DI feature only applies on definitions in the same file.

@weaverryan
Copy link
Contributor

This makes sense to me: this will create a non-named converter with a priority of 0... which is probably what you want in most cases.

@B-Galati could you also update the docs: https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/74f1f17e1e5c32ca43de92611e9097a8d0e0acf2/Resources/doc/annotations/converters.rst#creating-a-converter. We should say something like "If you're using service auto-registration and autoconfiguration, you're done! Your converter will automatically be used. If not,..."

You could even link to http://symfony.com/doc/current/service_container/3.3-di-changes.html for auto-registration and autoconfiguration.

@B-Galati B-Galati force-pushed the autoconfigure-tag-param-converter branch from 678538e to ba28726 Compare October 13, 2017 20:46
@B-Galati
Copy link
Contributor Author

@weaverryan It's done thank you, let me know for anything else ;-)

you're done! Your converter will automatically be used.
If not, you must add a tag to your service:

.. _auto-registration and autoconfiguration: http://symfony.com/doc/current/service_container/3.3-di-changes.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing, this (by our standard) needs to live all the way at the end of the file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done thanks !

@B-Galati B-Galati force-pushed the autoconfigure-tag-param-converter branch from ba28726 to 305c918 Compare October 16, 2017 06:55
@fabpot
Copy link
Member

fabpot commented Oct 16, 2017

Thank you @B-Galati.

@fabpot fabpot merged commit 305c918 into sensiolabs:master Oct 16, 2017
fabpot added a commit that referenced this pull request Oct 16, 2017
…ati)

This PR was merged into the 4.0.x-dev branch.

Discussion
----------

Add autoconfigure tag for ParamConverterInterface

I tried to add the same behavior in `converters.xml` but it was not working..

```xml
 <instanceof id="Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface" public="true">
            <tag name="request.param_converter" />
</instanceof>
```

Commits
-------

305c918 Add autoconfigure tag for ParamConverterInterface
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants