[TYPO3-mvc] to read settings in model

Stephan Schuler Stephan.Schuler at netlogix.de
Sat Jan 25 00:48:32 CET 2014


Hey there.

Well ... you most likely don't want that.

The model is something "global". You can have lots controllers, actions, pages. Each of those could make use of your model. Think about fe_users, which are available through a FrontendUser object. You might have hundrets of pages that use the very same FrontendUser. You might have very different extensions. Maybe there are a couple of extensions you just downloaded from TER and a couple of others you created yourselfe. The FrontendUser object would be the same in all situations, and it should behave in all situations. You clearly don't want to have the FrontendUser being initalized with tx_news settings in the first place and have the tx_use settings of the FrontenUser being still available when the user gets reused in your own extension a couple of lines of code later on the same page. But that's what happens: The FrontendUser object doesn't get destroyed but it gets reused.

Controllers are something "local". Let's call it "scope". An action has a dedicated entry point (the very first line of the action if you create just actions; or the spot where the subrequest is executed if you dig deeper) and a very dedicated ending (the very last line of your view, for example). So you will never experience having an action being initialize with a given set of settings and reused and reexecuted in a completely different context. If you put a single controller/action on a single page multiple times, they will be instanciated multiple times and can have different settings -- which is completely different from how models are used.

So, if you really want to have some settings somehwere outside of your controller: Fetch them yourself. You need to let inject the ConfigurationManager and ask it for settings. But then you need to know the absolute configuration path of your configuration through TypoScript (config.tx_mxext.plugin.settings.whatever).


Regards,


Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



--
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



________________________________________
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [typo3-project-typo3v4mvc-bounces at lists.typo3.org]" im Auftrag von "Alexander Averbukh [alav at gmx.net]
Gesendet: Freitag, 24. Januar 2014 16:52
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: [TYPO3-mvc]  to read settings in model

Hello all,

does anybody know,  how I can read settings in the model? It is  very easy in the controller with $this-> settings. But I need them in the model.

Thank you.
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list