ptut-vhost/build/api/core/Documentation.php

54 lines
989 B
PHP
Raw Permalink Normal View History

2018-02-17 17:18:58 +00:00
<?php
namespace api\core;
use \error\core\Error;
use \error\core\Err;
use \api\core\Request;
use \api\core\Config;
class Documentation{
/* (1) Attributes
---------------------------------------------------------*/
/* (1) Static */
/* (2) Instance */
/* (2) Builds the documentation
*
---------------------------------------------------------*/
2018-02-27 13:48:07 +00:00
public static function generate(Request $rq=null){
if(is_null($rq)){
return new Response(new Error(Err::NullRequest));
}
2018-02-17 17:18:58 +00:00
/* (1) Get data from config
---------------------------------------------------------*/
/* (1) If no index for this path -> exit */
if( !isset(Config::get()->index[$rq->get('id')['path']]) )
return new Response(new Error(Err::WrongPathModule));
/* (2) Local store: configuration for this path */
$cfg = Config::get()->index[$rq->get('id')['path']];
$response = new Response();
$response->append('methods', $cfg);
return $response;
}
}