Using Symfony, I am displaying a table with some entries the user is able to select from. There is a little more complexity as this might include calling some further actions e. g. for filtering the table entries, sorting by different criteria, etc.
I have implemented the whole thing in an own bundle, let's say ChoiceTableBundle
(with ChoiceTableController
). Now I would like to be able to use this bundle from other bundles, sometimes with some more parametrization.
My desired workflow would then look like this:
- User is currently working with Bundle
OtherBundle
and triggerschooseAction
. -
chooseAction
forwards toChoiceTableController
(resp. its default entry action). - Within
ChoiceTableBundle
, the user is able to navigate, filter, sort, ... using the actions and routing supplied by this bundle. - When the user has made his choice, he triggers another action (like
choiceFinishedAction
) and the control flow returns toOtherBundle
, handing over the results of the users choice. - Based on these results,
OtherBundle
can then continue working.
Additionally, OtherOtherBundle
(and some more...) should also be able to use this workflow, possibly passing some configuration values to ChoiceTableBundle
to make it behave a little different.
I have read about the "Controller as Service" pattern of Symfony 2 and IMHO it's the right approach here (if not, please tell me ;)). So I would make a service out of ChoiceTableController
and use it from the other bundles. Anyway, with the workflow above in mind, I don't see a "good" way to achieve this:
- How can I pass over configuration parameters to
ChoiceTableBundle
(resp.ChoiceTableController
), if neccessary? - How can
ChoiceTableBundle
know from where it was called? - How can I return the results to this calling bundle?
Basic approaches could be to store the values in the session or to create an intermediate object being passed. Both do not seem particularly elegant to me. Can you please give me a shove in the right direction? Many thanks in advance!