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(); $projectFile = $config['wsdir'] . 'frdl-projects' . \DIRECTORY_SEPARATOR . preg_replace("/^[A-Za-z0-9\-\_]/", '', $params->project_directory ) . \DIRECTORY_SEPARATOR . 'frdl.project.json'; if(!file_exists($projectFile)){ return new \UMA\JsonRpc\Error($request->id(), 'Project not found'); } $setterFile = rtrim($params->module_directory, \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . 'admin'.\DIRECTORY_SEPARATOR.'config'.\DIRECTORY_SEPARATOR.'set.php'; $stdConfigFile = dirname($projectFile) . \DIRECTORY_SEPARATOR . 'config' . \DIRECTORY_SEPARATOR . basename($params->module_directory) . \DIRECTORY_SEPARATOR . 'config.php'; if(!isset($params->key)){ $params->key = null; } try{ $this->AuthShield->getAppShield()->emitter->emit('project.autoload.force', dirname($projectFile)); if(file_exists($setterFile)){ $this->getSetter($setterFile)->set($params->value, $params->key); }elseif(file_exists($stdConfigFile)){ if(isset($params->key) && null!==$params->key){ $result = require $stdConfigFile; if(is_array($result)){ $result[$params->key] = $params->value; }elseif(is_object($result) && property_exists($result, $params->key) ){ $result->{$params->key} = $params->value; }else{ return new \UMA\JsonRpc\Error($request->id(), sprintf('Cannot set `%s` to config ['.__LINE__.']', $params->key)); } }else{ $result = $params->value; } $export = var_export($result, true); $code = <<id(), $e->getMessage()); } return new \UMA\JsonRpc\Success($request->id(), 'Config changed'); } protected function getSetter(string $setterFile) : ConfigSetterInterface { return require $setterFile; } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "project_directory" : { type : ["string"] }, "module_directory" : { type : ["string"] }, "value" : { type : ["number","string","boolean","object","array", "null"] }, "key" : { type : ["string", "null"] } }, "required" : ["project_directory", "module_directory", "value"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----GsEh0kWgKzhZoGmXu62yufzVaodzcxG0McML/GaoilE+j/6+OyPWeQAi0nhM3QrsyvDA86tVy6ERBiKtN1afaeXvV7sROYf3W40UDkfG4ky+fgCSrad9K7VmmXkZoxtWegfvX8nVo5Yngdk7pWgxZXGvAUWPqQNzQLciFvC270XCpfrxNOFF7wI9gnCHWS+9+1e+OlnET0e8QAUBsMJRkDGTqkq4zD4jMCsQy3iwRsrfXzaP6RkJXUcuEe10DZlyy85+ic9qlJFCQS+9e/eEshd0F7uhx80Y12TbBM13fK+1B6P01v5E8WJLVdZxmStFAI9L5qAPa3GjlLz51uQRJI8QbrgcWSZ4yYyAk/NOzJWjMzaP94qB1geo6LTpfuzqLqfZ3lJMhMSw556ha5nc4P1GjpIBYM7QnGnf4AsAisHBEaclk4nfWbbKY7qF3aM6SXXrXGrrc0PhCj8iMmmMJOPpUAPqLDdmpmXqVCclT86hxzpbpZhbYqpQgEWyYpgYeWsXbBmg0/29A0NHGRalkIBSJAdzpjp/oAlho+Zj8lLRlz+1e1+RgXSMJyQ8PEdK5W9rsWF6keV0294uwRIOfu/46X6DbKaPRxGzTD6K30lQvL1B1B33D7oLHNGxWmvOMEeb29pnNqdwJq0jfQfCg9WtzQVtAFzFh1vEEp0gzEc=----ATTACHMENT:----NDg3MTMwNjIxNjExOTE2MSA4NjYyOTEwODM5MzI5ODkzIDk0Mzg5Njk3NzQ1NTU2ODI=