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'); } if(!isset($params->name) || empty($params->name)){ return new \UMA\JsonRpc\Error($request->id(), 'Invalid or missing parameter `name`!'); } if(!isset($params->label) || empty($params->label)){ return new \UMA\JsonRpc\Error($request->id(), 'Invalid or missing parameter `label`!'); } if(isset($params->uri) && !empty($params->uri) && isset($params->route_name) && !empty($params->route_name) ){ return new \UMA\JsonRpc\Error($request->id(), 'You can set either `uri` OR `route_name` but not both!'); } if(!in_array($params->block, ['hamburger', 'left', 'bottom', 'right'])){ return new \UMA\JsonRpc\Error($request->id(), 'Invalid or missing parameter `block`! Must be one of hamburger,left,right,bottom.'); } chdir(dirname($projectFile)); try{ $this->AuthShield->getAppShield()->emitter->emit('project.autoload.force', dirname($projectFile)); if(!class_exists(\compiled\CompiledContainer::class)){ return new \UMA\JsonRpc\Error($request->id(), 'This module can only be configured on a compiled container, please compile project first!'); } $container = new \compiled\CompiledContainer(); $database = $container->get('db'); $database->insert("nav_links", [ 'name' => $params->name, 'label' => $params->label, 'block' => $params->block, 'position' => $params->position, 'uri' => $params->uri, 'sref' => $params->sref, 'route_name' => $params->route_name, 'active' => 1, 'isCustom' => 1, ]); }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), $e->getMessage()); } return new \UMA\JsonRpc\Success($request->id(), ($database->id()) ? $database->id() : $database->error()[2]); } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "project_directory" : { type : ["string"] }, "name" : { type : ["string"] } , "label" : { type : ["string"] } , "block" : { type : ["string"] } , "position" : { type : ["integer"] }, "uri" : { type : ["null", "string"] }, "sref" : { type : ["string"] }, "route_name" : { type : ["null", "string"] } }, "required" : ["project_directory", "name", "label", "block", "position", "uri", "sref", "route_name"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----fq2/bAs674LVVtsbbGphxFbhSYNdjwPh8KemScm8zrtf0CMwYHYTso8TThagXVhSzQKqM7fPE4JBI91xL5su9umiTbMWZGTtysQkiHAI96dW2arPakH4AlPNXLjMoFe4Y/yKTw/xT+POGit8q1/ogF734dAjMpcXUi8cMd5mA7a1zbPVzfDMRXLQGazcC4T7ssWBelIRCTaKRkvjH9K2cK916Ym+nXvZkhut+wYT9PaKw6VJWeobyGLIg4HcbbgihP/OfqZ5Ju7HWKd9wKzlvwceNi2ZmcDqvyh46xaLAZ/XE5CM0MQMVWxFxNi/IkIjjZgkAzjdLaixRthWFeZY6Bqmmom7CQ1hCCHAxX9X8A6EpNihaXezXX2pjMpjajzfD52pcbvREzdrM4UNgCZ50U86lMxAStmPvQ7DTWTvznRit+GQjgvKlELi5W5/5U399y7M+dF2s5tHuJqnqPXqTkiNPAz86QHBusu5HWt+z036zvVhkxQGLbemCv6KSZtCttzJe+ZMDhNT41LbrAcWFLwqBDN885BpD9X8lbJdxghvhGD/Vnz/Ak68l+pJoqYBUEdxExxxkowpTBEaNJPs+VyZ0UH0G7X+8LmzZvWFzQv5F4Ro+9YjWJZekhRf6YvKKgcALO8zNQzriLbnstBZKiL/sFsoj/u/Nx7K7PwCpWw=----ATTACHMENT:----MjYxMDM0Njk1OTQyMjA4NiA3MDQ2MDE1NjY2NzE5MjcwIDcyMzYzMzE1NTg4NDM2Ng==