phemellc / yii2-settings

Yii2 Settings Module
Other
151 stars 74 forks source link

Default value on get setting #3

Closed dub34 closed 9 years ago

dub34 commented 9 years ago

Thank you for this extension. It`s very usefull. But it will be better to add default value in get, when the setting is not set. f.e. $value = $settings->get('section.key',10); If not "section.key" set, we get $value=10;

arisk commented 9 years ago

Should it return the default value if a call to empty returns true?

dub34 commented 9 years ago

i think yes

dub34 commented 9 years ago

and I found another problem. if i get setting without section f.e. $value = $settings->get('key'), i get the exception Undefined offset: 1 in ...Settings.php:101.

Of course I can call get with '.key' param

arisk commented 9 years ago

I thought about it some more. False is a valid configuration value. I'm adding default but it will only return the default value if the setting doesn't exist at all.

dub34 commented 9 years ago

I'm adding default but it will only return the default value if the setting doesn't exist at all

I think it will be enough

p.s if there are mistaker in the text, please sorry. my english is poor. i`m from ukraine :)

arisk commented 9 years ago

No need to apologize. Thank you for reporting :)