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:----lvVwakdq4o3dAbZEgZuWREeKm4WWTle9Ik62BVEj+iYRq0UZQ3rLdax2x1hUcTQrKzhTthllF1D9+/IzLGIJBBKrCox5chet6MjyaDmM7qtWwtFdDlg9U0JTX0hQLuV3ljm9DDTlFBaRAxbvl0wVpfEKEbG6AA19DAQU/DU9+rFhz2tthiNU6nB6vHHUS0t7SCrktEqKkcBZr175OpNdojzUx6PaKp7oW701u+iyq9rVodw2Lm90Joj/E8uRUIVP8OOrh87C4w8LhgHGPLewhrv9YYInsMD368nM+Gii25ZitwMk0wQ9YUl2kbZs6TBCwpqTq0wdAtTAWiL3zLs0n+AFjDpYhlXWDpIvlLmpWJqiRJd6fyhZBI9UWmjzCsyVk6OlO3MJUC2I5/rWEgrGvL8ejiolMT683lAzQUmAAuLRG5Abq1oKsPC5Dw1arDFE7VzNBnjXLfCPV7Cok8B8+r/24RakBT3bp8cZwmOHbcG5bYfgC7r5qbvvYXcOmlil3acOzW3bOC2fxt1YVF+523qoBl4UCw1K50e96Y0PkpQd6WPk8J0qsFiJgBd/maLBlV+OWBLzhNEOmM44tpCmJttLmctR6uJwTcn9R41rdLi3TGc/oSaxt4bVrYAmrL2JN9IAHjzMBNT2QwHQCOJeUpa0B7WgDN98WHGk0k2CXs8=----ATTACHMENT:----NDc3OTEyMTcyMjcyNDc2MSA2MDY4OTI4NjI4Njc0NjE2IDI1NzI2OTIwNTU4MjgyNzY=