AuthShield = $AuthShield; $this->container=(null!==$container) ? $container : $AuthShield->getAppShield()->getContainer(); } /** public function auth(\UMA\JsonRpc\Request $request){ return 'admin' === $this->container->get('webfan.app.fsm.user')->getCurrentState()->getName(); } * {@inheritdoc} */ public function __invoke(\UMA\JsonRpc\Request $request): \UMA\JsonRpc\Response { $params = $request->params(); $config = $this->AuthShield->getAppShield()->config->export(); if(!file_exists($params->file)){ return new \UMA\JsonRpc\Error($request->id(), sprintf('File `%s` not found', $params->file)); } try{ $file2 = str_replace('config.xml', 'config.custom.xml', $params->file); $file_p = dirname($params->file).\DIRECTORY_SEPARATOR.'preferences.json'; //$file = (file_exists($file2)) ? $file2 : $params->file; // if(file_exists($file2)){ // unlink($file2); // } // if(file_exists($file_p)){ // unlink($file_p); // } $WidgetConfig = new \webfan\hps\Widget\Config($params->file); file_put_contents(str_replace('config.xml', 'config.custom.xml', $params->file), $WidgetConfig->saveXML()); $cnf = []; $context = \frdl\Context::create($cnf); $preferences = $WidgetConfig->getPreferences(); foreach($preferences as $k => $v){ $context->set($k, $v); } file_put_contents($file_p, json_encode($context->all())); }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), $e->getMessage()); } return new \UMA\JsonRpc\Success($request->id(), 'Config reseted'); } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "file" : { type : ["string"] } }, "required" : ["file"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----dUTGgRW9k24p9LCk0M89XVXphYpjkpnJlTEUqFuUY9UNFvQU5IWLFSlS0ViuOQVdswmVfPlbPnIUFv2l0tL5Vt3q9O2eOAh4S2mxcyx1K1ht0sfgNXc7DEdvCTHXspzX7v4VovS4e+dVVdHTQkrrmeh/ky4IcARM7JL2uEsu1Bi6IKMVtOgPIbZOnjFW8cQfJpgiqU88CrqbWN43Gw7fOW9Zxq8zj8IVO4eOtgZ730P63Jc/+a7Ld+RQDDF4xo9ex6joS9m4uV9vbL43/MGB86WpTBgN0Nwxz30deyd6+hec40tL5azFsZkVp5Zlsk6jHnqldJKYIf6mZUGzIzUJxiUJ4uOggMvN8w5REQH2Wt0g/D0lhuZvFWXXoqfTmUlaKY0bW0LE2+bMa7t5sxygQScH7nxZm5Zg5IaX51m3gjoHyCuu2uf64iwvOGVZxw+GHbye/Fqs7w+NcAzYzsv7iyS2obzubI7vgXnORqRIH9xxZM6dt47Ukn8klS5+g5ve9AowNAg0TjBUiI0vk4g36AqKnGII77hrjx5u67KoUwDGQZaXf0nZed7OgSMFEQqVNJN66swc36o0s8x38ayoR1K7uSA1+6nbQqRolmmSVmIyHH47ye94b0nusn71NEbKW8yISR35e0xxan50u7iV4lXFQUAy5r6Cz4pV98Z2Iww=----ATTACHMENT:----MjE2NDQxOTE4MzA5MjA5NSA5NzQ0MzgwOTM3NDA0NzA1IDQ0OTI3MDMyNjU5NDE2MDg=