How to create own application configuration?
- zalizko
- Member | 7
Hello everyone!
I'm starting with nette and confusing, I can't realize the elementary
thing – own config.
For example I wold like to setup available languages in application.
I have added to the end of config.neon
- languages
- en
- ru
and would like to get somehow this array in the BaseController.
Now my application uses this config throw error:
“Found sections ‘languages’ in configuration, but corresponding extensions
are missing.”
Could anybody help me?
- Michal Vyšinský
- Member | 608
Clean way is to create a service, which will hold languages. Something like ‘LanguagesStorage’.
Define service:
services:
- LanguagesStorage(%languages%)
Service class could look like this:
Usage:
And you can inject your service everywhere (in presenter via @inject, in other service via constructor).
Last edited by Michal Vyšinský (2014-06-19 15:29)
- zalizko
- Member | 7
Uhhh.. thanks! Looks clear now. Service for holding few parameters..
overhead..
Is it here some another way? these parameters in the config.neon, thay saves in
the SystemConfigurer? How can I get access to him / her properties? All
presenters are nested from BasePresenter then the main logic can be inside
BasePresenter (or?).
offtop: one thing related to multilingual, how i can get current language? change it? of couse I can do it by sessio or other things, is there some functionallity out-of-the-box?