Foundation
Foundation copied to clipboard
Register custom converters from a bundle?
The need
Automatically add custom converters (coming from a bundle) to an existing session (the default of my application).
I don't find a way to achieve this, so I have tried another approach.
Context
- Symfony application with
pomm-bundle: ~2.4
. - My application has a session flagged as default and use specific converters (add with a custom
SessionBuilder::postConfigure
). - I have a bundle (I own it) in which I declare another session (not flagged as default) with registered converters specific to my bundle.
- The main need was to add custom converters from a bundle to the default session, but I don't find how to achieve this, so I have declared a second session in the bundle
Encountered bug
In my application, I don' know why, when I get models of the project, they are randomly attached to the default session or the session add by the bundle (I guess it's not random, but I don't figure out 😄 ).
This result in ConverterException
like No converter registered for type 'public.validation_type'.
when a model use the wrong session.
I don't know if my explanations are clear, so do not hesitate to ask for more details!
The need
is the main goal, I do not need this second session, it was only to test an alternative solution because I don't find howto extends the default one through my bundle (I've tried with CompilerPass
, but I don't really know where to plug.)
Hello,
As far as I can understand, you could not find a way to declare converters you have made in your own bundle into the default Session. So you declared another session then Sf “randomly” switches from a Session to another.
It this is your problem, I would advise you to post it on stack-overflow using the pomm
tag. If it appears this is related to a bug, then we will open a ticket here.
That's it! :)
I made the post: https://stackoverflow.com/questions/70166159/register-custom-pomm-converters-from-a-bundle