A
A
AlikDex2017-06-14 02:12:25
Yii
AlikDex, 2017-06-14 02:12:25

Question yii'stam, well, symphonists, too, take a look?

Sorry for not being so informative. I just don't know how to phrase the question.
In general, the theme is I sat, so I thought I thought. I do not like any Yii::$app->params['site_title']arrays for settings. It's dull and tedious to prescribe this all the time in templates. I cut down my settings with harlots in short. Through the class, well, I connected it through the components. It turned out to be an even more depressing sight: Yii::$app->settings->get('site_title');
Here. Let's get to the heart of the matter. What if we inject this object with settings into the View object? Well, like that in the template was $this->settings->get('site_title');. Isn't it normal? What are the pitfalls? Or basically idea mr.? What will the symphonists say about this, it's very interesting how they deal with such situations (when a global config is needed)? Or maybe it's better to make a static class.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-06-14
@AlikDex

I don't like any Yii::$app->params['site_title'] arrays for settings.

And it’s right that they don’t like it, such an approach creates only unnecessary and not obvious connections. How to avoid it depends on the specific tasks.
Well, it's not very normal. It turns out that the settings of a particular View contain the titles of all View-sites. It seems to be nothing terrible, but it's somehow not right
. As far as I understand, you want to put the title settings of all pages into a single settings file. In this case, it’s better to implement some kind of behavior that will respond to the corresponding View event, select the necessary title for a particular View (for example, by route) and set it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question