| Current Path : /home/jeromecohp/www/tmp/yooessentials/modules/core/src/Config/ |
| Current File : /home/jeromecohp/www/tmp/yooessentials/modules/core/src/Config/ConfigController.php |
<?php
/**
* @package Essentials YOOtheme Pro (Freemium) 1.6.8
* @author ZOOlanders https://www.zoolanders.com
* @copyright Copyright (C) Joolanders, SL
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
namespace ZOOlanders\YOOessentials\Config;
use YOOtheme\Http\Request;
use YOOtheme\Http\Response;
use ZOOlanders\YOOessentials\Config;
class ConfigController
{
public const CONFIG_SAVE_URL = 'yooessentials/config/save';
public const CONFIG_IMPORT_URL = 'yooessentials/config/import';
public static function save(Request $request, Response $response, Config $config)
{
try {
$values = $config->replace($request('config', []))->persist();
} catch (\Exception $e) {
$request->abort($e->getCode(), $e->getMessage());
}
return $response->withJson(['data' => $values], 200);
}
public static function import(Request $request, Response $response, ConfigUpdater $updater)
{
$config = $updater($request('config', []));
return $response->withJson($config, 200);
}
}