SensioFrameworkExtraBundle
SensioFrameworkExtraBundle copied to clipboard
Naming ParamConverter with autowiring activated and with no priority set
Hello,
I'm trying to call my CustomParamConverter
from my Controller.
If I understand how converters work: if I don't explicitly write the converter=
options in the @ParamConverter
annotation it will call ALL converters by priority.
Problem is if I want to typed my controller's param with an Entity class, then it will call the DoctrineParamConverter
So, I have to declare explicitly my converter in my services.yml
, give it a name (like my_converter) and then call the @ParamConverter
annotation with the converter="my_converter"
options.
Is there another way to give a name to my CustomParamConverter
and using autowiring ? Because when I don't declare it explicitly, the converter name seems to be NULL
in the AddParamConverterPass
class :/
Maybe we could add a getName method in the paramConverterInterface ?
Ok I just understand that I should use DTO/Value object with param converter (instead of entity itself) if I don't want to use database and don't want to specify the paramConverter
But my question about naming the paramConverter is still available ^^'
I think adding a getName
function could be a great solution
Same here. Custom param conventer has null
name when autowiring and therefore it is not picked up due to exception "No converter named 'bar' found for conversion of parameter 'foo'"
Yes or auto set the name to something like the class name or the FQCN. It's currently driving me a bit crazy 😆