Alternative $this->config>set_item($item, $value) |
I notice that this function is not in CI4. But, I need this function to dynamically inject (temporary) array string to public $item = [] from \Config\App.php. Is there any alternative or maybe there's a workaround I'm not noticing?
Thank you!
All the config files are classes where all the properties are public. That means that once you create an instance of a config you can modify the properties however you see fit.
PHP Code: <?php namespace App\Controllers; You can dynamically add properties to the class PHP Code: $config = new Config\App();
Thanks for the reply. It seems that it didn't work to push array to my public $item = [...];. Here's my code:
app\config\Packages PHP Code: <?php namespace Config; app\Controllers\Test PHP Code: <?php namespace App\Controllers; The output should show nuxt.js, jquery.js, idk.js, and vue.js. But instead, it just show only vue.js. In real case, I really want to dynamically add Javascript files to footer page. I have this helper works on CI3, but I'm still confused how can I make it work on CI4-rc. Thank you! ------- (12-01-2019, 06:38 PM)dave friend Wrote: All the config files are classes where all the properties are public. That means that once you create an instance of a config you can modify the properties however you see fit.
(12-01-2019, 09:16 PM)simonickalexs Wrote: Thanks for the reply. It seems that it didn't work to push array to my public $item = [...];. Here's my code: At this point you have discovered the error, but I only make the comment for those of us who come to this post for one reason or another and we do not see a conclusion. Obviously the error is that you are replacing the Scripts array with a single value, instead you can use array_push PHP Code: $ci = new \Config\Packages();
|
Welcome Guest, Not a member yet? Register Sign In |