[FLOW3-general] Question about dependency injection (and a second one about configuration)
Jens Hopp
flow3 at hopp-it.de
Sat Nov 5 12:42:11 CET 2011
Hi,
a question about dependency injection.
(and an additional question about configuration)
Some Information in advance:
I would like to use a "Presenter"-object in a controller.
Every model has its own Presenter. This Presenter contains further
information about the model, for example it has some text properties like
"label", "description" (for the model itself and for its properties) and
it contains more detailed information how to display the properties.
Inside of the action method the Presenter will be assigned to the view
additional to the entities. So I can prepare views more generic for the
several property types and avoid to put text content like labels,
descriptions and so on hardcoded into the views.
Problem: This Presenter is only needed if any view is rendered (by
default in the actions "show", "index", "edit", "new").
I do not need it in redirecting actions - so I want to avoid it to be
loaded there.
Does it make sense to use dependency injection to get these Presenters
(is there any lazy loading mechanism available or even active by
default)? Or would it be better to write a special method to get the
Presenter only when needed?
A further question coming up:
I would like to configure these Presenters using yaml.
If I put all configuration of the Presenters into objects.yaml this file
will increase and become quite long (Every property of a model creates a
handful of yaml lines, a single Presenter's configuration could consist
of 50 lines or more).
Is this a problem? Because I never need all available Presenters at the
same time it could be better to create a distinct yaml file for every
Presenter*. Or not? How does flow3 deal with this?
*(If so - then 3rd Question: Use \Symfony\Component\Yaml\Parser()
directly or is there anything flow3 wraps around it that would be better
to be used?)
Thanks a lot!
Cheers
Jens
More information about the FLOW3-general
mailing list