Setting a Config Item |
Hello
Is it possible to set a value into an item loaded from a config file? I read into the manual the page about "Config Class" Expecially about "set_item" function But which is the syntax for 'item_name' in case item is loaded from a config file? Example: In my controller: PHP Code: $this->load->library(array('ion_auth')); In this case, I set 'new_value' into config array, but NOT in "ion_auth" occurrence... Is it possible to do this? Thanks
As you have realized Ion auth loads config items into its own config key using this scheme
PHP Code: $this->load->config('ion_auth', TRUE); What that means is that $config['ion_auth'] will hold an array of the contents of application/config/ion_auth.php So to set the identity key this ought to work PHP Code: $config['ion_auth'] ['identity'] = 'new_value'; Or this amounts to the exact same thing only it requires more typing. PHP Code: $ion_auth_config = $this->config->item('ion_auth');
With:
PHP Code: $config['ion_auth'] ['identity'] = 'new_value'; I initialize $config array; but it isn't the same array where original configuration ion_auth was loaded... If I try: PHP Code: var_dump($config); I have: array(1) { ["ion_auth"]=> array(1) { ["identity"]=> string(9) "new_value" } } If I try: PHP Code: var_dump($this->config); I see the original value, as loaded from file... object(CI_Config)#3 (3) { ["config"]=> &array(...) { ["ion_auth"]=> array(...) { ["default_rounds"]=> int(8) ["identity"]=> string(5) "email" ["min_password_length"]=> int(8) } } }
Doh!
That's what I get for responding when I should have gone to sleep. This line PHP Code: $config['ion_auth'] ['identity'] = 'new_value'; Should have been PHP Code: $this->config->config['ion_auth'] ['identity'] = 'new_value';
Ok. Many thanks.
This is th correct syntax for configuration parameters 'item_name' loaded from file 'file_name': PHP Code: $this->config->config['file_name'] ['item_name'] = 'new_value'; |
Welcome Guest, Not a member yet? Register Sign In |