diff --git a/src/Admin/Actions/ClientAction.php b/src/Admin/Actions/ClientAction.php index 2f380dc17..cc2bb2732 100644 --- a/src/Admin/Actions/ClientAction.php +++ b/src/Admin/Actions/ClientAction.php @@ -16,6 +16,7 @@ use Flarum\Core\Groups\Permission; use Flarum\Api\Client; use Flarum\Core\Settings\SettingsRepository; use Flarum\Locale\LocaleManager; +use Flarum\Events\UnserializeConfig; class ClientAction extends BaseClientAction { @@ -48,7 +49,11 @@ class ClientAction extends BaseClientAction { $view = parent::render($request, $routeParams); - $view->setVariable('config', $this->settings->all()); + $config = $this->settings->all(); + + event(new UnserializeConfig($config)); + + $view->setVariable('config', $config); $view->setVariable('permissions', Permission::map()); $view->setVariable('extensions', app('flarum.extensions')->getInfo()); diff --git a/src/Api/Actions/ConfigAction.php b/src/Api/Actions/ConfigAction.php index 83ade88c5..012151a12 100644 --- a/src/Api/Actions/ConfigAction.php +++ b/src/Api/Actions/ConfigAction.php @@ -14,6 +14,7 @@ use Flarum\Api\Request; use Flarum\Core\Settings\SettingsRepository; use Flarum\Core\Groups\Permission; use Flarum\Core\Exceptions\PermissionDeniedException; +use Flarum\Events\SerializeConfig; use Zend\Diactoros\Response\EmptyResponse; use Exception; @@ -49,6 +50,8 @@ class ConfigAction implements Action } foreach ($config as $k => $v) { + event($event = new SerializeConfig($k, $v)); + $this->settings->set($k, $v); if (strpos($k, 'theme_') === 0 || $k === 'custom_less') { diff --git a/src/Events/SerializeConfig.php b/src/Events/SerializeConfig.php new file mode 100644 index 000000000..1732c5bdf --- /dev/null +++ b/src/Events/SerializeConfig.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Events; + +class SerializeConfig +{ + /** + * The config key being saved. + * + * @var string + */ + public $key; + + /** + * The config value to save. + * + * @var string + */ + public $value; + + /** + * @param string $key The config key being saved. + * @param string $value The config value to save. + */ + public function __construct($key, &$value) + { + $this->key = $key; + $this->value = &$value; + } +} diff --git a/src/Events/UnserializeConfig.php b/src/Events/UnserializeConfig.php new file mode 100644 index 000000000..dfd511e3d --- /dev/null +++ b/src/Events/UnserializeConfig.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Events; + +class UnserializeConfig +{ + /** + * The config array. + * + * @var array + */ + public $config; + + /** + * @param array $config The config array. + */ + public function __construct(&$config) + { + $this->config = &$config; + } +}