Updating config in controller

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Autumn Shade
Registered User
Posts: 29
Joined: Thu May 30, 2019 12:38 pm

Updating config in controller

Post by Autumn Shade » Mon Jun 03, 2019 10:41 am

Greetings. I may not seem to understand this correctly, but I want to ask if configs are only available in migrations or they can be updated in controller. Let me give you an example how I want to use it.

Example:

I have a single cooldown constant right now, I want to make it editable from the acp, but making a table just for that does not seem quite right to me, so I decided to read about config, so I can make it a variable value. So, I added it to a config with

Code: Select all

array('config.add', array('ext_cooldown', 30));
but once It passes to the controller, on form submit, I don't know how to update that data. Maybe create an event after submitting and triggering it? I want to hear your opinion on this.

User avatar
Autumn Shade
Registered User
Posts: 29
Joined: Thu May 30, 2019 12:38 pm

Re: Updating config in controller

Post by Autumn Shade » Mon Jun 03, 2019 10:44 am

Nevermind that topic, I did it without reading, for which I am sorry. If anybody gets onto this, the solution is: You go to services.yml, include your config and do

Code: Select all

$this->config->set
method.

Post Reply

Return to “Extension Writers Discussion”