예제 #1
0
파일: Method.php 프로젝트: apioo/fusio-impl
 public function getDocumentation($routeId, $version, $path)
 {
     if ($version == '*' || empty($version)) {
         $version = $this->methodTable->getLatestVersion($routeId);
     }
     $methods = $this->methodTable->getMethods($routeId, $version, true);
     $resource = new Resource($this->getStatusFromMethods($methods), $path);
     foreach ($methods as $method) {
         $resourceMethod = Resource\Factory::getMethod($method['method']);
         if ($method['status'] == Resource::STATUS_DEVELOPMENT) {
             if (!empty($method['request'])) {
                 $resourceMethod->setRequest(new LazySchema($this->schemaLoader, $method['request']));
             }
         } else {
             if (!empty($method['requestCache'])) {
                 $request = unserialize($method['requestCache']);
                 if ($request instanceof SchemaInterface) {
                     $resourceMethod->setRequest($request);
                 }
             }
         }
         if ($method['status'] == Resource::STATUS_DEVELOPMENT) {
             if (!empty($method['response'])) {
                 $resourceMethod->addResponse(200, new LazySchema($this->schemaLoader, $method['response']));
             }
         } else {
             if (!empty($method['responseCache'])) {
                 $response = unserialize($method['responseCache']);
                 if ($response instanceof SchemaInterface) {
                     $resourceMethod->addResponse(200, $response);
                 }
             }
         }
         $resource->addMethod($resourceMethod);
     }
     return $resource;
 }
예제 #2
0
 /**
  * Reads all relations of the provided route and writes them to the tables
  *
  * @param integer $routeId
  */
 public function updateRelations($routeId)
 {
     // remove all existing entries
     $this->removeExistingRelations($routeId);
     // get dependencies of the config
     $methods = $this->routesMethodTable->getMethods($routeId);
     $schemas = $this->getDependingSchemas($methods);
     $actions = $this->getDependingActions($methods);
     foreach ($schemas as $schemaId) {
         $this->routesSchemaTable->create(array('routeId' => $routeId, 'schemaId' => $schemaId));
     }
     foreach ($actions as $actionId) {
         $this->routesActionTable->create(array('routeId' => $routeId, 'actionId' => $actionId));
     }
 }