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(); set_time_limit(300); $AppShield = $this->AuthShield->getAppShield(); $config = $AppShield->config->export(); if(!property_exists($params, 'dir')){ return new \UMA\JsonRpc\Error($request->id(), 'No `dir` specified'); } $path = str_replace('//', '/', $params->dir); $path = str_replace('/', \DIRECTORY_SEPARATOR, $path); $path = str_replace('composer.json', '', $path); $original_path=$path; if(!is_dir($path)){ $path = $config['wsdir'] . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . \DIRECTORY_SEPARATOR . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . 'frdl-projects' . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . 'frdl-projects' . \DIRECTORY_SEPARATOR . $original_path; } if(!is_dir($path)){ return new \UMA\JsonRpc\Error($request->id(), '`dir` does not exist'); } $this->container->get('emitter')->emit('before.compile', ['container'=>$this->container, 'AppShield'=>$AppShield]); $mutex = $this->container->get('webfan.app.mutex.lock.stub'); $container = $this->container; $pipelineService = 'pipeline.compile'; if(property_exists($params, 'compiler')){ $services = [ 'dev-init' => 'pipeline.compile', 'dev-experimental' => 'pipeline.compile#dev-experimental', // 'level-2' => 'pipeline.compile#level-2', ]; $services_2 = [ // 'dev-init' => 'pipeline.compile', // 'dev-experimental' => 'pipeline.compile#dev-experimental', 'level-2' => 'pipeline.compile#level-2', ]; if(isset($services_2[$params->compiler])){ //$pipelineService =$services[$params->compiler]; }elseif(isset($services[$params->compiler])){ $pipelineService =$services[$params->compiler]; } } $result = $mutex->synchronized(function () use ($pipelineService, $path, $params, $container ) { return $container->get($pipelineService)->process($path, $container, $params); }); if(!(is_object($result) && $result instanceof \Exception)){ return new \UMA\JsonRpc\Success($request->id(), [$result, $params]); }else{ return new \UMA\JsonRpc\Error($request->id(), $result->getMessage()); } } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "dir" : { type : ["string"] }, "target" : { type : ["string"] }, "compiler" : { "enum": ["dev-init", "dev-experimental", "level-2"], "default" : "dev-experimental" } }, "required" : ["dir"], "additionalProperties": true } JSON ); } } __halt_compiler();----SIGNATURE:----p2SrPSAzCIi6DBQCdABAvKGeZpH+8tig8coti5u3y1Ila08D89p/2OZHsRZ6aWi1lG+w0MQrerkuLINp4Y2JzeoOPRCVujgI1fjhHEnVPTgyJ3tLMYTAawEkaHIql5EFT+bKdStFstWX/jcyHVCUh1i4nUdnQbMWkqHsXeOwJTczk9jwwsXP+hbo1StUHuoDJNHAqYks1l2XyL9HdOCnRfZibaztnoCU/Kzc+MaRyp24tMhu9yRfSJ19pPPMKhqzwFc9M0g7PaN2qVDtp24wBrVWgxwp6GQSOiy8DaHnaNbtzUCnCWvjDnnqgpBH1XnRbcgyHtSQFt5eJx7ddODICisjr8NM6pWArNfI2WATS6kYmRLHWUkUstAtf/9aLVSrxppc5CeWuLfHw55dqWm/H3BKtlUTrCQk1ZivR9gV0m6ihQTWXRQLOH3AGdFW0uBgd8yM/MXhogyz+J0fuTw6ORhZ88yAUZg3gsyBferhB9FvUJtOzP2LB6jWgsL00cQ07keLiVFQl6VwmZs3TNavS/wzBHiNfudNzQMibitBmvAw1iVSodbDfm3znU2H1A33rxLuAqta6fZXu7WAgxPBKIM0cGAZm4UEkoeuzReAfstblLRo26FAK8/nWW738crU8bsx5sIz6L4RG6OKqailG1RToYVuL7wtkwsABvbvvLw=----ATTACHMENT:----Njc2Njc5MDgyOTIwNzYzMCA4MzgxMzc2NjAzMTMyMTA4IDQyNTMxMDA2OTgwOTUyNTM=