[FLOW3-general] Question about dependency injection (and a second one about configuration)

"Christian Müller (Kitsunet)" christian.mueller at typo3.org
Sun Nov 6 17:27:16 CET 2011


>
> 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?

Hi Jens,
I don't think that dependency injection will help you in your case.

I would maybe settle for a getter and a transient property in your 
model, that way you can create a lazy instance of your presenter from 
the template if needed.

{model.getPresenter.somePresenterGetter}


> 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?

Configuration is cached, so don't worry about a big file.

> *(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?)

Just add it to your packages settings, that way it will be parsed by 
FLOW3 directly.

cheers,

Christian


More information about the FLOW3-general mailing list