-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NFR: Get one element of the array with config->get() #12221
Comments
Dot notation is very good idea |
I think will be better: $adapter = $this->config->path('application.database.adapter', 'Mysql');
$adapter = $this->config->path('application/database/adapter', 'Mysql', '/'); |
Ye. Fine option |
it's a little confusing use 'path', for me is better 'get' |
But what if for some weird reason someone already have named section with dot ? |
@Jurigag you mean this? <?php
return new \Phalcon\Config([
'database' => [
'adapter' => 'Postgresql',
'host' => 'localhost',
'username' => 'xerron',
'password' => 'root',
'dbname' => 'db_uwu'
],
// ...code ...
' section.with.dot' => 'mmm...'
] good question. 👍 |
I need this so bad! 100x thumbs up |
Will be implemented in 3.1.0 |
So implement it in other places too, as far as i know people wanted this in forms too and somewhere else. |
In PHP7 default values is most readable: $adapter = $this->config->get('database.adapter') ?? 'Mysql'; |
but it's longer and we support not only PHP7 |
Just add option to just call |
Well, this is good: $adapter = $this->config->path('application/database/adapter', '/'); |
This is cool |
@sergeyklay Actually what @xerron needs, is only: |
@udarkness Related to #11157 |
After read all above I think, the best way is something like this:
Use 3rd param to reset separator per request: Return Three ways to get default value:
And I'm absolutely sure that |
get($key, $default = null) get('Dashboard/Main.plugins', []) Up to the first dot, the path to the file. After first dot using as array dot notation. Something like this? |
What? But config adapter itself accept file path, so no, it can't be like this. |
А если он будет принимать путь к папке с конфигами, и получится ленивая загрузка конфигураций только там где это нужно и со значениями по умолчанию? And if he will take the path to the configuration file, and you get lazy loading configurations only where it is needed and with default values? Sorry translation may be inaccurate. |
Implemented in the |
@fenixphp This should be a separated NFR |
The good from the get function is that you can set a default value.
now:
This is better:
The text was updated successfully, but these errors were encountered: