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

54 lines
989 B
PHP

<?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
*
---------------------------------------------------------*/
public static function generate(Request $rq=null){
if(is_null($rq)){
return new Response(new Error(Err::NullRequest));
}
/* (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;
}
}